Ejemplo n.º 1
0
 public DsPurchase.POMAINDataTable GetPoMast()
  {
     var ta = new POMAINTableAdapter {Connection = {ConnectionString = _constr}};
     var ds = new DsPurchase().POMAIN;
     ta.Fill(ds);
     return ds;
  }
Ejemplo n.º 2
0
       public string DoSave()
        {
            var dm = new DataManager();
            string retval;
            SqlTransaction tran = null;
            var isnew = false;
            try
            {
                var cn = new SqlConnection(_constr);
                cn.Open();
                tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted);
                var ds = new DsPurchase();
                var dt = ds.POMAIN;
                var taPurMain = new POMAINTableAdapter();
                var taPurDetail = new PODETAILTableAdapter();
                taPurMain.Connection.ConnectionString = _constr;

                taPurMain.Fill(dt);
                // Assaign Transaction
                taPurMain.AssignConnection(cn, tran);
                taPurDetail.AssignConnection(cn, tran);
                var dr = dt.FindByPONO(Drow.PONO);
                if (dr != null)
                { dr.BeginEdit(); }
                else
                { dr = (DsPurchase.POMAINRow)dt.NewRow(); }
                if (string.IsNullOrEmpty(Drow.PONO))
                {
                    var autoid = dm.GetAutoId(11);
                    autoid++;
                    Utils.Pono = dm.CreateFormatedAutoNo(autoid);
                    dr.PONO = Utils.Pono;
                    dr.USERID = Utils.Userid;
                    dr.COMPANY = Utils.Company;
                    dr.UDATE = DateTime.Now;
                    isnew = true;
                }
                else
                {
                    Utils.Pono = Drow.PONO;
                    dr.EDATE = DateTime.Now;
                    dr.EUSERID = Utils.Userid;
                }
                dr.TRANDATE = Drow.TRANDATE; 
                dr.SUPID = Drow.SUPID;
                dr.SUPNAME = Drow.SUPNAME;
                dr.SUPADD = Drow.SUPADD;
                dr.DELADD = Drow.DELADD;
                dr.DUEDAYS = Drow.DUEDAYS;
                dr.STORECODE = Drow.STORECODE;
                dr.EXTRDISC = Drow.EXTRDISC;
                dr.NETVALUE = Drow.NETVALUE;
                dr.PAYTERMS = Drow.PAYTERMS;
                dr.supnote = Drow.supnote;
                if (isnew)
                {
                    dt.Rows.Add(dr);
                    taPurMain.Update(dt);
                }
                else
                {
                    dr.EndEdit();
                    taPurMain.Update(dr);
                }
                foreach (DataRow purd in Podetail.Rows)
                {
                    if ((purd.RowState != DataRowState.Deleted))
                        purd["PONO"] = Utils.Pono;
                }
                taPurDetail.Update(Podetail);
                tran.Commit();
                dm.UpdateAutoNum(11);
                retval = "1";
            }
            catch (Exception ex)
            {
                if (tran != null)
                    tran.Rollback();
                if (isnew)
                    Utils.Pono = string.Empty;
                retval = ex.ToString();
            }
            return retval;
        }