예제 #1
0
 public Ledgers.COMMISIONMASTDataTable GetCommissionMast(string commid = null, bool useconstr = false, string newconstr = "p")
 {
     var dt = new Ledgers().COMMISIONMAST;
     var ta = new LedgersTableAdapters.COMMISIONMASTTableAdapter
                  {
                      Connection = { ConnectionString = useconstr ? newconstr : _constr }
                  };
     if (commid == null)
     {
         ta.Fill(dt);
     }
     else
     {
         ta.FillByCOMID(dt, commid);
     }
     return dt;
 }
예제 #2
0
 public string DoSave()
 {
     string retval = "0";
     SqlTransaction tran = null;
     var cn = new SqlConnection(_constr);
     try
     {
         cn.Open();
         var tadet = new LedgersTableAdapters.COMMISIONDETAILTableAdapter();
         var tam = new LedgersTableAdapters.COMMISIONMASTTableAdapter {Connection = {ConnectionString = _constr}};
         var dt = new Ledgers().COMMISIONMAST;
         tam.Fill(dt);
         tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted);
         tam.AssignConnection(cn, tran);
         tadet.AssignConnection(cn, tran);
         bool isnew = false;
         var dr = dt.FindByCOMID(CommisionmastRow.COMID);
         if (dr != null)
         {
             dr.BeginEdit();
             Utils.CommissionNo = CommisionmastRow.COMID;
             dr.EUSERID = Utils.Userid;
             dr.EDATE = DateTime.Now.Date;
         }
         else
         {
             isnew = true;
             var autoid = new DataManager().GetAutoId(15);
             autoid++;
             Utils.CommissionNo = new DataManager().CreateFormatedAutoNo(autoid);
             dr = (Ledgers.COMMISIONMASTRow) dt.NewRow();
             dr.PRMOFRM = CommisionmastRow.PRMOFRM;
             dr.PRMOTO = CommisionmastRow.PRMOTO;
             dr.PROMONAME = CommisionmastRow.PROMONAME;
             dr.STOREID = CommisionmastRow.STOREID;
             dr.EMPNO = CommisionmastRow.EMPNO;
             dr.STATUS = CommisionmastRow.STATUS;
             dr.COMID = Utils.CommissionNo;
             dr.USERID = Utils.Userid;
             dr.UDATE = DateTime.Now.Date;
         }
         foreach (Ledgers.COMMISIONDETAILRow crow in Commisiondetail.Rows)
         {
             crow.COMID = Utils.CommissionNo;
         }
         if (isnew)
         {
             dt.Rows.Add(dr);
             tam.Update(dt);
         }
         else
         {
             dr.EndEdit();
             tam.Update(dt);
         }
         tadet.Update(Commisiondetail);
         new DataManager().UpdateAutoNum(15);
         
         tran.Commit();
         retval = "1";
     }
     catch (Exception ex)
     {
         retval = ex.ToString();
         if (tran != null && cn.State == ConnectionState.Open)
         {
             tran.Rollback();
         }
     }
     return retval;
 }