예제 #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the tinppricingdtldef EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotinppricingdtldef(tinppricingdtldef tinppricingdtldef)
 {
     base.AddObject("tinppricingdtldef", tinppricingdtldef);
 }
예제 #2
0
 /// <summary>
 /// Create a new tinppricingdtldef object.
 /// </summary>
 /// <param name="pridtldefsysid">Initial value of the pridtldefsysid property.</param>
 /// <param name="pridtlsysid">Initial value of the pridtlsysid property.</param>
 /// <param name="effectivedate">Initial value of the effectivedate property.</param>
 /// <param name="currency">Initial value of the currency property.</param>
 /// <param name="price">Initial value of the price property.</param>
 public static tinppricingdtldef Createtinppricingdtldef(global::System.String pridtldefsysid, global::System.String pridtlsysid, global::System.DateTime effectivedate, global::System.String currency, global::System.Decimal price)
 {
     tinppricingdtldef tinppricingdtldef = new tinppricingdtldef();
     tinppricingdtldef.pridtldefsysid = pridtldefsysid;
     tinppricingdtldef.pridtlsysid = pridtlsysid;
     tinppricingdtldef.effectivedate = effectivedate;
     tinppricingdtldef.currency = currency;
     tinppricingdtldef.price = price;
     return tinppricingdtldef;
 }
