Exemplo n.º 1
0
 public int GetPurchaseReturnHoldCount()
 {
     var ds = new DsPurchase.RETURNMASTDataTable();
     var ta = new RETURNMASTTableAdapter {Connection = {ConnectionString = _constr}};
     return ta.FillByHold(ds);
 }
Exemplo n.º 2
0
 public void UpdatedSynReturn(string purid)
 {
     var ta = new RETURNMASTTableAdapter { Connection = { ConnectionString = _constr } };
     ta.UpdatedSync(purid);
 }
Exemplo n.º 3
0
 public DsPurchase.RETURNMASTDataTable GetPurRetInvMainById(string pkid)
 {
     var ta = new RETURNMASTTableAdapter {Connection = {ConnectionString = _constr}};
     var ds = new DsPurchase().RETURNMAST;
     ta.FillByRetid(ds, pkid);
     return ds;
 }
Exemplo n.º 4
0
 public DsPurchase.RETURNMASTDataTable GetPurRetMainByHold()
 {
     var ta = new RETURNMASTTableAdapter {Connection = {ConnectionString = _constr}};
     var ds = new DsPurchase.RETURNMASTDataTable();
     ta.FillByHold(ds);
     return ds;
 }
Exemplo n.º 5
0
        public string DoSave(DsPurchase.RETURNMASTRow drow, DsPurchase.RETURNDETAILDataTable returndetail)
        {
            var dm = new DataManager();
            string retval;
            SqlTransaction tran = null;
            var isnew = false;
            try
            {
                var cn = new SqlConnection(_constr);
                cn.Open();
                tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted);
                var ds = new DsPurchase();
                var dsStock = new DsInventory();
                var dt = ds.RETURNMAST;
                var taPurMain = new RETURNMASTTableAdapter {Connection = {ConnectionString = _constr}};
                var taPurDetail = new RETURNDETAILTableAdapter();
     
    
                var taStockMaster = new STOCKMASTERTableAdapter {Connection = {ConnectionString = _constr}};
                var taapar = new LedgersTableAdapters.APARMAINTableAdapter();
                var taledger = new LedgersTableAdapters.LEDGERSTableAdapter();

                taStockMaster.Fill(dsStock.STOCKMASTER);

                taPurMain.Fill(ds.RETURNMAST);



                // Assaign Transaction
                taPurMain.AssignConnection(cn, tran);
                taPurDetail.AssignConnection(cn, tran);
                taStockMaster.AssignConnection(cn, tran);

                taapar.AssignConnection(cn, tran);
                taledger.AssignConnection(cn, tran);

                var dr = dt.FindByRETURNID(drow.RETURNID);
                if (dr != null)
                { dr.BeginEdit(); }
                else
                { dr = (DsPurchase.RETURNMASTRow)dt.NewRow(); }
                if (string.IsNullOrEmpty(drow.RETURNID))
                {
                    var autoid = dm.GetAutoId(2);
                    autoid++;
                    Utils.Retinvid = dm.CreateFormatedAutoNo(autoid);
                    dr.RETURNID = Utils.Retinvid;
                    dr.USERID = Utils.Userid;
                    dr.COMPANY = Utils.Company;
                    dr.TRANDATE = System.DateTime.Now;
                    isnew = true;
                }
                else
                {
                    Utils.Retinvid = drow.RETURNID;
                    dr.EDATE = DateTime.Now;
                    dr.EUSERID = Utils.Userid;
                }
                dr.SUPID = drow.SUPID;
                dr.SUPNAME = drow.SUPNAME;
                dr.INVDATE = drow.INVDATE;
                dr.INVNO = drow.INVNO;
                dr.SPDISCOUNT = drow.SPDISCOUNT;
                dr.WHID = drow.WHID;
                dr.ADJVALUE = drow.ADJVALUE;
                dr.NETVALUE = drow.NETVALUE;
                dr.HOLD = drow.HOLD;

                if (isnew)
                {
                    dt.Rows.Add(dr);
                    taPurMain.Update(dt);
                }
                else
                {
                    dr.EndEdit();
                    taPurMain.Update(dr);
                }
                foreach (DataRow purd in returndetail.Rows)
                {
                    if ((purd.RowState != DataRowState.Deleted))
                        purd["RETURNID"] = Utils.Retinvid;
                }
                taPurDetail.Update(returndetail);
                //STOCK
                if (!dr.HOLD)
                {
                   // Masters.StockMaster.UpdateQtyInStockDataSet(ref dsStock, returndetail, true);
                   // taStockMaster.Update(dsStock.STOCKMASTER);
                    Masters.StockMaster.UpdateQtyInStockDataSet(ref cn,ref tran, returndetail, true);
                //LEDGER
                    taapar.Insert("S", dr.SUPID, DateTime.Now.Date, dr.INVDATE, Utils.Retinvid, dr.INVNO, -dr.NETVALUE, 0, -dr.NETVALUE, Utils.Company, 2, Utils.Userid, 0);
                    taledger.Insert("S", dr.SUPID, DateTime.Now.Date, dr.INVDATE, Utils.Retinvid, dr.INVNO, dr.NETVALUE,0, 2, Utils.Company, Utils.Userid, "Purchase Retun");
                }
                dm.UpdateAutoNum(2);
                tran.Commit();
                retval = "1";
            }
            catch (Exception ex)
            {
                if (tran != null)
                    tran.Rollback();
                if (isnew)
                    Utils.Retinvid = string.Empty;
                retval = ex.ToString();
            }
            return retval;
        }
