200 lines
8.2 KiB
C#
200 lines
8.2 KiB
C#
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.HJGL.MaterialManage
|
|
{
|
|
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.Base_ConsumablesService.GetConsumablesByConsumablesId(mat.WeldId);
|
|
var type = string.Empty;
|
|
var dropValue = BLL.DropListService.HJGL_ConsumablesTypeList().FirstOrDefault(x => x.Value == weld.ConsumablesType);
|
|
if (dropValue != null)
|
|
{
|
|
type = dropValue.Text;
|
|
}
|
|
|
|
// 焊工
|
|
this.drpWelder.Items.Clear();
|
|
drpWelder.DataTextField = "Text";
|
|
drpWelder.DataValueField = "Value";
|
|
drpWelder.DataSource = BLL.WelderService.GetWelderByUsingPlan(mat.UsingPlanId);
|
|
drpWelder.DataBind();
|
|
if (!string.IsNullOrEmpty(welderId))
|
|
{
|
|
this.drpWelder.SelectedValue = welderId;
|
|
this.drpWelder.Readonly = true;
|
|
}
|
|
|
|
// 保管员
|
|
this.drpStoreMan.Items.Clear();
|
|
drpStoreMan.DataTextField = "UserName";
|
|
drpStoreMan.DataValueField = "UserId";
|
|
drpStoreMan.DataSource = BLL.UserService.GetProjectUserListByProjectId(this.CurrUser.LoginProjectId);
|
|
drpStoreMan.DataBind();
|
|
|
|
|
|
this.txtWeldName.Text = weld.ConsumablesCode;
|
|
txtWeldSpec.Text = weld.SteelFormat;
|
|
txtWarrantybook.Text = mat.Warrantybook;
|
|
txtNumber.Text = mat.Number;
|
|
this.txtRecycleAmount.Text = "0";
|
|
//drpWelder.SelectedValue = mat.UsingMan;
|
|
txtRecycleDate.Text = DateTime.Now.ToString();
|
|
var curUser = BLL.UserService.GetUserByUserId(this.CurrUser.UserId);
|
|
if (curUser != null)
|
|
{
|
|
drpStoreMan.SelectedValue = curUser.UserId;
|
|
}
|
|
|
|
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 == "焊条")
|
|
{
|
|
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 isOnTime = Request.Params["isOnTime"]; // 是否准时 0-否
|
|
|
|
var mat = BLL.UsingMatService.GetUsingMatById(usingMatId);
|
|
var recycleMat = BLL.RecycleMatService.GetRecycleMatByUsingMatId(usingMatId);
|
|
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 (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);
|
|
}
|
|
}
|
|
|
|
//}
|
|
}
|
|
|
|
if (isOnTime == "0") // 违规
|
|
{
|
|
BLL.UsingMatService.UsingMatIsOnTime(usingMatId, true);
|
|
}
|
|
|
|
// 闭环
|
|
BLL.UsingMatService.UsingMatIsColse(usingMatId, true);
|
|
ShowNotify("焊材已退回仓库!");
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
}
|
|
} |