예제 #3
0
        public void DoSaveSingleObject()
        {
            wsINP.IwsINPClient client = new wsINP.IwsINPClient();

            try
            {
                baseForm.SetCursor();

                #region Validate & build object from UI
                baseForm.ValidateData(this);

                if (!CheckBeforeSave()) return;

                tinppricing prc = new tinppricing();

                if (UpdateMode == Public_UpdateMode.Update)
                {
                    prc = OriginalPricing;
                }

                //Build Pricing Object
                baseForm.CreateSingleObject<tinppricing>(prc, this, UpdateMode);

                if (UpdateMode == Public_UpdateMode.Insert)
                {
                    prc.prisysid = Function.GetGUID();
                }

                prc.lastmodifiedtime = Function.GetCurrentTime();
                prc.lastmodifieduser = Function.GetCurrentUser();

                #endregion

                #region Prepare Pricing Detail
                List<tinppricingdtl> lstDtl = new List<tinppricingdtl>();
                for (int i = 0; i < grdDetail.Rows.Count; i++)
                {
                    tinppricingdtl dtl = new tinppricingdtl();

                    dtl.checktype = this.grdDetail.Rows[i].Cells["checktype"].Value.ToString();
                    dtl.lastmodifiedtime = prc.lastmodifiedtime;
                    dtl.lastmodifieduser = prc.lastmodifieduser;
                    dtl.pridtlsysid = Function.GetGUID();
                    dtl.prisysid = prc.prisysid;
                    dtl.remark = string.Empty;
                    dtl.category = this.grdDetail.Rows[i].Cells["category"].Value.ToString();

                    if (this.grdDetail.Rows[i].Cells["reworkratio"].Value.ToString() == string.Empty)
                        dtl.reworkratio = null;
                    else
                        dtl.reworkratio = decimal.Parse(this.grdDetail.Rows[i].Cells["reworkratio"].Value.ToString());

                    if (this.grdDetail.Rows[i].Cells["reworkprice"].Value.ToString() == string.Empty)
                        dtl.reworkprice = null;
                    else
                        dtl.reworkprice = decimal.Parse(this.grdDetail.Rows[i].Cells["reworkprice"].Value.ToString());

                    if (this.grdDetail.Rows[i].Cells["sbootheight"].Value.ToString() == string.Empty)
                        dtl.sbootheight = 0;
                    else
                        dtl.sbootheight = decimal.Parse(this.grdDetail.Rows[i].Cells["sbootheight"].Value.ToString());

                    if (this.grdDetail.Rows[i].Cells["ebootheight"].Value.ToString() == string.Empty)
                        dtl.ebootheight = 0;
                    else
                        dtl.ebootheight = decimal.Parse(this.grdDetail.Rows[i].Cells["ebootheight"].Value.ToString());

                    lstDtl.Add(dtl);
                }

                var q = (from p in lstDtl
                         group p by new { p.category, p.checktype,p.sbootheight,p.ebootheight } into t1
                         select new
                         {
                             category = t1.Key.category,
                             checktype = t1.Key.checktype,
                             pridtlsysid = t1.Max(p => p.pridtlsysid),
                             prisysid = t1.Max(p => p.prisysid),
                             remark = t1.Max(p => p.remark),
                             reworkratio = t1.Max(p => p.reworkratio),
                             reworkprice = t1.Max(p => p.reworkprice),
                             sbootheight = t1.Key.sbootheight,
                             ebootheight = t1.Key.ebootheight,
                             lastmodifiedtime = t1.Max(p => p.lastmodifiedtime),
                             lastmodifieduser = t1.Max(p => p.lastmodifieduser)
                         }).ToList();

                List<tinppricingdtldef> lstDef = new List<tinppricingdtldef>();
                for (int i = 0; i < grdDetail.Rows.Count; i++)
                {
                    tinppricingdtldef def = new tinppricingdtldef();

                    var q1 = (from p in q
                              where p.category == this.grdDetail.Rows[i].Cells["category"].Value.ToString()
                              && p.checktype == this.grdDetail.Rows[i].Cells["checktype"].Value.ToString()
                              && p.sbootheight == Decimal.Parse(this.grdDetail.Rows[i].Cells["sbootheight"].Value.ToString())
                              && p.ebootheight == Decimal.Parse(this.grdDetail.Rows[i].Cells["ebootheight"].Value.ToString())
                              select p.pridtlsysid).Single();

                    def.currency = this.grdDetail.Rows[i].Cells["currency"].Value.ToString();

                    if (this.grdDetail.Rows[i].Cells["effectivedate"].Value.ToString() != string.Empty)
                        def.effectivedate = DateTime.Parse(this.grdDetail.Rows[i].Cells["effectivedate"].Value.ToString());

                    if (this.grdDetail.Rows[i].Cells["expireddate"].Value.ToString() != string.Empty)
                        def.expireddate = DateTime.Parse(this.grdDetail.Rows[i].Cells["expireddate"].Value.ToString());
                    else
                        def.expireddate = null;

                    def.price = decimal.Parse(this.grdDetail.Rows[i].Cells["price"].Value.ToString());
                    def.pridtldefsysid = Function.GetGUID();
                    def.pridtlsysid = q1;
                    def.remark = this.grdDetail.Rows[i].Cells["remark"].Value.ToString();
                    def.unit = this.grdDetail.Rows[i].Cells["unit"].Value.ToString();

                    lstDef.Add(def);
                }

                List<tinppricingdtl> lstDtlFinal = new List<tinppricingdtl>();
                for (int i = 0; i < q.Count; i++)
                {
                    tinppricingdtl dtl = new tinppricingdtl();

                    dtl.checktype = q[i].checktype;
                    dtl.lastmodifiedtime = q[i].lastmodifiedtime;
                    dtl.lastmodifieduser = q[i].lastmodifieduser;
                    dtl.pridtlsysid = q[i].pridtlsysid;
                    dtl.prisysid = q[i].prisysid;
                    dtl.remark = q[i].remark;
                    dtl.category = q[i].category;
                    dtl.reworkratio = q[i].reworkratio;
                    dtl.reworkprice = q[i].reworkprice;
                    dtl.sbootheight = q[i].sbootheight;
                    dtl.ebootheight = q[i].ebootheight;

                    lstDtlFinal.Add(dtl);
                }
                #endregion

                #region call WCF

                if (UpdateMode == Public_UpdateMode.Insert)
                {
                    client.DoInsertPricing(baseForm.CurrentContextInfo, prc,
                        lstDtlFinal.ToArray<tinppricingdtl>(), lstDef.ToArray<tinppricingdtldef>());
                }

                if (UpdateMode == Public_UpdateMode.Update)
                {
                    client.DoUpdatePricing(baseForm.CurrentContextInfo, prc,
                        lstDtlFinal.ToArray<tinppricingdtl>(), lstDef.ToArray<tinppricingdtldef>());
                }
                #endregion

                if (UpdateMode == Public_UpdateMode.Insert)
                    baseForm.CreateMessageBox(Public_MessageBox.Information, MessageBoxButtons.OK, null, UtilCulture.GetString("Msg.R00001"));
                else if (UpdateMode == Public_UpdateMode.Update)
                    baseForm.CreateMessageBox(Public_MessageBox.Information, MessageBoxButtons.OK, null, UtilCulture.GetString("Msg.R00002"));

                this.Close();
            }
            catch (Exception ex)
            {
                MESMsgBox.ShowError(ExceptionParser.Parse(ex));
            }
            finally
            {
                baseForm.ResetCursor();
                baseForm.CloseWCF(client);
            }
        }