| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using CoreFS.CA06;
- using Pur.Entity;
- using System.Collections;
- using Core.Mes.Client.Comm.Tool;
- using Pur.Entity.configureEntity;
- using Core.Mes.Client.Comm.Control;
- using com.hnshituo.pur.vo;
- using Pur.Entity.ck;
- using Infragistics.Win;
- using Pur.require_plan;
- namespace Pur.ck
- {
- public partial class frmCheckItem : FrmPmsBase
- {
- public frmCheckItem()
- {
- InitializeComponent();
- }
- //菜单按钮事件
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- GetCkInBill();
- break;
- case "RecReceiveAll"://全部接收
- RecReceiveAll();
- break;
- case "RecReceivePortion"://部分接收
- RecReceivePortion();
- break;
- case "RecReceiveBack"://让步接收
- RecReceiveBack();
- break;
- case "RecReturn"://拒收
- RecReturn();
- break;
- }
- }
- /// <summary>
- /// 全部接收
- /// </summary>
- private void RecReceiveAll()
- { checkRec("1"); }
- /// <summary>
- /// 部分接收
- /// </summary>
- private void RecReceivePortion()
- { checkRec("2"); }
- /// <summary>
- /// 让步接收
- /// </summary>
- private void RecReceiveBack()
- { checkRec("3"); }
- /// <summary>
- /// 拒收
- /// </summary>
- private void RecReturn()
- { checkRec("4"); }
- /// <summary>
- /// 查询
- /// </summary>
- private void GetCkInBill()
- {
- PurCkRecBillEntity pcibEntity = new PurCkRecBillEntity();
- pcibEntity.Status = "2";//只查询已初检的收货单
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkRecBillService", "GetCkRecBill", new object[] { pcibEntity });
- //按创建时间降序
- if (dt.Rows.Count != 0)
- {
- dt.DefaultView.Sort = "CREATETIME DESC";
- dt = dt.DefaultView.ToTable();
- }
- GridHelper.CopyDataToDatatable(dt, dataTable1, true);
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void GetPUR_CK_STORAGE()
- {
- CkStorage CkSto = new CkStorage();
- CkSto.OrderId = txt_ORDER_ID.Text;
- CkSto.RefeId = txt_RefeId.Text;
- CkSto.RefType = "3";
- if (!string.IsNullOrEmpty(txt_createTimeS.Text) && !string.IsNullOrEmpty(txt_createTimeE.Text))
- {
- CkSto.CreateTime = Convert.ToDateTime(txt_createTimeS.Text);
- CkSto.UpdateTime = Convert.ToDateTime(txt_createTimeE.Text).AddDays(1);
- }
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStorageService", "find_Storage", new object[] { CkSto });
- GridHelper.CopyDataToDatatable(dt, dataTable7, true);
- }
- /// <summary>
- /// 获取质检头信息
- /// </summary>
- private void getCkLimsM()
- {
- PurCkLimsMEntity CkLimsMEntity = new PurCkLimsMEntity();
- CkLimsMEntity.InspectCode = txt_INSPECT_CODE_Query.Text;
- CkLimsMEntity.BatchNo = txt_BATCH_NO_Query.Text;
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkLimsMService", "getCkLimsM", new object[] { CkLimsMEntity});
- GridHelper.CopyDataToDatatable(dt, dataTable8, true);
- }
- /// <summary>
- /// 获取质检行信息
- /// </summary>
- private void getCkLimsC(string strInspectCode)
- {
- PurCkLimsCEntity CkLimsCEntity = new PurCkLimsCEntity();
- CkLimsCEntity.InspectCode = strInspectCode;
- CkLimsCEntity.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkLimsCService", "find", new object[] { CkLimsCEntity, 0, 0 });
- GridHelper.CopyDataToDatatable(dt, dataTable3, true);
- }
- /// <summary>
- /// 开始初检
- /// </summary>
- private void checkRec(string strRecieveMode)
- {
- //ultraGrid1.UpdateData();
- ArrayList alCkRecBillEntity = new ArrayList();
- // for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- //{
- PurCkRecBillEntity CkRecBillEntity = new PurCkRecBillEntity();
- //CkRecBillEntity.RecId = ultraGrid1.Rows[i].Cells["RecId"].Value.ToString();
- CkRecBillEntity.RecCls = strRecieveMode;//接收方式
- CkRecBillEntity.Status = "3";
- alCkRecBillEntity.Add(CkRecBillEntity);
- // }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkRecBillService", "checkRec", new object[] { alCkRecBillEntity });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("操作失败 " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("操作成功");
- }
- /// <summary>
- /// 生成检验委托单
- /// </summary>
- private void AddCheckDelegateId()
- {
- if (ultraGrid6.ActiveRow == null)
- { return; }
- try
- {
- DateTime? dtnull = null;
- PurCkLimsMEntity CkLimsMEntity = new PurCkLimsMEntity();
- String strInspectCode = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getOddNumber_yymm", new object[] { "PUR_CK_LIMS_M", "INSPECT_CODE", "ZJDH-", "3" });
- String strBatchNo = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getOddNumber_yymm", new object[] { "PUR_CK_LIMS_M", "INSPECT_SNQ", "JYP-", "3" });
- CkLimsMEntity.InspectCode = strInspectCode;//质检单号
- CkLimsMEntity.RecId = ultraGrid6.ActiveRow.Cells["INSTOCKNO"].Value.ToString();//收货单号
- CkLimsMEntity.BatchNo = ultraGrid6.ActiveRow.Cells["BATCHNO"].Value.ToString();//入场批号
- CkLimsMEntity.InspectSnq = strBatchNo;//检验批号
- CkLimsMEntity.InspectDate = txt_INSPECT_DATE.Value == null ? dtnull : (DateTime)txt_INSPECT_DATE.Value;//检验日期(判定日期)
- CkLimsMEntity.Remark = txt_REMARK.Text;//备注
- CkLimsMEntity.Paihao = txt_PAIHAO.Text;//牌号
- CkLimsMEntity.InspectUserName = txt_INSPECT_USER_NAME.Text;//质检人姓名
- CkLimsMEntity.OrderLineSqe = txt_ORDER_LINE_SQE.Text;//合同行号
- CkLimsMEntity.Qty = txt_QTY.Text.Trim() == "" ? 0 : double.Parse(txt_QTY.Text);//验收量
- CkLimsMEntity.InspectStandCode = txt_INSPECT_STAND_CODE.Text;//质检标准编号
- CkLimsMEntity.ItemName = txt_ITEM_NAME.Text;//物料名称
- CkLimsMEntity.ItemCode = ultraGrid6.ActiveRow.Cells["ITEMCODE"].Value.ToString();//物料编码
- CkLimsMEntity.ItemStandardsCode = txt_ITEM_STANDARDS_CODE.Text;//标准编号
- CkLimsMEntity.CheckItems = txt_CHECK_ITEMS.Text;// 检测项目
- CkLimsMEntity.Validflag = "1";
- CkLimsMEntity.CreateName = UserInfo.GetUserName();
- CkLimsMEntity.CreateUserid = UserInfo.GetUserID();
- CkLimsMEntity.CreateTime = System.DateTime.Now;
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkLimsMService", "doInsert", new object[] { CkLimsMEntity });//添加操作
- CkStorage CkSto = new CkStorage();
- CkSto.InvId = ultraGrid6.ActiveRow.Cells["InvId"].Value.ToString();
- CkSto.BatchNo = strBatchNo;
- CoreResult crt1 = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkStorageService", "doUpdate", new object[] { CkSto });//修改库存检验批号
- if (crt.Resultcode != 0 || crt1.Resultcode != 0)
- {
- MessageUtil.ShowTips("生成失败: " + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("成功生成检验委托单:" + strBatchNo);
- getCkLimsM();
- comm.doActiveSelRow(ultraGrid1, "INSPECTCODE", strInspectCode);
- GetPUR_CK_STORAGE();
- comm.doActiveSelRow(ultraGrid6, "INSTOCKNO", CkLimsMEntity.RecId);
- }
- catch (Exception e){
- MessageUtil.ShowTips("生成失败: " + e.Message);
- return;
- }
- }
- /// <summary>
- /// 增加质检行信息
- /// </summary>
- private void AddCkLims()
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择质检委托单");
- return;
- }
- ultraGrid5.UpdateData();
- //更新检验单检验结果
- PurCkLimsMEntity CkLimsMEntity = new PurCkLimsMEntity();
- CkLimsMEntity.InspectCode = ultraGrid1.ActiveRow.Cells["InspectCode"].Value.ToString();
- CkLimsMEntity.Result = cmbCheck.Value.ToString();
- CkLimsMEntity.Remark = txt_REMARK1.Text;
- if (txt_ITEM_UOM_CONEFFICIENT.Text != "")
- {
- CkLimsMEntity.ItemUomConefficient = double.Parse(txt_ITEM_UOM_CONEFFICIENT.Text);
- }
- //插入检验详细信息
- ArrayList alCkLims = new ArrayList();
- for (int i = 0; i < ultraGrid5.Rows.Count; i++)
- {
- PurCkLimsCEntity CkLimsCEntity = new PurCkLimsCEntity();
- CkLimsCEntity.InspectCode = ultraGrid1.ActiveRow.Cells["InspectCode"].Value.ToString();
- CkLimsCEntity.ChemCode = ultraGrid5.Rows[i].Cells["ChemCode"].Value.ToString();//质检项
- CkLimsCEntity.ChemValue1 = ultraGrid5.Rows[i].Cells["ChemValue1"].Value.ToString();//质检结果
- CkLimsCEntity.ChemValue2 = ultraGrid5.Rows[i].Cells["ChemValue2"].Value.ToString();//单位
- CkLimsCEntity.SeqNo = i;
- CkLimsCEntity.Validflag = "1";
- CkLimsCEntity.CreateName = UserInfo.GetUserName();
- CkLimsCEntity.CreateUserid = UserInfo.GetUserID();
- CkLimsCEntity.CreateTime = System.DateTime.Now;
- alCkLims.Add(CkLimsCEntity);
- }
- //更新库存收货单的状态
- CkStorage ckEntity =new CkStorage();
- ckEntity.InStockNo = ultraGrid1.ActiveRow.Cells["RECID"].Value.ToString();
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkLimsCService", "AddCkLims", new object[] { alCkLims, CkLimsMEntity, ckEntity });//添加操作
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("判定结果失败");
- return;
- }
- MessageUtil.ShowTips("已生成判定结果:"+cmbCheck.Text);
- getCkLimsM();
- comm.doActiveSelRow(ultraGrid1, "INSPECTCODE", CkLimsMEntity.InspectCode);
- string strINSTOCKNO = ultraGrid6.ActiveRow.Cells["INSTOCKNO"].Value.ToString();
- GetPUR_CK_STORAGE();
- comm.doActiveSelRow(ultraGrid6, "INSTOCKNO", strINSTOCKNO);
- }
- /// <summary>
- /// 获取检验委托信息
- /// </summary>
- private void getCheckDelegate()
- {
- txt_ORDER_LINE_SQE.Text = ultraGrid6.ActiveRow.Cells["ORDERLINESQE"].Value.ToString();//合同行号
- txt_SUPP_NAME.Text = ultraGrid6.ActiveRow.Cells["SUPPNAME"].Value.ToString();//供应商名称
- txt_CHK_BATCH_NO.Text = ultraGrid6.ActiveRow.Cells["CHKBATCHNO"].Value.ToString();//检验批
- txt_ITEM_NAME.Text = ultraGrid6.ActiveRow.Cells["ITEMNAME"].Value.ToString();//物料名称
- txt_ITEM_STANDARDS_CODE.Text = ultraGrid6.ActiveRow.Cells["ITEMSTANDARDSCODE"].Value.ToString();//标准编号
- txt_RECQTY.Text = ultraGrid6.ActiveRow.Cells["INVQTY"].Value.ToString();//收货数量、供货数量
- }
- /// <summary>
- /// 激活收货单号,查询 相应的质检信息
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- getCkLimsC(ultraGrid1.ActiveRow.Cells["INSPECTCODE"].Value.ToString());
- if (ultraGrid1.ActiveRow.Cells["RESULT"].Value.ToString() == "合格")
- {
- cmbCheck.Value = 1;
- }
- else
- {
- cmbCheck.Value = 0;
- }
- txt_ITEM_UOM_CONEFFICIENT.Text = ultraGrid1.ActiveRow.Cells["ITEMUOMCONEFFICIENT"].Value.ToString();
- }
- /// <summary>
- /// 质检信息激活事件,查询质检明细单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
- {
- PurCkLimsCEntity CkLimsCEntity = new PurCkLimsCEntity();
- //CkLimsCEntity.InspectCode = ultraGrid2.ActiveRow.Cells["INSPECTCODE"].Value.ToString();
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkLimsCService", "find", new object[] { CkLimsCEntity, 0, 0 });
- GridHelper.CopyDataToDatatable(dt, dataTable3, true);
- }
- /// <summary>
- /// 生成检验委托单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnChkDelegate_Click(object sender, EventArgs e)
- {
- AddCheckDelegateId();
- }
- /// <summary>
- /// 查询库存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnQuery_Click(object sender, EventArgs e)
- {
- GetPUR_CK_STORAGE();
- }
- /// <summary>
- /// 查询质检头信息
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnQueryCLM_Click(object sender, EventArgs e)
- {
- getCkLimsM();
- }
- /// <summary>
- /// 确定质检判定结果信息
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnConform_Click(object sender, EventArgs e)
- {
- AddCkLims();
- }
- private void ultraGrid6_AfterRowActivate(object sender, EventArgs e)
- {
- getCheckDelegate();
- }
- /// <summary>
- /// 界面加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void frmCheckItem_Load(object sender, EventArgs e)
- {
- cmbCheck.SelectedIndex = 0;
- txt_createTimeS.Value = DateTime.Now.AddMonths(-1);
- }
- }
- }
|