public string DoSave() { 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 dt = ds.POMAIN; var taPurMain = new POMAINTableAdapter(); var taPurDetail = new PODETAILTableAdapter(); taPurMain.Connection.ConnectionString = _constr; taPurMain.Fill(dt); // Assaign Transaction taPurMain.AssignConnection(cn, tran); taPurDetail.AssignConnection(cn, tran); var dr = dt.FindByPONO(Drow.PONO); if (dr != null) { dr.BeginEdit(); } else { dr = (DsPurchase.POMAINRow)dt.NewRow(); } if (string.IsNullOrEmpty(Drow.PONO)) { var autoid = dm.GetAutoId(11); autoid++; Utils.Pono = dm.CreateFormatedAutoNo(autoid); dr.PONO = Utils.Pono; dr.USERID = Utils.Userid; dr.COMPANY = Utils.Company; dr.UDATE = DateTime.Now; isnew = true; } else { Utils.Pono = Drow.PONO; dr.EDATE = DateTime.Now; dr.EUSERID = Utils.Userid; } dr.TRANDATE = Drow.TRANDATE; dr.SUPID = Drow.SUPID; dr.SUPNAME = Drow.SUPNAME; dr.SUPADD = Drow.SUPADD; dr.DELADD = Drow.DELADD; dr.DUEDAYS = Drow.DUEDAYS; dr.STORECODE = Drow.STORECODE; dr.EXTRDISC = Drow.EXTRDISC; dr.NETVALUE = Drow.NETVALUE; dr.PAYTERMS = Drow.PAYTERMS; dr.supnote = Drow.supnote; if (isnew) { dt.Rows.Add(dr); taPurMain.Update(dt); } else { dr.EndEdit(); taPurMain.Update(dr); } foreach (DataRow purd in Podetail.Rows) { if ((purd.RowState != DataRowState.Deleted)) purd["PONO"] = Utils.Pono; } taPurDetail.Update(Podetail); tran.Commit(); dm.UpdateAutoNum(11); retval = "1"; } catch (Exception ex) { if (tran != null) tran.Rollback(); if (isnew) Utils.Pono = string.Empty; retval = ex.ToString(); } return retval; }
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; }
public string DoSave(DsInventory.ADJMASTRow drow, DsInventory.ADJDETAILDataTable adjdetailDataTable) { 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 DsInventory(); var dt = ds.ADJMAST; var taAdjMast = new ADJMASTTableAdapter(); var taAdjDetail = new ADJDETAILTableAdapter(); var taStockMaster = new STOCKMASTERTableAdapter(); taStockMaster.Connection.ConnectionString = _constr; taAdjMast.Connection.ConnectionString = _constr; taStockMaster.Fill(ds.STOCKMASTER); taAdjMast.Fill(ds.ADJMAST); // Assaign Transaction taAdjMast.AssignConnection(cn, tran); taAdjDetail.AssignConnection(cn, tran); taStockMaster.AssignConnection(cn, tran); var dr = dt.FindByADJID(drow.ADJID); if (dr != null) { dr.BeginEdit(); } else { dr = (DsInventory.ADJMASTRow )dt.NewRow(); } if (string.IsNullOrEmpty(drow.ADJID)) { var autoid = dm.GetAutoId(10); autoid++; Utils.Adjid = dm.CreateFormatedAutoNo(autoid); dr.ADJID = Utils.Adjid; dr.USERID = Utils.Userid; dr.COMPANY = Utils.Company; isnew = true; } else { Utils.Adjid = drow.ADJID; } dr.STORECODE = drow.STORECODE; dr.TRANDATE = drow.TRANDATE; dr.REASON = drow.REASON; if (isnew) { dt.Rows.Add(dr); taAdjMast.Update(dt); } else { dr.EndEdit(); taAdjMast.Update(dr); } foreach (DataRow purd in adjdetailDataTable.Rows) { if ((purd.RowState != DataRowState.Deleted)) purd["ADJID"] = Utils.Adjid; } taAdjDetail.Update(adjdetailDataTable); Masters.StockMaster.UpdateInventoryItem(ref ds, adjdetailDataTable); taStockMaster.Update(ds.STOCKMASTER); tran.Commit(); dm.UpdateAutoNum(10); retval = "1"; } catch (Exception ex) { if (tran != null) tran.Rollback(); if (isnew) Utils.Adjid = string.Empty; retval = ex.ToString(); } return retval; }
public string DoSave(Ledgers.ARAPRECEIPTSRow drmain,Ledgers.ARAPRECEIPTSDETAILSDataTable dt) { SqlTransaction tran = null; var isnew = false; string retval = string.Empty; try { var cn = new SqlConnection (_constr); cn.Open(); tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted); var taPurPaid = new ARAPRECEIPTSTableAdapter {Connection = {ConnectionString = _constr}}; var dtmain = new Ledgers.ARAPRECEIPTSDataTable(); var ds = taPurPaid.Fill(dtmain); var taPurPaidDet = new ARAPRECEIPTSDETAILSTableAdapter(); var taApAr = new LedgersTableAdapters.APARMAINTableAdapter(); var taLedger = new LedgersTableAdapters.LEDGERSTableAdapter(); taLedger.AssignConnection(cn, tran); taPurPaid.AssignConnection(cn,tran); var dm = new DataManager(); taPurPaidDet.AssignConnection(cn,tran); var dr = dtmain.FindByARAPTRANID(drmain.ARAPTRANID); if (dr != null) { dr.BeginEdit(); } else { dr = (Ledgers.ARAPRECEIPTSRow) dtmain.NewRow(); Utils.PurPayment = dm.GetAutoId(19).ToString("D6"); drmain.ARAPTRANID =Utils.PurPayment; dr.ARAPTRANID = Utils.PurPayment; isnew = true; } dr.AMOUNT = drmain.AMOUNT; dr.TDATE = drmain.TDATE; dr.BANKID = drmain.BANKID; dr.POSTED = false; string cmdtxt = string.Empty; foreach (Ledgers.ARAPRECEIPTSDETAILSRow drdet in dt.Rows) { if (drdet.RowState != DataRowState.Deleted) { drdet.ARAPTRANID = dr.ARAPTRANID; cmdtxt = "update APARMAIN set PAIDAMOUNT = " + drdet.AppliedAmt + ", BALANCE = 0 where TRANID = " + drdet.TRANID; var cmd = new SqlCommand(cmdtxt, cn, tran); cmd.ExecuteNonQuery(); taLedger.Insert("S", drdet.REFNO, DateTime.Now.Date, drdet.INVOICEDATE, dr.ARAPTRANID,drdet.INVOICENO, drdet.INVAMOUNT,0, 18, Utils.Company, Utils.Userid, "Purchase Payment"); } } if (isnew) { dtmain.Rows.Add(dr); taPurPaid.Update(dtmain); } else { dr.EndEdit(); taPurPaid.Update(dr); } taPurPaidDet.Update(dt); tran.Commit(); dm.UpdateAutoNum(19); retval = "1"; } catch (Exception ex) { tran.Rollback(); retval = ex.ToString(); } return retval; }
public string DoSave(DsPurchase.PURINVMAINRow drow, DsPurchase.PURINVDETAILDataTable purinvdetail,bool issale=false, string tostore = "") { 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 dt = ds.PURINVMAIN; var taPurMain = new PURINVMAINTableAdapter(); var taPurDetail = new PURINVDETAILTableAdapter(); var taStockMaster = new STOCKMASTERTableAdapter(); var taPriceMaster = new DsMasterTableAdapters.PRICEMASTERTableAdapter(); var taItemMaster = new DsMasterTableAdapters.ITEMMASTTableAdapter(); var taapar = new LedgersTableAdapters.APARMAINTableAdapter(); var taledger = new LedgersTableAdapters.LEDGERSTableAdapter(); taPurMain.Connection.ConnectionString = _constr; taPurMain.FillByPurid(ds.PURINVMAIN, drow.PURINVID); // taPurMain.Fill(ds.PURINVMAIN); // Assaign Transaction taPurMain.AssignConnection(cn, tran); taPurDetail.AssignConnection(cn, tran); taStockMaster.AssignConnection(cn, tran); taPriceMaster.AssignConnection(cn, tran); taItemMaster.AssignConnection(cn, tran); taapar.AssignConnection(cn, tran); taledger.AssignConnection(cn, tran); var dr = dt.FindByPURINVID(drow.PURINVID); if (dr != null) { dr.BeginEdit(); } else { dr = (DsPurchase.PURINVMAINRow)dt.NewRow(); } if (string.IsNullOrEmpty(drow.PURINVID)) { var autoid = dm.GetAutoId(1); autoid++; Utils.Purinvid = dm.CreateFormatedAutoNo(autoid); dr.PURINVID = Utils.Purinvid; dr.USERID = Utils.Userid; dr.COMPANY = Utils.Company; dr.UDATE = DateTime.Now; isnew = true; } else { Utils.Purinvid = drow.PURINVID; 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.DUEDAYS = drow.DUEDAYS; 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); } //bool issale = false;//string tostore = string.Empty; //STOCK if (!drow.HOLD) { if (issale) { new StockMaster().CreateStock(ref cn, ref tran, purinvdetail, drow.WHID, "S", true, false); } else { new StockMaster().CreateStock(ref cn, ref tran, purinvdetail, drow.WHID, "P", true, false); } //Price Master taPriceMaster.Update(new PriceMaster().UpdatePriceMaster(purinvdetail, drow.SUPID)); //UPDATE LASTPRICE,LASTEXPIRY,LASTCOSTPRICE //LEDGER taapar.Insert("S", dr.SUPID, DateTime.Now.Date, dr.INVDATE, Utils.Purinvid, dr.INVNO, dr.NETVALUE, 0, dr.NETVALUE, Utils.Company, 1, Utils.Userid, 0); taledger.Insert("S", dr.SUPID, DateTime.Now.Date, dr.INVDATE, Utils.Purinvid, dr.INVNO, 0, dr.NETVALUE, 1, Utils.Company, Utils.Userid,"Purchase Invoice"); } foreach (DsPurchase.PURINVDETAILRow purd in purinvdetail.Rows) { if ((purd.RowState != DataRowState.Deleted)) { purd.PURINVID = Utils.Purinvid; if (!purd.IsISSUEFORSALENull()) { issale = purd.ISSUEFORSALE; tostore = purd.TOSTORE; } // Item Master Price if (!drow.HOLD) { taItemMaster.UpdateCPSP(purd.SPRICE, purd.CPRICE, purd.ITEMNO); } } } taPurDetail.Update(purinvdetail); tran.Commit(); dm.UpdateAutoNum(1); retval = "1"; } catch (Exception ex) { if (tran != null) tran.Rollback(); if (isnew) Utils.Purinvid = string.Empty; retval = ex.ToString(); } return retval; }
public string DoSave() { string retval = "0"; SqlTransaction tran = null; try { var cn = new SqlConnection { ConnectionString = _constr }; cn.Open(); tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted); var dm = new DataManager(); var dt = new Ledgers.APARMAINDataTable(); var ta = new LedgersTableAdapters.APARMAINTableAdapter {Connection = {ConnectionString = _constr}}; ta.Fill(dt); var taleder = new LedgersTableAdapters.LEDGERSTableAdapter(); taleder.AssignConnection(cn,tran); ta.AssignConnection(cn, tran); var tasalesamtdetails = new LedgersTableAdapters.SalesAmountDetailsTableAdapter(); tasalesamtdetails.AssignConnection(cn, tran); var autoid = dm.GetAutoId(17); autoid++; Utils.CustomerReceipt = dm.CreateFormatedAutoNo(autoid); ta.Update(AparmainData); var bl = new SalesManger().GetInvoiceNo(17); taleder.Insert("C", customerno, trandate, trandate, Utils.CustomerReceipt, Utils.CustomerReceipt,0 , AppliedAmt, 17, Utils.Company, Utils.Userid, "Customer Receipt"); tasalesamtdetails.Insert(trandate, null, customerno, "C", amountype, AppliedAmt, shiftcode, false, Utils.Company,userid, false, null); tran.Commit(); retval = "1"; } catch (Exception ex) { retval = ex.ToString(); if (tran != null) tran.Rollback(); } return retval; }
public string GetInvoiceNo(int srcid=14) { var dm = new DataManager(); var autoid = dm.GetAutoId(srcid); autoid++; string retval = Utils.Company + autoid.ToString("D8"); // dm.CreateFormatedAutoNo(autoid); dm.UpdateAutoNum(srcid); return retval; }
public string DoSave(DsInventory.ITEMTRANSFERMAINRow drow, DsInventory.ITEMTRANSFERDETAILDataTable itemtransferdetail, string Stype) { var dm = new DataManager(); string retval = "0"; SqlTransaction tran = null; var isnew = false; try { var cn = new SqlConnection(_constr); cn.Open(); tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted); var ds = new DsInventory(); var dt = ds.ITEMTRANSFERMAIN; var taItemTransMain = new ITEMTRANSFERMAINTableAdapter(); var taItremTransDetail = new ITEMTRANSFERDETAILTableAdapter(); var taStockMaster = new STOCKMASTERTableAdapter {Connection = {ConnectionString = _constr}}; taItemTransMain.Connection.ConnectionString = _constr; taStockMaster.Fill(ds.STOCKMASTER); taItemTransMain.FillByTranid(dt, drow.TRANID); // Assaign Transaction taItemTransMain.AssignConnection(cn, tran); taItremTransDetail.AssignConnection(cn, tran); taStockMaster.AssignConnection(cn, tran); var dr = dt.FindByTRANID(drow.TRANID); if (dr != null) { dr.BeginEdit(); } else { dr = (DsInventory.ITEMTRANSFERMAINRow) dt.NewRow(); isnew = true; } if (isnew) { var autoid = dm.GetAutoId(3); autoid++; Utils.Tranid = dm.CreateFormatedAutoNo(autoid); dr.TRANID = Utils.Tranid; dr.COMPANY = Utils.Company; } else { Utils.Tranid = drow.TRANID; dr.EDATE = DateTime.Now; dr.EUSERID = Utils.Userid; } dr.FRMSTOREID = drow.FRMSTOREID; dr.TOSTOREID = drow.TOSTOREID; dr.TRANDATE = drow.TRANDATE; dr.TOTVALUE = drow.TOTVALUE; dr.TOTITEMS = itemtransferdetail.Count; dr.HOLD = drow.HOLD; dr.FRMNAME = drow.FRMNAME; dr.TONAME = drow.TONAME; dr.TTYPE = drow.TTYPE; dr.TOCOMP = drow.TOCOMP; dr.USERID = drow.USERID; var taa = new DataManager(); dr.DOWNFILENO = drow.DOWNFILENO; if (isnew) { dt.Rows.Add(dr); taItemTransMain.Update(dt); if (dr.TTYPE == 3) { dr.AFILENO = Utils.Tranid; // taa.CreateFormatedAutoNo(taa.GetAutoId(5)); dr.FLAGFILE = true; } } else { dr.EndEdit(); taItemTransMain.Update(dr); } foreach (DataRow purd in itemtransferdetail.Rows) { if ((purd.RowState != DataRowState.Deleted)) { purd["TRANID"] = Utils.Tranid; purd["TOSTORE"] = drow.TOSTOREID; } } taItremTransDetail.Update(itemtransferdetail); if (!dr.HOLD) { Masters.StockMaster.UpdateQtyInStockDataSet(ref cn, ref tran, itemtransferdetail, false); if (dr.TTYPE == 3) { new Masters.StockMaster().CreateStock(ref cn, ref tran, itemtransferdetail, drow.TOSTOREID, Stype, false, false); } dm.UpdateAutoNum(3); } tran.Commit(); retval = "1"; } catch (Exception ex) { if (tran != null) tran.Rollback(); if (isnew) Utils.Tranid = string.Empty; retval = ex.ToString(); } return retval; }