xinjiang/SGGL/FineUIPro.Web/HJGL/MaterialManage/UsingMatCheck.aspx.cs

395 lines
18 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.IO;
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 UsingMatCheck : PageBase
{
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string keyId = Request.Params["keyId"];
string grid = Request.Params["grid"];
if (grid == "1") // 领料
{
var mat = BLL.UsingMatService.GetUsingMatById(keyId);
if (mat != null)
{
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;
}
var w = BLL.WelderService.GetWelderById(mat.UsingMan);
var storeMan = BLL.UserService.GetUserByUserId(mat.StoreMan);
string unit = "";
unit = "根";
txtAmount.Text = (mat.Amount.Value + mat.TwoAmount.Value).ToString("0.##") + "根";
//if (type.WeldTypeName.Contains("焊条"))
//{
// unit = "根";
// txtAmount.Text = mat.Amount.Value.ToString("0.##") + "根";
//}
//else
//{
// unit = "公斤";
// txtAmount.Text = mat.Amount.Value.ToString("0.##") + "Kg";
//}
string[] weldNames = weld.ConsumablesCode.Split('/');
string weldName = string.Empty;
if (weldNames.Length > 1)
{
weldName = weldNames[1];
}
else
{
weldName = weldNames[0];
}
string strSpeak = w.WED_Name + "领牌号为" + weldName + "的" + type + mat.Amount.Value.ToString("0.##") + unit + "请确认";
ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>DoSpeak('" + strSpeak + "');</script>");
txtStoreMan.Text = storeMan.UserName;
txtName.Text = w.WED_Name;
txtWeldName.Text = weld.ConsumablesCode;
txtWeldSpec.Text = weld.SteelFormat;
txtDatetime.Text = mat.UsingDate.Value.ToShortDateString();
txtWarrantybook.Text = mat.Warrantybook;
txtNumber.Text = mat.Number;
}
}
if (grid == "2") // 退料
{
var recycle = BLL.RecycleMatService.GetRecycleMatById(keyId);
var mat = BLL.UsingMatService.GetUsingMatById(recycle.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;
}
var w = BLL.WelderService.GetWelderById(mat.UsingMan);
var storeMan = BLL.UserService.GetUserByUserId(mat.StoreMan);
//if (recycle.IsStoreManConfirm == true)
//{
// btnStoreMam.Text = "保管员已确认";
//}
if (recycle.IsWelderConfirm == true)
{
btnWelder.Text = "焊工已确认";
}
string unit = "";
unit = "根";
txtAmount.Text = recycle.RecycleAmount.Value.ToString("0.##") + "根";
if (type.Contains("焊条"))
{
this.lbRetrunTop.Visible = true;
this.txtRetrunTop.Visible = true;
}
else
{
this.lbRetrunTop.Visible = false;
this.txtRetrunTop.Visible = false;
//unit = "公斤";
//txtAmount.Text = recycle.RecycleAmount.Value.ToString("0.##") + "Kg";
}
string[] weldNames = weld.ConsumablesCode.Split('/');
string weldName = string.Empty;
if (weldNames.Length > 1)
{
weldName = weldNames[1];
}
else
{
weldName = weldNames[0];
}
string strSpeak = w.WED_Name + "退回牌号为" + weldName + "的" + type + recycle.RecycleAmount.Value.ToString("0.##") + unit;
if (type.Contains("焊条"))
{
strSpeak = strSpeak + "退回焊条头" + (recycle.ReturnMatTop != null ? recycle.ReturnMatTop.Value.ToString() : "0") + unit;
}
strSpeak = strSpeak + "请确认";
ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>DoSpeak('" + strSpeak + "');</script>");
lbAmount.Text = "退回数量:";
lbDatetime.Text = "退回时间:";
txtStoreMan.Text = storeMan.UserName;
txtName.Text = w.WED_Name;
txtWeldName.Text = weld.ConsumablesCode;
txtWeldSpec.Text = weld.SteelFormat;
txtRetrunTop.Text = recycle.ReturnMatTop != null ? recycle.ReturnMatTop.Value.ToString() : "0";
txtDatetime.Text = recycle.RecycleDate.Value.ToShortDateString();
txtWarrantybook.Text = mat.Warrantybook;
txtNumber.Text = mat.Number;
}
if (grid == "3") // 退回焊条头
{
//var recycleTop = BLL.RecycleMatTopService.GetRecycleMatTopByUsingMatId(keyId);
//var w = BLL.HJGL_PersonManageService.GetWelderByWenId(recycleTop.RecycleMan);
//var storeMan = BLL.StoremanInfoService.GetStoremanById(recycleTop.StockMan);
//lbAmount.Text = "退回焊条头:";
//string strSpeak = w.WED_Name + "退回焊条头" + recycleTop.RecycleAmount.Value.ToString("0.##") + "根请确认";
//ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>DoSpeak('" + strSpeak + "');</script>");
//lbDatetime.Text = "退回时间:";
//txtStoreMan.Text = storeMan.StoreName;
//txtName.Text = w.WED_Name;
//txtWeldName.Text = weld.WeldName;
//txtWeldSpec.Text = weld.WeldSpec;
//txtAmount.Text = recycleTop.RecycleAmount.Value.ToString("0.##") + "根";
//txtDatetime.Text = recycleTop.RecycleDate.Value.ToShortDateString();
//txtWarrantybook.Text = mat.Warrantybook;
//txtNumber.Text = mat.Number;
}
}
}
#endregion
#region
/// <summary>
/// 焊工确认
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnWelder_Click(object sender, EventArgs e)
{
string keyId = Request.Params["keyId"];
string grid = Request.Params["grid"];
string isFinger = Request.Params["isFinger"]; // 是否需指纹确认1-是0-否
string fingerOrFace = Request.Params["FingerOrFace"];//0-指纹1-人脸识别
if (grid == "1")
{
var usingMat = BLL.UsingMatService.GetUsingMatById(keyId);
if (usingMat.IsWelderConfirm != true)
{
if (fingerOrFace == "0")
{
if (isFinger == "1")
{
ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>FingerConfirm('" + keyId + "','1','" + grid + "');</script>");
}
}
else if (fingerOrFace == "1")
{
ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>FaceConfirm('" + keyId + "','1','" + grid + "');</script>");
}
else
{
//ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>CodeConfirm('" + keyId + "','1','" + grid + "');</script>");
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("CodeConfirm.aspx?keyId={0}&flag={1}&grid={2}", keyId, "1", grid, "", "焊工确认 - ")));
}
}
else
{
ScriptManager.RegisterStartupScript(this, typeof(string), "_alert", "alert('焊工已确认!')", true);
}
}
else
{
var recycle = BLL.RecycleMatService.GetRecycleMatById(keyId);
if (recycle.IsWelderConfirm != true)
{
if (isFinger == "1")
{
if (fingerOrFace == "0")
{
ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>FingerConfirm('" + keyId + "','1','" + grid + "');</script>");
}
else if (fingerOrFace == "1")
{
ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>FaceConfirm('" + keyId + "','1','" + grid + "');</script>");
}
else
{
ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>CodeConfirm('" + keyId + "','1','" + grid + "');</script>");
}
}
else
{
BLL.RecycleMatService.WelderConfirm(recycle.RecycleMatId, true);
ScriptManager.RegisterStartupScript(this, typeof(string), "_alert", "alert('焊工确认成功!')", true);
}
}
else
{
ScriptManager.RegisterStartupScript(this, typeof(string), "_alert", "alert('焊工已确认!')", true);
}
}
}
#endregion
#region
protected void btnPrinter_Click(object sender, EventArgs e)
{
//string reportId = BLL.Const.CLGL_MaterialLabelReportId;
//ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>ReportPrint('" + reportId + "','" + Request.Params["keyId"] + "','');</script>");
string keyId = Request.Params["keyId"];
if (!string.IsNullOrEmpty(keyId))
{
string weldSpec = string.Empty;//规格
string weldName = string.Empty;//材质牌号
string welderName = string.Empty;//焊工姓名
string number = string.Empty;//流水号
string storeName = string.Empty;//保管员
string usingDate = string.Empty;//时间
var material = BLL.UsingMatService.GetUsingMatById(keyId);
if (material != null)
{
if (!string.IsNullOrEmpty(material.WeldId))
{
var weldInfo = BLL.Base_ConsumablesService.GetConsumablesByConsumablesId(material.WeldId);
if (weldInfo != null)
{
weldSpec = weldInfo.SteelFormat;
weldName = weldInfo.ConsumablesCode;
}
}
if (!string.IsNullOrEmpty(material.UsingMan))
{
var welder = BLL.WelderService.GetWelderById(material.UsingMan);
if (welder != null)
{
welderName = welder.WED_Name + "(" + welder.WED_Code + ")";
}
}
number = material.Number;
if (!string.IsNullOrEmpty(material.StoreMan))
{
var store = BLL.UserService.GetUserByUserId(material.StoreMan);
if (store != null)
{
storeName = store.UserName;
}
}
usingDate = material.UsingDate.Value.ToShortDateString() + " " + material.UsingDate.Value.ToShortTimeString();
}
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
keyValuePairs.Add("WeldSpec", weldSpec);
keyValuePairs.Add("WeldName", weldName);
keyValuePairs.Add("WelderName", welderName);
keyValuePairs.Add("Number", number);
keyValuePairs.Add("StoreName", storeName);
keyValuePairs.Add("UsingDate", usingDate);
BLL.Common.FastReportService.ResetData();
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
string initTemplatePath = "";
string rootPath = Server.MapPath("~/");
initTemplatePath = "File\\Fastreport\\材料标签.frx";
if (File.Exists(rootPath + initTemplatePath))
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../TrustManage/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
}
}
}
#endregion
protected void btnClose_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#region
/// <summary>
/// 保管员确认
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnStoreMam_Click(object sender, EventArgs e)
{
string keyId = Request.Params["keyId"];
string grid = Request.Params["grid"];
string isFinger = Request.Params["isFinger"]; // 是否需指纹确认1-是0-否
string fingerOrFace = Request.Params["FingerOrFace"];//0-指纹1-人脸识别
if (grid == "1")
{
if (fingerOrFace == "0")//指纹
{
if (isFinger == "1")
{
ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>FingerConfirm('" + keyId + "','2','" + grid + "');</script>");
}
}
else if (fingerOrFace == "1")
{
ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>FaceConfirm('" + keyId + "','2','" + grid + "');</script>");
}
else
{
ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>CodeConfirm('" + keyId + "','2','" + grid + "');</script>");
}
}
else if (grid == "2")
{
var recycle = BLL.RecycleMatService.GetRecycleMatById(keyId);
var mat = BLL.UsingMatService.GetUsingMatById(recycle.UsingMatId);
if (recycle.IsStoreManConfirm != true)
{
if (fingerOrFace == "0")
{
if (isFinger == "1")
{
ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>FingerConfirm('" + keyId + "','2','" + grid + "');</script>");
}
}
else if (fingerOrFace == "1")
{
ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>FaceConfirm('" + keyId + "','2','" + grid + "');</script>");
}
else if (fingerOrFace == "2")
{
ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script type='text/javascript'>CodeConfirm('" + keyId + "','2','" + grid + "');</script>");
}
else
{
if (!string.IsNullOrEmpty(mat.StockInId))
{
decimal recycleAmount = recycle.RecycleAmount.HasValue ? recycle.RecycleAmount.Value : 0;
BLL.StockInService.UpdateStockInAmount(mat.StockInId, recycleAmount);
}
ScriptManager.RegisterStartupScript(this, typeof(string), "_alert", "alert('保管员确认成功!')", true);
}
}
else
{
ScriptManager.RegisterStartupScript(this, typeof(string), "_alert", "alert('保管员已确认!')", true);
}
}
}
#endregion
}
}