예제 #1
0
        private void DoRepair(bool closeFlag)
        {
            wsINP.IwsINPClient client = new wsINP.IwsINPClient();
            try{
                baseForm.SetCursor();
                baseForm.ValidateData(this);
                if (this.numRepairQty.Value > Convert.ToInt16(this.txtPairQty.Text))
                {
                    throw new Exception(UtilCulture.GetString("Msg.R01014", UtilCulture.GetString("Label.R02026"), UtilCulture.GetString("Label.R02036")));
                }

                tinprepairhis his = new tinprepairhis();
                his.repsysid = Function.GetGUID();
                his.workgroup = ((ValueInfo)this.cmbWorkGroup.SelectedItem).ValueField;
                his.step = ((ValueInfo)this.cmbStep.SelectedItem).ValueField;
                his.reptype = MES_RepairType.ToRepair.ToString();
                his.customerid = this.ucmbCustOrderNo.SelectedRow.Cells["customerid"].Value.ToString();
                his.custorderno = this.ucmbCustOrderNo.Value.ToString();
                his.styleno = this.txtStyleNo.Text;
                his.color = this.txtColor.Text;
                his.size = this.txtSize.Text;
                his.checktype = this.ucmbCustOrderNo.SelectedRow.Cells["checktype"].Value.ToString();
                his.isfirst = this.ckIsFirst.Checked ? MES_Misc.Y.ToString() : MES_Misc.N.ToString();
                his.pairqty = this.numRepairQty.Value;
                his.claimtime = Function.GetCurrentTime();
                his.claimuser = Function.GetCurrentUser();

                List<tinprepairfail> lstreasoncode = new List<tinprepairfail>();

                foreach (UltraGridRow row in this.grdDetail.Rows)
                {
                    if (row.Cells["ck"].Value.ToString().Equals("Y"))
                    {
                        if (Convert.ToDecimal(row.Cells["pairqty"].Value)==0)
                        {
                            throw new Exception(UtilCulture.GetString("Msg.R01016", UtilCulture.GetString("Label.R02036")));
                        }
                        tinprepairfail repairfail = new tinprepairfail();
                        repairfail.reasoncode = row.Cells["reasoncode"].Value.ToString();
                        repairfail.remark = row.Cells["remark"].Value.ToString();
                        repairfail.pairqty = Convert.ToDecimal(row.Cells["pairqty"].Value);
                        lstreasoncode.Add(repairfail);
                    }
                }

                if (this.numRepairQty.Value == 0)
                {
                    throw new Exception(UtilCulture.GetString("Msg.R01016", UtilCulture.GetString("Label.R02036")));
                }
                if (lstreasoncode.Count == 0)
                {
                    throw new Exception(UtilCulture.GetString("Msg.R01015"));
                }

                client.DoInsertRepair(baseForm.CurrentContextInfo, his, lstreasoncode.ToArray<tinprepairfail>());
                baseForm.CreateMessageBox(Public_MessageBox.Information, MessageBoxButtons.OK, null, UtilCulture.GetString("Msg.R00002"));
                if (closeFlag)
                {
                    this.Close();
                }
                else
                {
                    Clean();
                }

            }
            catch (Exception ex)
            {
                baseForm.CreateMessageBox(Public_MessageBox.Error, MessageBoxButtons.OK, null, ex.Message);
            }
            finally
            {
                baseForm.ResetCursor();
                baseForm.CloseWCF(client);
            }
        }