public string DoSave() { string retval = "0"; SqlTransaction tran = null; var cn = new SqlConnection(_constr); try { bool isnew = false; cn.Open(); var ta = new DsMasterTableAdapters.INSCUSTOMERSTableAdapter { Connection = { ConnectionString = _constr } }; var dt = new DsMaster().INSCUSTOMERS; ta.Fill(dt); tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted); ta.AssignConnection(cn, tran); var dr = dt.FindByTID(InscustomersRow.TID); if (dr != null) { dr.BeginEdit(); } else { isnew = true; dr = (DsMaster.INSCUSTOMERSRow)dt.NewRow(); dr.FILENO = InscustomersRow.FILENO; dr.POLICYNO = InscustomersRow.POLICYNO; dr.CLASS = InscustomersRow.CLASS; dr.CUSTSHARE = InscustomersRow.CUSTSHARE; dr.PATNAME = InscustomersRow.PATNAME; dr.CUSTNO = InscustomersRow.CUSTNO; } if (isnew) { dt.Rows.Add(dr); ta.Update(dt); } else { dr.EndEdit(); ta.Update(dt); } tran.Commit(); retval = "1"; } catch (Exception ex) { retval = ex.ToString(); if (tran != null && cn.State == ConnectionState.Open) { tran.Rollback(); } } return retval; }
public string DoSaveInsuranceCustDatails(DsMaster.INSCUSTOMERSRow drow) { string retval = "0"; //var cn = new SqlConnection(_constr); //SqlTransaction tran=null; try { // CUSTNO //FILENO,//CLASS //VISITNO //POLICYNO //PATNAME // cn.Open(); var tam = new DsMasterTableAdapters.INSCUSTOMERSTableAdapter { Connection = { ConnectionString = _constr } }; var dt = new DsMaster().INSCUSTOMERS; tam.Fill(dt); //tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted); //tam.AssignConnection(cn, tran); bool isnew = false; var dr = dt.FindByTID(drow.TID); if (dr != null) { dr.BeginEdit(); }else { isnew = true; dr = (DsMaster.INSCUSTOMERSRow)dt.NewRow(); // CUSTNO //FILENO,//CLASS //VISITNO //POLICYNO //PATNAME dr.FILENO = drow.FILENO; dr.PATNAME = drow.PATNAME; dr.POLICYNO = drow.POLICYNO; dr.PATNAME = drow.PATNAME; dr.CUSTNO = drow.CUSTNO; } if (isnew) { dt.Rows.Add(dr); tam.Update(dt); } else { dr.EndEdit(); tam.Update(dt); } // tran.Commit(); retval = "1"; } catch (Exception ex) { retval = ex.ToString(); //if (tran != null && cn.State == ConnectionState.Open) //{ // tran.Rollback(); //} } return retval; }
public string DoSave(DsMaster.PRINTERSRow printersRow) { try { var dt = new DsMaster().PRINTERS; var ta = new DsMasterTableAdapters.PRINTERSTableAdapter() {Connection = {ConnectionString = _constr}}; bool isnew = false; ta.Fill(dt); var drnew = dt.FindByTID(printersRow.TID); if (drnew != null) { drnew.BeginEdit(); } else { drnew = (DsMaster.PRINTERSRow) dt.NewRow(); isnew = true; } drnew.BarcodePrinter = printersRow.BarcodePrinter; drnew.Invoiceprinter = printersRow.Invoiceprinter; drnew.Drugprinter = printersRow.Drugprinter; drnew.Computer = printersRow.Computer; drnew.Defaultprinter = printersRow.Defaultprinter; drnew.ISDEFAULT = printersRow.ISDEFAULT; if (isnew) { dt.Rows.Add(drnew); ta.Update(dt); } else { drnew.EndEdit(); ta.Update(drnew); } return "1"; } catch (Exception ex) { return ex.ToString(); } }