Example #1
0
        private void DoSave()
        {
            wsINP.IwsINPClient client = new wsINP.IwsINPClient();
            try
            {
                baseForm.SetCursor();
                baseForm.ValidateData(this);
                if (this.numPairQty.Value == orgqty)
                {
                    throw new Exception(UtilCulture.GetString("Msg.R01025"));
                }
                if (this.numPairQty.Value > orgqty)
                {
                    if (RepairHis.reptype.Equals(MES_RepairType.ToRepair.ToString()))
                    {
                        tinpwip wip = GetSingleWip();
                        if (wip != null)
                        {
                            if ((this.numPairQty.Value - orgqty) > wip.pairqty)
                            {
                                throw new Exception(UtilCulture.GetString("Msg.R01027"));
                            }
                        }
                        else
                        {
                            if ((this.numPairQty.Value - orgqty) > 0)
                            {
                                throw new Exception(UtilCulture.GetString("Msg.R01027"));
                            }
                        }
                    }

                    if (RepairHis.reptype.Equals(MES_RepairType.RepairFail.ToString()) || RepairHis.reptype.Equals(MES_RepairType.RepairSuccess.ToString()))
                    {
                        tinprepairstock stock = GetSingleRepairStock();
                        if (stock != null)
                        {
                            if ((this.numPairQty.Value - orgqty) > stock.curpairqty)
                            {
                                throw new Exception(UtilCulture.GetString("Msg.R01026"));
                            }
                        }
                        else
                        {
                            throw new Exception("No data found");
                        }
                    }
                }
                else
                {
                    if (RepairHis.reptype.Equals(MES_RepairType.ToRepair.ToString()))
                    {
                        tinprepairstock stock = GetSingleRepairStock();
                        if (stock != null)
                        {
                            if ((orgqty-this.numPairQty.Value) > stock.curpairqty)
                            {
                                throw new Exception(UtilCulture.GetString("Msg.R01026"));
                            }
                        }
                        else
                        {
                            throw new Exception("No data found");
                        }
                    }
                    else if (RepairHis.reptype.Equals(MES_RepairType.RepairSuccess.ToString()))
                    {
                        int leftSuccessQty = GetLeftRepairSuccessQty();
                        if ((orgqty - this.numPairQty.Value) > leftSuccessQty)
                        {
                            throw new Exception(UtilCulture.GetString("Msg.R01027"));
                        }

                    }
                }
                client.DoRepaireAdjust(baseForm.CurrentContextInfo, RepairHis.repsysid, ReaseanCode, Convert.ToInt16(this.numPairQty.Value));
                baseForm.CreateMessageBox(Public_MessageBox.Information, MessageBoxButtons.OK, null, UtilCulture.GetString("Msg.R00002"));
                this.Close();
            }
            catch (Exception ex)
            {
                baseForm.CreateMessageBox(Public_MessageBox.Error, MessageBoxButtons.OK, null, ex.Message);
            }
            finally
            {
                baseForm.ResetCursor();
            }
        }