150 lines
		
	
	
		
			6.5 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			150 lines
		
	
	
		
			6.5 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using System.Web;
							 | 
						|||
| 
								 | 
							
								using System.Web.UI;
							 | 
						|||
| 
								 | 
							
								using System.Web.UI.WebControls;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace FineUIPro.Web.HJGL.MaterialManage
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    public partial class CodeConfirm : System.Web.UI.Page
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        protected void Page_Load(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (!IsPostBack)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                string flag = Request.Params["flag"]; //1-焊工,2-保管员
							 | 
						|||
| 
								 | 
							
								                if (flag == "1")
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    lbcode.Text = "请输入焊工号:";
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                else
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    lbcode.Text = "请输入保管员账号:";
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        protected void btnConfirm_Click(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            string keyId = Request.Params["keyId"];
							 | 
						|||
| 
								 | 
							
								            string flag = Request.Params["flag"]; //1-焊工,2-保管员
							 | 
						|||
| 
								 | 
							
								            string grid = Request.Params["grid"]; //1-领料,2-退料,3-退焊条头,4-保管员结束确认
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            if (grid == "1")  // 领料
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                var usingMat = BLL.UsingMatService.GetUsingMatById(keyId);
							 | 
						|||
| 
								 | 
							
								                if (usingMat != null)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    if (flag == "1")
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        if (WelderIsSuccess(usingMat.UsingMan))
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            BLL.UsingMatService.WelderConfirm(keyId, true);
							 | 
						|||
| 
								 | 
							
								                            string msg = "焊工:" + txtCode.Text + "已确认领料";
							 | 
						|||
| 
								 | 
							
								                            ScriptManager.RegisterStartupScript(this, typeof(string), "_alert", "alert('" + msg + "');", true);
							 | 
						|||
| 
								 | 
							
								                            //Alert.ShowInTop("焊工:"+txtCode+"已确认领料",MessageBoxIcon.Success);
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                        else
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            ScriptManager.RegisterStartupScript(this, typeof(string), "_alert", "alert('焊工号输入错误!');", true);
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    else
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        if (StoreManIsSuccess(usingMat.StoreMan))
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            BLL.UsingMatService.StoreManConfirm(keyId, true);
							 | 
						|||
| 
								 | 
							
								                            string msg = "保管员:" + txtCode.Text + "已确认";
							 | 
						|||
| 
								 | 
							
								                            ScriptManager.RegisterStartupScript(this, typeof(string), "_alert", "alert('" + msg + "');", true);
							 | 
						|||
| 
								 | 
							
								                            //Alert.ShowInTop("保管员:" + txtCode + "已确认", MessageBoxIcon.Success);
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                        else
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            ScriptManager.RegisterStartupScript(this, typeof(string), "_alert", "alert('保管员账号输入错误!');", true);
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                else
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    ScriptManager.RegisterStartupScript(this, typeof(string), "_alert", "alert('请选中要确认的领料记录!');", true);
							 | 
						|||
| 
								 | 
							
								                    //Alert.ShowInTop("请选中要确认的领料记录!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                    return;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            if (grid == "2")  // 退料
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                var recycleMat = BLL.RecycleMatService.GetRecycleMatById(keyId);
							 | 
						|||
| 
								 | 
							
								                if (recycleMat != null)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    if (flag == "1")
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        if (WelderIsSuccess(recycleMat.RecycleMan))
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            BLL.RecycleMatService.WelderConfirm(keyId, true);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                            var recycle = BLL.RecycleMatService.GetRecycleMatById(keyId);
							 | 
						|||
| 
								 | 
							
								                            var mat = BLL.UsingMatService.GetUsingMatById(recycle.UsingMatId);
							 | 
						|||
| 
								 | 
							
								                            if (!string.IsNullOrEmpty(mat.StockInId))
							 | 
						|||
| 
								 | 
							
								                            {
							 | 
						|||
| 
								 | 
							
								                                decimal recycleAmount = recycle.RecycleAmount.HasValue ? recycle.RecycleAmount.Value : 0;
							 | 
						|||
| 
								 | 
							
								                                BLL.StockInService.UpdateStockInAmount(mat.StockInId, recycleAmount);
							 | 
						|||
| 
								 | 
							
								                            }
							 | 
						|||
| 
								 | 
							
								                            string msg = "焊工:" + txtCode.Text + "已确认退料";
							 | 
						|||
| 
								 | 
							
								                            ScriptManager.RegisterStartupScript(this, typeof(string), "_alert", "alert('" + msg + "');", true);
							 | 
						|||
| 
								 | 
							
								                            //Alert.ShowInTop("焊工:" + txtCode + "已确认退料", MessageBoxIcon.Success);
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                        else
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            ScriptManager.RegisterStartupScript(this, typeof(string), "_alert", "alert('焊工号输入错误!');", true);
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    else
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        if (StoreManIsSuccess(recycleMat.StockMan))
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            BLL.RecycleMatService.StoreManConfirm(keyId, true);
							 | 
						|||
| 
								 | 
							
								                            string msg = "保管员:" + txtCode.Text + "已确认";
							 | 
						|||
| 
								 | 
							
								                            ScriptManager.RegisterStartupScript(this, typeof(string), "_alert", "alert('" + msg + "');", true);
							 | 
						|||
| 
								 | 
							
								                            //Alert.ShowInTop("保管员:" + txtCode + "已确认", MessageBoxIcon.Success);
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                        else
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            ScriptManager.RegisterStartupScript(this, typeof(string), "_alert", "alert('保管员账号输入错误!');", true);
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                else
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    ScriptManager.RegisterStartupScript(this, typeof(string), "_alert", "alert('请选中要确认的退料记录!');", true);
							 | 
						|||
| 
								 | 
							
								                    //Alert.ShowInTop("请选中要确认的退料记录!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                    return;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        private bool WelderIsSuccess(string welderId)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            bool isSuccess = false;
							 | 
						|||
| 
								 | 
							
								            var welder = BLL.WelderService.GetWelderById(welderId);
							 | 
						|||
| 
								 | 
							
								            if (welder != null && welder.WED_Code == this.txtCode.Text.Trim())
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                isSuccess = true;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            return isSuccess;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        private bool StoreManIsSuccess(string storemanId)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            bool isSuccess = false;
							 | 
						|||
| 
								 | 
							
								            var user = BLL.UserService.GetUserByUserId(storemanId);
							 | 
						|||
| 
								 | 
							
								            if (user != null && user.Account == txtCode.Text.Trim())
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                isSuccess = true;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            return isSuccess;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |