Exemplo n.º 1
0
        //Update a record
        public static int UpdateRecord(eTax eobj)
        {
            int retval = 0;

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                try
                {
                    int dbobj = (from s in db.tblTaxMs.Where(u => u.sTaxName == eobj.sTaxName.Trim() && u.iTaxId != eobj.iTaxId)
                                 select new
                    {
                        s.iTaxId,
                    }).Count();
                    if (dbobj > 0)
                    {
                        return(retval = 2);
                    }

                    OneFineRate.tblTaxM obj = (OneFineRate.tblTaxM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblTaxM());
                    db.tblTaxMs.Attach(obj);
                    db.Entry(obj).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    retval = 1;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(retval);
        }
Exemplo n.º 2
0
        //Add new record
        public static int AddRecord(eTax eobj)
        {
            int retval = 0;

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                try
                {
                    int dbobj = (from s in db.tblTaxMs.Where(u => u.sTaxName == eobj.sTaxName.Trim())
                                 select new
                    {
                        s.iTaxId,
                    }).Count();
                    if (dbobj > 0)
                    {
                        return(retval = 2);
                    }

                    OneFineRate.tblTaxM dbuser = (OneFineRate.tblTaxM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblTaxM());
                    db.tblTaxMs.Add(dbuser);
                    db.SaveChanges();
                    retval = 1;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(retval);
        }