コード例 #1
0
ファイル: Masters.cs プロジェクト: rehman922/VIRETAIL
 // public DsMaster.STOREMASTRow StoremastRow;
 public string DoSave()
 {
     string retval="0";
     SqlTransaction tran = null;
     var isnew = false;
     try
     {
         var cn = new SqlConnection {ConnectionString = _constr};
         cn.Open();
         tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted);
         var dt = new DsMaster().STOREMAST;
         var ta = new DsMasterTableAdapters.STOREMASTTableAdapter();
         ta.Connection.ConnectionString = _constr;
         ta.Fill(dt);
         ta.AssignConnection(cn, tran);
         var dr = dt.FindBySTORECODE(storecode);
         if (dr != null)
         {
             dr.BeginEdit();
             dr.EditedBy = Utils.Userid;
         }
         else
         {
             dr = (DsMaster.STOREMASTRow) dt.NewRow();
             isnew = true;
             var autoid = new DataManager().GetAutoId(9);
             autoid++;
             storecode = String.Format("{0,-2:D2}", autoid);
             dr.CREATEDBY = Utils.Userid;
             dr.CREATEDATE = System.DateTime.Now.Date;
         }
         dr.STORECODE = storecode;
         dr.STORETYPE = storetype;
         dr.STORENAME = storename;
         dr.ADDRESSS = address;
         dr.PHONENO = phono;
         dr.FAXNO = fax;
         dr.COMM = communicationtype;
         dr.COMPANY = COMPANY;
         if (isnew)
         {
             dt.Rows.Add(dr);
             ta.Update(dt);
         }
         else
         {
             dr.EndEdit();
             ta.Update(dt);
         }
         new DataManager().UpdateAutoNum(9);
         tran.Commit();
         retval = "1";
     }
     catch (Exception ex)
     {
         retval = ex.ToString();
         if (tran != null) tran.Rollback();
     }
     return retval;
 }