using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
namespace FineUIPro.Web.WeldMat.Recycle
{
public partial class RecycleMatTopEdit : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string usingMatId = Request.Params["usingMatId"];
var mat = BLL.UsingMatService.GetUsingMatById(usingMatId);
var weld = BLL.WeldInfoService.GetWeldInfoById(mat.WeldId);
var type = BLL.WeldTypeService.GetWeldTypeById(weld.WeldTypeId);
// 焊工
this.drpWelder.Items.Clear();
drpWelder.DataTextField = "Text";
drpWelder.DataValueField = "Value";
drpWelder.DataSource = BLL.HJGL_PersonManageService.GetWelderByUsingPlan(mat.UsingPlanId);
drpWelder.DataBind();
// 保管员
this.drpStoreMan.Items.Clear();
drpStoreMan.DataTextField = "Text";
drpStoreMan.DataValueField = "Value";
drpStoreMan.DataSource = BLL.StoremanInfoService.GetStoremanList();
drpStoreMan.DataBind();
this.txtWeldName.Text = weld.WeldName;
txtWeldSpec.Text = weld.WeldSpec;
txtWarrantybook.Text = mat.Warrantybook;
txtNumber.Text = mat.Number;
drpWelder.SelectedValue = mat.UsingMan;
txtRecycleDate.Text = DateTime.Now.ToString();
var curUser = BLL.StoremanInfoService.GetStoremanByUserId(this.CurrUser.UserId);
if (curUser != null)
{
drpStoreMan.SelectedValue = curUser.StoremanId;
}
var recycleMatTop = BLL.RecycleMatTopService.GetRecycleMatTopByUsingMatId(usingMatId);
if (recycleMatTop != null)
{
txtRecycleDate.Text = recycleMatTop.RecycleDate.Value.ToString();
txtRecycleAmount.Text = recycleMatTop.RecycleAmount.Value.ToString();
drpStoreMan.SelectedValue = mat.StoreMan;
}
}
}
///
/// 提交按钮
///
///
///
protected void btnSave_Click(object sender, EventArgs e)
{
string usingMatId = Request.Params["usingMatId"];
var mat = BLL.UsingMatService.GetUsingMatById(usingMatId);
var recycleMatTop = BLL.RecycleMatTopService.GetRecycleMatTopByUsingMatId(usingMatId);
if (this.txtRecycleAmount.Text == string.Empty)
{
ShowNotify("请输入退回数量!");
return;
}
Model.Weld_RecycleMatTop newRecycleMatTop = new Model.Weld_RecycleMatTop();
newRecycleMatTop.ProjectId = mat.ProjectId;
newRecycleMatTop.WeldId = mat.WeldId;
newRecycleMatTop.UsingPlanId = mat.UsingPlanId;
newRecycleMatTop.RecycleAmount = Convert.ToInt32(this.txtRecycleAmount.Text);
newRecycleMatTop.RecycleMan = drpWelder.SelectedValue;
newRecycleMatTop.StockMan = this.drpStoreMan.SelectedValue;
newRecycleMatTop.RecycleDate = Convert.ToDateTime(this.txtRecycleDate.Text);
newRecycleMatTop.UsePosition = mat.UsePosition;
newRecycleMatTop.UsingMatId = usingMatId;
if (recycleMatTop == null)
{
newRecycleMatTop.RecycleMatTopId = SQLHelper.GetNewID(typeof(Model.Weld_RecycleMatTop));
BLL.RecycleMatTopService.AddRecycleMatTop(newRecycleMatTop);
}
else
{
if (recycleMatTop.IsStoreManConfirm == true || recycleMatTop.IsWelderConfirm == true)
{
ShowNotify("保管员或焊工已确认,不能修改!");
return;
}
else
{
newRecycleMatTop.RecycleMatTopId = recycleMatTop.RecycleMatTopId;
BLL.RecycleMatTopService.UpdateRecycleMatTop(newRecycleMatTop);
}
}
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
}
}