Exemplo n.º 1
0
        public void DoInsertPricing(tinppricing prc, List<tinppricingdtl> lstPrcDtl,
            List<tinppricingdtldef> lstDef)
        {
            try
            {
                dbInstance.BeginTransaction();

                PricingDal prcDal = new PricingDal(dbInstance);

                prcDal.DoInsert<tinppricing>(prc);

                for (int i = 0; i < lstPrcDtl.Count; i++)
                {
                    prcDal.DoInsert<tinppricingdtl>(lstPrcDtl[i]);
                }

                for (int i = 0; i < lstDef.Count; i++)
                {
                    prcDal.DoInsert<tinppricingdtldef>(lstDef[i]);
                }

                dbInstance.Commit();
            }
            catch (Exception ex)
            {
                dbInstance.Rollback();
                throw ex;
            }
            finally
            {
                dbInstance.CloseConnection();
            }
        }
Exemplo n.º 2
0
        public void DoUpdatePricing(tinppricing prc, List<tinppricingdtl> lstPrcDtl,
            List<tinppricingdtldef> lstDef)
        {
            try
            {
                dbInstance.BeginTransaction();

                PricingDal prcDal = new PricingDal(dbInstance);

                prcDal.DeleteDef(prc.prisysid);
                prcDal.DeleteDtl(prc.prisysid);

                for (int i = 0; i < lstPrcDtl.Count; i++)
                {
                    prcDal.DoInsert<tinppricingdtl>(lstPrcDtl[i]);
                }

                for (int i = 0; i < lstDef.Count; i++)
                {
                    prcDal.DoInsert<tinppricingdtldef>(lstDef[i]);
                }

                if (lstDef.Count <= 0)
                {
                    prcDal.DoDelete<tinppricing>(new List<MESParameterInfo>() {
                        new MESParameterInfo(){
                            ParamName="prisysid",ParamValue=prc.prisysid
                        }
                    });
                }
                else
                {
                    prcDal.DoUpdate<tinppricing>(prc);
                }

                dbInstance.Commit();
            }
            catch (Exception ex)
            {
                dbInstance.Rollback();
                throw ex;
            }
            finally
            {
                dbInstance.CloseConnection();
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new tinppricing object.
 /// </summary>
 /// <param name="prisysid">Initial value of the prisysid property.</param>
 /// <param name="customerid">Initial value of the customerid property.</param>
 public static tinppricing Createtinppricing(global::System.String prisysid, global::System.String customerid)
 {
     tinppricing tinppricing = new tinppricing();
     tinppricing.prisysid = prisysid;
     tinppricing.customerid = customerid;
     return tinppricing;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the tinppricing EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotinppricing(tinppricing tinppricing)
 {
     base.AddObject("tinppricing", tinppricing);
 }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
        public void DoShowSingleObject(List<MESParameterInfo> lstParameters)
        {
            wsINP.IwsINPClient client = new wsINP.IwsINPClient();

            try
            {
                baseForm.SetCursor();

                #region Show to UI
                tinppricing prc = client.GetSinglePricing(baseForm.CurrentContextInfo, lstParameters.ToArray<MESParameterInfo>());

                if (prc == null) return;

                baseForm.ShowSingleObjectToUI<tinppricing>(prc, this);
                OriginalPricing = prc;
                #endregion

                #region Show pricing detail
                List<MESParameterInfo> lstParameter = new List<MESParameterInfo>()
                {
                    new MESParameterInfo()
                    {
                        ParamName="prisysid",
                        ParamValue=prc.prisysid,
                        ParamType="string"
                    }
                };

                DataSet ds = client.GetPricingRecords(baseForm.CurrentContextInfo, lstParameter.ToArray<MESParameterInfo>());
                this.grdDetail.DataSource = ds.Tables[0];
                #endregion
            }
            catch (Exception ex)
            {
                MESMsgBox.ShowError(ExceptionParser.Parse(ex));
            }
            finally
            {
                baseForm.ResetCursor();
                baseForm.CloseWCF(client);
            }
        }
Exemplo n.º 7
0
 public void DoUpdatePricing(ContextInfo contextInfo, tinppricing prc, List<tinppricingdtl> lstPrcDtl,
     List<tinppricingdtldef> lstDef)
 {
     contextInfo.Action = MES_ActionType.Update;
     PricingBll bll = new PricingBll(contextInfo);
     bll.CallAccessControl();
     bll.DoUpdatePricing(prc, lstPrcDtl, lstDef);
     GC.Collect();
 }