Exemplo n.º 6
0
 public void DeletePurRetInv(string purinv, string comp)
 {
     var ta = new RETURNDETAILTableAdapter {Connection = {ConnectionString = _constr}};
     ta.DeleteQueryByid(purinv);
     var ta1 = new RETURNMASTTableAdapter();
     ta1.Connection.ConnectionString = _constr;
     ta1.DeleteQuery(purinv);
 }
Exemplo n.º 7
0
        public string DoSavePurchaseInvoiceReturnInRemote(DsPurchase.RETURNMASTRow drow, DsPurchase.RETURNDETAILDataTable returndetail)
        {
            var dm = new DataManager();
            string retval="0";
            SqlTransaction tran = null;
            try
            {
                var cn = new SqlConnection(_constr);
                cn.Open();
                tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted);
                var ds = new DsPurchase();
                var dt = ds.RETURNMAST;
                var dtdetail = ds.RETURNDETAIL;

                var taPurMain = new RETURNMASTTableAdapter ();
                var taPurDetail = new RETURNDETAILTableAdapter();
                var taapar = new LedgersTableAdapters.APARMAINTableAdapter();
                var taledger = new LedgersTableAdapters.LEDGERSTableAdapter();
  
                // Assaign Transaction
                taPurMain.AssignConnection(cn, tran);
                taPurDetail.AssignConnection(cn, tran);
                taapar.AssignConnection(cn, tran);
                taledger.AssignConnection(cn, tran);
               var  dr = (DsPurchase.RETURNMASTRow)dt.NewRow();  
                    dr.RETURNID = drow.RETURNID;
                    dr.USERID = drow.USERID;
                    dr.COMPANY = drow.COMPANY;
                    dr.TRANDATE = drow.TRANDATE;
                if(!dr.IsEDATENull())
                    dr.EDATE =  dr.EDATE;
                if(!dr.IsEUSERIDNull())
                    dr.EUSERID = dr.EUSERID;
                    dr.SUPID = drow.SUPID;
                    dr.SUPNAME = drow.SUPNAME;
                    dr.INVDATE = drow.INVDATE;
                    dr.INVNO = drow.INVNO;
                    dr.SPDISCOUNT = drow.SPDISCOUNT;
                    dr.WHID = drow.WHID;
                    dr.ADJVALUE = drow.ADJVALUE;
                    dr.NETVALUE = drow.NETVALUE;
                    dr.HOLD = drow.HOLD;
                    dt.Rows.Add(dr);
                    taPurMain.Update(dt);
                //LEDGER
                    taapar.Insert("S", dr.SUPID, drow.TRANDATE, dr.INVDATE, drow.RETURNID, dr.INVNO, -dr.NETVALUE, 0, -dr.NETVALUE, Utils.Company, 2, Utils.Userid, 0);
                    taledger.Insert("S", dr.SUPID, drow.TRANDATE, dr.INVDATE, drow.RETURNID, dr.INVNO, dr.NETVALUE, 0, 2, Utils.Company, Utils.Userid, "Purchase Retun");

                    foreach (DsPurchase.RETURNDETAILRow ditemdetarow in returndetail)
                    {
                        var newdetrow = dtdetail.NewRow();
                        foreach (DataColumn dc in returndetail.Columns)
                        {
                            if (!dc.ReadOnly)
                            {
                                newdetrow[dc.ColumnName] = ditemdetarow[dc.ColumnName];
                            }
                        }
                        dtdetail.Rows.Add(newdetrow);
                    }
                    taPurDetail.Update(dtdetail);
                tran.Commit();
                retval = "1";
            }
            catch (Exception ex)
            {
                if (tran != null)
                    tran.Rollback();
                retval = ex.ToString();
            }
            return retval;
        }