11
This commit is contained in:
@@ -0,0 +1,218 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using BLL;
|
||||
using FineUIPro.Web.HJGLServer.BaseInfo;
|
||||
|
||||
namespace FineUIPro.Web.WeldMat.Recycle
|
||||
{
|
||||
public partial class RecycleMatEdit : PageBase
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
string usingMatId = Request.Params["usingMatId"];
|
||||
string welderId = Request.Params["welderId"];
|
||||
string flag = Request.Params["flag"]; // 标记1-查看
|
||||
if (flag == "1")
|
||||
{
|
||||
this.btnSave.Hidden = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.btnSave.Hidden = false;
|
||||
}
|
||||
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();
|
||||
if (!string.IsNullOrEmpty(welderId))
|
||||
{
|
||||
this.drpWelder.SelectedValue = welderId;
|
||||
this.drpWelder.Readonly = true;
|
||||
}
|
||||
|
||||
// 保管员
|
||||
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;
|
||||
this.txtRecycleAmount.Text = "0";
|
||||
//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 recycleMat = BLL.RecycleMatService.GetRecycleMatByUsingMatId(usingMatId);
|
||||
if (recycleMat != null)
|
||||
{
|
||||
txtRecycleDate.Text = recycleMat.RecycleDate.Value.ToString();
|
||||
if (recycleMat.RecycleAmount != null)
|
||||
{
|
||||
txtRecycleAmount.Text = recycleMat.RecycleAmount.Value.ToString();
|
||||
}
|
||||
if (recycleMat.ReturnMatTop != null)
|
||||
{
|
||||
txtRecycleTopAmount.Text = recycleMat.ReturnMatTop.Value.ToString();
|
||||
}
|
||||
if (recycleMat.StockMan != null)
|
||||
{
|
||||
drpStoreMan.SelectedValue = recycleMat.StockMan;
|
||||
}
|
||||
if (recycleMat.RecycleMan != null)
|
||||
{
|
||||
drpWelder.SelectedValue = recycleMat.RecycleMan;
|
||||
}
|
||||
}
|
||||
|
||||
if (type.WeldTypeName == "焊条")
|
||||
{
|
||||
this.txtRecycleTopAmount.Hidden = false;
|
||||
decimal oneNum= mat.Amount != null ? mat.Amount.Value : 0;
|
||||
decimal twoNum = mat.TwoAmount != null ? mat.TwoAmount.Value : 0;
|
||||
this.txtRecycleTopAmount.Text = (oneNum+twoNum).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.txtRecycleTopAmount.Hidden = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 提交按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
string usingMatId = Request.Params["usingMatId"];
|
||||
string isHave = Request.Params["isOnTime"]; // 从退料页面入口
|
||||
bool isOnTime = false;
|
||||
var mat = BLL.UsingMatService.GetUsingMatById(usingMatId);
|
||||
var recycleMat = BLL.RecycleMatService.GetRecycleMatByUsingMatId(usingMatId);
|
||||
var weld = BLL.WeldInfoService.GetWeldInfoById(mat.WeldId);
|
||||
var type = BLL.WeldTypeService.GetWeldTypeById(weld.WeldTypeId);
|
||||
if (this.txtRecycleAmount.Text == string.Empty)
|
||||
{
|
||||
ShowNotify("请输入退回数量!");
|
||||
return;
|
||||
}
|
||||
Model.Weld_RecycleMat newRecycleMat = new Model.Weld_RecycleMat();
|
||||
newRecycleMat.ProjectId = mat.ProjectId;
|
||||
newRecycleMat.WeldId = mat.WeldId;
|
||||
newRecycleMat.UsingPlanId = mat.UsingPlanId;
|
||||
|
||||
if (string.IsNullOrEmpty(isHave)) // 从领料页面入口
|
||||
{
|
||||
if (type.WeldTypeName == "焊条")
|
||||
{
|
||||
if (mat.UsingDate.Value.AddHours(4) < DateTime.Now)
|
||||
{
|
||||
isOnTime = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mat.UsingDate.Value.AddHours(12) < DateTime.Now)
|
||||
{
|
||||
isOnTime = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isOnTime = false;
|
||||
}
|
||||
|
||||
if (this.txtRecycleAmount.Text != "")
|
||||
{
|
||||
newRecycleMat.RecycleAmount = Convert.ToDecimal(this.txtRecycleAmount.Text);
|
||||
}
|
||||
if (this.txtRecycleTopAmount.Text != "")
|
||||
{
|
||||
newRecycleMat.ReturnMatTop = Convert.ToInt32(this.txtRecycleTopAmount.Text);
|
||||
}
|
||||
newRecycleMat.RecycleMan = drpWelder.SelectedValue;
|
||||
newRecycleMat.StockMan = this.drpStoreMan.SelectedValue;
|
||||
newRecycleMat.RecycleDate = Convert.ToDateTime(this.txtRecycleDate.Text);
|
||||
newRecycleMat.Warrantybook = mat.Warrantybook;
|
||||
newRecycleMat.Number = mat.Number;
|
||||
newRecycleMat.UsePosition = mat.UsePosition;
|
||||
newRecycleMat.UsingMatId = usingMatId;
|
||||
newRecycleMat.IsStoreManConfirm = true;
|
||||
newRecycleMat.IsWelderConfirm = true;
|
||||
|
||||
if (newRecycleMat.RecycleAmount > mat.Amount)
|
||||
{
|
||||
ShowNotify("退回数量不能大于领用数量!");
|
||||
return;
|
||||
}
|
||||
if (recycleMat == null)
|
||||
{
|
||||
newRecycleMat.RecycleMatId = SQLHelper.GetNewID(typeof(Model.Weld_RecycleMat));
|
||||
BLL.RecycleMatService.AddRecycleMat(newRecycleMat);
|
||||
|
||||
// 不需要确认,直接退回库存
|
||||
if (!string.IsNullOrEmpty(mat.StockInId))
|
||||
{
|
||||
if (this.txtRecycleAmount.Text != "" && this.txtRecycleAmount.Text != "0")
|
||||
{
|
||||
decimal recycleAmount = Convert.ToDecimal(this.txtRecycleAmount.Text);
|
||||
BLL.StockInService.UpdateStockInAmount(mat.StockInId, recycleAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (recycleMat.IsStoreManConfirm == true || recycleMat.IsWelderConfirm == true)
|
||||
//{
|
||||
// ShowNotify("保管员或焊工已确认,不能修改!");
|
||||
// return;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
newRecycleMat.RecycleMatId = recycleMat.RecycleMatId;
|
||||
BLL.RecycleMatService.UpdateRecycleMat(newRecycleMat);
|
||||
if (!string.IsNullOrEmpty(mat.StockInId))
|
||||
{
|
||||
if (this.txtRecycleAmount.Text != "" && this.txtRecycleAmount.Text != "0")
|
||||
{
|
||||
decimal oldRecycleAmount = recycleMat.RecycleAmount != null ? recycleMat.RecycleAmount.Value : 0;
|
||||
decimal newRecycleAmount = Convert.ToDecimal(this.txtRecycleAmount.Text);
|
||||
BLL.StockInService.UpdateStockInAmount(mat.StockInId, oldRecycleAmount, newRecycleAmount);
|
||||
}
|
||||
}
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
BLL.UsingMatService.UsingMatIsOnTime(usingMatId, isOnTime); //超时
|
||||
|
||||
// 闭环
|
||||
BLL.UsingMatService.UsingMatIsColse(usingMatId, true);
|
||||
ShowNotify("焊材已退回仓库!");
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user