Пример #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();
            }
        }
Пример #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();
            }
        }