コード例 #1
0
ファイル: frmShipPlan.cs プロジェクト: jimidzj/Inspect
        private void DoShipPlan()
        {
            wsINP.IwsINPClient client = new wsINP.IwsINPClient();
            try
            {
                baseForm.SetCursor();
                baseForm.ValidateData(this);

                if (ShipingSysId == null)
                {
                    ShipingSysId = Function.GetGUID();
                }
                List<string> lstcustorderno = new List<string>();
                List<tinpshippingdtl> lstshippingdtl = new List<tinpshippingdtl>();
                foreach (UltraGridRow row in this.grdDetail.Rows)
                {
                    if (lstcustorderno.Contains(row.Cells["custorderno"].Value.ToString()))
                    {
                        throw new Exception(UtilCulture.GetString("Msg.R01022", row.Cells["custorderno"].Value.ToString()));
                    }
                    else
                    {
                        lstcustorderno.Add(row.Cells["custorderno"].Value.ToString());
                    }
                    if ( Convert.ToInt16(row.Cells["cartonqty"].Value) <= 0)
                    {
                        throw new Exception(UtilCulture.GetString("Msg.R01016", UtilCulture.GetString("Label.R02021")));
                    }
                    int maxcartonqty = getMaxCartonQty(((ValueInfo)this.cmbCustomer.SelectedItem).ValueField,row.Cells["custorderno"].Value.ToString());
                    if (Convert.ToInt16(row.Cells["cartonqty"].Value) >maxcartonqty )
                    {
                        throw new Exception(UtilCulture.GetString("Msg.R01014", UtilCulture.GetString("Label.R02021"), maxcartonqty.ToString()));
                    }
                    tinpshippingdtl dtl = new tinpshippingdtl();
                    if (UpdateMode == Public_UpdateMode.Update)
                    {
                        List<MESParameterInfo> lstParams = new List<MESParameterInfo>() {
                            new MESParameterInfo(){ParamName="custorderno",ParamValue=row.Cells["custorderno"].Value.ToString()},
                            new MESParameterInfo(){ParamName="shippingsysid",ParamValue=ShipingSysId}
                        };

                        DataSet ds = client.GetShippingDtlCtnRecords(baseForm.CurrentContextInfo, lstParams.ToArray<MESParameterInfo>());

                        if (ds.Tables[0].Rows.Count > Convert.ToInt16(row.Cells["cartonqty"].Value))
                        {
                            throw new Exception(UtilCulture.GetString("Msg.R01023", UtilCulture.GetString("Label.R02021"), ds.Tables[0].Rows.Count.ToString()));
                        }
                    }
                    dtl.shippingsysid = ShipingSysId;
                    dtl.shippingplanno = this.txtShippingPlanNo.Text;
                    dtl.customerid =((ValueInfo)this.cmbCustomer.SelectedItem).ValueField;
                    dtl.custorderno = row.Cells["custorderno"].Value.ToString();
                    dtl.ttlcantonqty = Convert.ToInt16(row.Cells["cartonqty"].Value);
                    lstshippingdtl.Add(dtl);
                }
                if (lstshippingdtl.Count == 0)
                {
                    throw new Exception(UtilCulture.GetString("Msg.R01019"));
                }
                tinpshippingplan shippingplan = new tinpshippingplan();
                shippingplan.shippingplanno = this.txtShippingPlanNo.Text;
                shippingplan.loadingdate = Convert.ToDateTime(this.dtLoadingDt.Value);
                shippingplan.boxqty = this.txtBoxQty.Text;
                shippingplan.deliverybill = this.txtDeliveryBill.Text;
                shippingplan.inshipno = this.txtInShipNo.Text;
                shippingplan.commissionedqty =Convert.ToInt16( this.numCommissionedQty.Value);
                shippingplan.commissionedvolume = this.numCommissionedVolume.Value;
                shippingplan.commissionedweight = this.numCommissionedWeight.Value;
                shippingplan.startport = this.txtStartPort.Text;
                shippingplan.destinationport = this.txtDestinationPort.Text;
                shippingplan.unloadport = this.txtUnloadPort.Text;
                shippingplan.voyage = this.txtVoyage.Text;
                shippingplan.remark = this.txtRemark.Text;

                client.DoShipPlan(baseForm.CurrentContextInfo, lstshippingdtl.ToArray<tinpshippingdtl>(), shippingplan);
                if (UpdateMode == Public_UpdateMode.Update)
                {
                    baseForm.CreateMessageBox(Public_MessageBox.Information, MessageBoxButtons.OK, null, UtilCulture.GetString("Msg.R00002"));
                }
                else
                {
                    baseForm.CreateMessageBox(Public_MessageBox.Information, MessageBoxButtons.OK, null, UtilCulture.GetString("Msg.R00001"));
                }
                this.Close();

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