예제 #1
0
 public string DoSave()
 {
     string retval;
     try
     {
         var cn = new SqlConnection {ConnectionString = _constr};
         cn.Open();
         var dt = new DsMaster().COMPANY;
         bool isnew = false;
         var ta = new DsMasterTableAdapters.COMPANYTableAdapter {Connection = cn};
         ta.Fill(dt);
         var dr = dt.FindByCCODE(CompanyRow.CCODE);
         if (dr != null)
         {
             dr.BeginEdit();
             dr.EUSERID = Utils.Userid;
             dr.EDATE = DateTime.Now.Date;
         }
         else
         {
             dr = (DsMaster.COMPANYRow) dt.NewRow();
             isnew = true;
             dr.CUSERID = Utils.Userid;
             dr.CDATE = DateTime.Now.Date;
         }
         dr.COMPNAME = CompanyRow.COMPNAME;
         dr.COMPADD = CompanyRow.COMPADD;
         dr.CITY = CompanyRow.CITY;
         dr.COUNTRY = CompanyRow.COUNTRY;
         dr.TELEPHONE = CompanyRow.TELEPHONE;
         dr.FAX = CompanyRow.FAX;
         dr.EMAIL = CompanyRow.EMAIL;
         dr.WEB = CompanyRow.WEB;
         dr.BUSTYPEID = CompanyRow.BUSTYPEID;
         dr.CURRID = CompanyRow.CURRID;
         dr.CCODE = CompanyRow.CCODE;
         dr.ISDEFAULT = CompanyRow.ISDEFAULT;
         if (isnew)
         {
             dt.Rows.Add(dr);
             ta.Update(dt);
         }
         else
         {
             dr.EndEdit();
             ta.Update(dt);
         }
         retval = "1";
     }
     catch (Exception ex)
     {
         retval = ex.ToString();
     }
     return retval;
 }