示例#1
0
        public void ResetThePromotionPrice(DateTime dt1)
        {
            string retval = "0";
            SqlTransaction tran = null;
            var cn = new SqlConnection(_constr);
            try
            {
                cn.Open();

                var t = new Ledgers.PROMOITEMSDataTable();
                var tam = new LedgersTableAdapters.PROMOITEMSTableAdapter().FillByToDate(t, dt1);
                PromoitemsDataTable = t;

                tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted);
               // tam.AssignConnection(cn, tran);
                var clstock = new StockMaster();
                var clitem = new ItemMaster();
                foreach (Ledgers.PROMOITEMSRow dr in PromoitemsDataTable.Rows)
                {
                        //dr.POSTED = true;
                        clstock.UpdateSpriceByItemno(dr.ITEMNO, dr.OLDPRICE, ref cn, ref tran);
                        clitem.UpdateSpriceByItemno(dr.ITEMNO, dr.OLDPRICE, ref cn, ref tran);
                }
                tran.Commit();
              //  retval = "1";
            }
            catch (Exception ex)
            {
                retval = ex.ToString();
                if (tran != null && cn.State == ConnectionState.Open)
                {
                    tran.Rollback();
                }
            }
        }
示例#2
0
        public string DoUploadPromotionItems(Ledgers.PROMOITEMSDataTable dtp,bool isRemote)
        {
            string retval;
            SqlTransaction tran = null;
            try
            {
                //isRemote true mean data downloading in local machine , isremote false mean data uploading in sync
                if (isRemote)
                    _syncConstr = Utils.Connectionstring;

                var cn = new SqlConnection(_syncConstr);
                cn.Open();
                tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted);
                var ds = new Ledgers();

                //var dt = ds.COMMISIONMAST;
                var dtdetail = ds.PROMOITEMS;

                var taCommMain = new PROMOITEMSTableAdapter();
                taCommMain.AssignConnection(cn, tran);
                
                    var clstock = new StockMaster();
                    var clitem = new ItemMaster();
                
                foreach (Ledgers.PROMOITEMSRow ditemdetarow in dtp.Rows)
                {
                    var newdetrow = dtdetail.NewRow();


                    //dtdetail.TIDColumn.AutoIncrement = false;
                    //dtdetail.TIDColumn.ReadOnly = false;

                    if (isRemote)
                    {
                        clstock.UpdateSpriceByItemno(ditemdetarow.ITEMNO, ditemdetarow.NEWPRICE, ref cn, ref tran);
                        clitem.UpdateSpriceByItemno(ditemdetarow.ITEMNO, ditemdetarow.NEWPRICE, ref cn, ref tran);
                    }
                    foreach (DataColumn dc in dtp.Columns)
                    {
                        //if (!dc.ReadOnly)
                        //{
                        
                            newdetrow[dc.ColumnName] = ditemdetarow[dc.ColumnName];
                       // }
                    }
                    dtdetail.Rows.Add(newdetrow);
                }
                taCommMain.Update(dtdetail);
                 
                tran.Commit();
                retval = "1";
            }
            catch (Exception ex)
            {
                if (tran != null)
                    tran.Rollback();
                retval = ex.ToString();
            }
            return retval; 

            
        }
示例#3
0
        public string DoSave(bool isdownload=false)
        {
            string retval = "0";
            SqlTransaction tran = null;
            var cn = new SqlConnection(_constr);
            try
            {
                cn.Open();

                var tam = new LedgersTableAdapters.PROMOITEMSTableAdapter();
                
                tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted);
                tam.AssignConnection(cn, tran);
                var clstock = new StockMaster();
                var clitem = new ItemMaster();
                foreach (Ledgers.PROMOITEMSRow dr in PromoitemsDataTable.Rows)
                {
                    if (!isdownload)
                    {
                        if (!dr.POSTED)
                        {
                            dr.POSTED = true;
                            clstock.UpdateSpriceByItemno(dr.ITEMNO, dr.NEWPRICE, ref cn, ref tran);
                            clitem.UpdateSpriceByItemno(dr.ITEMNO, dr.NEWPRICE, ref cn, ref tran);
                        }
                    }
                    else
                    {
                        dr.POSTED = true;
                        clstock.UpdateSpriceByItemno(dr.ITEMNO, dr.NEWPRICE, ref cn, ref tran);
                        clitem.UpdateSpriceByItemno(dr.ITEMNO, dr.NEWPRICE, ref cn, ref tran);

                    }
                }
                tam.Update(PromoitemsDataTable);
                tran.Commit();
                retval = "1";
            }
            catch (Exception ex)
            {
                retval = ex.ToString();
                if (tran != null && cn.State == ConnectionState.Open)
                {
                    tran.Rollback();
                }
            }
            return retval;
        }