public string DoSalesItemDelete(DsInventory.SALESINVDETAILRow dr) { SqlTransaction tran = null; var retval = "0"; try { var cn = new SqlConnection(_constr); cn.Open(); tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted); var dt = new DsInventory.SALESINVDETAIL_DELDataTable(); var tastock = new DsInventoryTableAdapters.STOCKMASTERTableAdapter(); var tasalede = new DsInventoryTableAdapters.SALESINVDETAIL_DELTableAdapter(); // var tasales = new DsInventoryTableAdapters.SALESINVDETAILTableAdapter(); tastock.AssignConnection(cn, tran); tasalede.AssignConnection(cn, tran); // tasales.AssignConnection(cn,tran); var dr1 = (DsInventory.SALESINVDETAIL_DELRow)dt.NewRow(); dr1.SINVNO = dr.SINVNO; dr1.ITEMNO = dr.ITEMNO; dr1.BARCODE = dr.BARCODE; dr1.QTY = dr.QTY; dr1.INVRATE = dr.INVRATE; dr1.SPRICE = dr.SPRICE; dr1.CPRICE = dr.CPRICE; if (!dr.IsEXPDATENull()) dr1.EXPDATE = dr.EXPDATE; dr1.STOCKID = dr.STOCKID; dr1.STOCK = dr.STOCK; dr1.DOCTORID = dr.DOCTORID; dr1.ITEMNAME = dr.ITEMNAME; dr1.COMPANY = Utils.Company; dr1.TRANDATE = DateTime.Now; dr1.USERID = Utils.Userid; dr1.ISRETURN = dr.ISRETURN; dt.Rows.Add(dr1); //tasalede.Insert(dr.SINVNO, dr.ITEMNO, dr.BARCODE, dr.QTY, dr.INVRATE, dr.SPRICE, dr.CPRICE, dr.EXPDATE, // dr.STOCKID, dr.STOCK, dr.DOCTORID, dr.ITEMNAME, Utils.Company, DateTime.Now, Utils.Userid,dr.ISRETURN); tasalede.Update(dr1); if (dr.STOCKID > 0) { if(dr.ISRETURN) tastock.UpdateSaleQtyByStockid((-1* dr.QTY), dr.STOCKID); else tastock.UpdateSaleQtyByStockid(dr.QTY, dr.STOCKID); } // tasales.Update(salesinvdetail); tran.Commit(); retval = "1"; } catch (Exception ex) { retval = ex.ToString(); tran.Rollback(); } return retval; }
public string UpdateQtyAndSalesTable(int stockid,int qty,DsInventory.SALESINVDETAILDataTable salesinvdetail) { string retval = "0"; SqlTransaction tran = null; try { var cn = new SqlConnection(_constr); cn.Open(); tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted); var ds = new DsInventory(); var tasalDetail = new DsInventoryTableAdapters.SALESINVDETAILTableAdapter(); var tastock = new DsInventoryTableAdapters.STOCKMASTERTableAdapter(); tasalDetail.AssignConnection(cn, tran); tastock.AssignConnection(cn, tran); tastock.UpdateSaleQtyByStockid(qty, stockid); tasalDetail.Update(salesinvdetail); tran.Commit(); retval = "1"; } catch (Exception ex) { retval = ex.ToString(); tran.Rollback(); } return retval; }
public void DoSalesItemDelete(DsInventory.SALESINVDETAILRow dRow, ref SqlConnection cn, ref SqlTransaction tran) { // tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted); var dt = new DsInventory.SALESINVDETAIL_DELDataTable(); var tastock = new DsInventoryTableAdapters.STOCKMASTERTableAdapter(); var tasalede = new DsInventoryTableAdapters.SALESINVDETAIL_DELTableAdapter(); tastock.AssignConnection(cn, tran); tasalede.AssignConnection(cn, tran); var dr = (DsInventory.SALESINVDETAIL_DELRow) dt.NewRow(); dr.SINVNO = dRow.SINVNO; dr.ITEMNO = dRow.ITEMNO; dr.BARCODE = dRow.BARCODE; dr.QTY = dRow.QTY; dr.INVRATE = dRow.INVRATE; dr.SPRICE = dRow.SPRICE; dr.CPRICE = dRow.CPRICE; if(!dRow.IsEXPDATENull()) dr.EXPDATE = dRow.EXPDATE; dr.STOCKID = dRow.STOCKID; dr.STOCK = dRow.STOCK; dr.DOCTORID = dRow.DOCTORID; dr.ITEMNAME = dRow.ITEMNAME; dr.COMPANY = Utils.Company; dr.TRANDATE = DateTime.Now; dr.USERID = Utils.Userid; tasalede.Update(dr); if (dr.STOCKID > 0) { if (dr.ISRETURN) tastock.UpdateSaleQtyByStockid(-dr.QTY, dr.STOCKID); else tastock.UpdateSaleQtyByStockid(dr.QTY, dr.STOCKID); } //if (dRow.STOCKID > 0) //{ // // tastock.UpdateQtyByStockID(dRow.QTY, dRow.STOCKID); // tastock.UpdateSaleQtyByStockid(dRow.QTY, dRow.STOCKID); //} }
public string UpdateStockDataSet(DataTable dt) { SqlTransaction tran = null; string retval ="0"; try { var cn = new SqlConnection(_constr); cn.Open(); //int autosed = int.Parse(Utils.Company)*1000000; //var str = " DBCC CHECKIDENT (STOCKMASTER , RESEED, + autosed +) "; //var cmd = new SqlCommand(str, cn); //cmd.ExecuteNonQuery(); tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted); var ta = new DsInventoryTableAdapters.STOCKMASTERTableAdapter(); ta.AssignConnection(cn, tran); if (ta.Update((DsInventory.STOCKMASTERDataTable) dt) > 0) retval = "1"; tran.Commit(); } catch (Exception ex) { if (tran != null) tran.Rollback(); retval = ex.ToString(); } return retval; }