Exemple #1
0
 public string DoSave()
 {
     string retval;
     //  SqlTransaction tran = null;
     try
     {
         var cn = new SqlConnection {ConnectionString = _constr};
         cn.Open();
         //tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted);
         var dt = new DsMaster().USERINFO;
         bool isnew = false;
         var ta = new DsMasterTableAdapters.USERINFOTableAdapter() {Connection = cn};
         ta.Fill(dt);
         //ta.AssignConnection(cn, tran);
         var dr = dt.FindByUSERID(userinfoRow.USERID);
         if (dr != null)
         {
             dr.BeginEdit();
             dr.EDATE = System.DateTime.Now.Date;
             dr.EDITEDBY = Utils.Userid;
         }
         else
         {
             dr = (DsMaster.USERINFORow) dt.NewRow();
             isnew = true;
             dr.CREATEDBY = Utils.Userid;
             dr.CDATE = System.DateTime.Now.Date;
         }
         dr.USERNAME = userinfoRow.USERNAME;
         dr.FULLNAME = userinfoRow.FULLNAME;
         dr.EMPNO = userinfoRow.EMPNO;
         dr.PASSWORD = userinfoRow.PASSWORD;
         dr.ACTIVE = userinfoRow.ACTIVE;
         dr.PROFILEID = userinfoRow.PROFILEID;
         dr.USERTYPE = userinfoRow.USERTYPE;
         if (isnew)
         {
             dt.Rows.Add(dr);
             ta.Update(dt);
         }
         else
         {
             dr.EndEdit();
             ta.Update(dt);
         }
         //Utils.NewUserid
         retval = "1";
     }
     catch (Exception ex)
     {
         retval = ex.ToString();
         // if (tran != null) tran.Rollback();
     }
     return retval;
 }