예제 #1
0
파일: DALCity.cs 프로젝트: khwwas/SCMS
        public int SaveRecord(SETUP_City pRow_NewData)
        {
            int li_ReturnValue = 0;

            try
            {
                SCMSDataContext dbSCMS = Connection.Create();
                SETUP_City lRow_ExistingData = dbSCMS.SETUP_Cities.Where(c => c.City_Id.Equals(pRow_NewData.City_Id)).SingleOrDefault();

                if (lRow_ExistingData != null)
                {
                    lRow_ExistingData.City_Title = pRow_NewData.City_Title;
                }
                else
                {
                    dbSCMS.SETUP_Cities.InsertOnSubmit(pRow_NewData);
                }
                dbSCMS.SubmitChanges();

                li_ReturnValue = Convert.ToInt32(pRow_NewData.City_Id);
            }
            catch
            {
                return 0;
            }

            return li_ReturnValue;
        }
예제 #2
0
        public ActionResult SaveRecord(String ps_Code, String ps_Title)
        {
            SETUP_City lrow_City = new SETUP_City();
            String ls_Action = "Edit", IsAuditTrail = "", ls_UserId = "";
            String[] ls_Lable = new String[3], ls_Data = new String[3];
            Int32 li_ReturnValue = 0;

            try
            {
                if (String.IsNullOrEmpty(ps_Code))
                {
                    if (DALCommon.AutoCodeGeneration("SETUP_City") == 1)
                    {
                        ps_Code = DALCommon.GetMaximumCode("SETUP_City");
                        ls_Action = "Add";
                    }
                }

                if (!String.IsNullOrEmpty(ps_Code))
                {
                    lrow_City.City_Id = ps_Code;
                    lrow_City.City_Code = ps_Code;
                    lrow_City.City_Title = ps_Title;
                    lrow_City.Cnty_Id = "00001";
                    lrow_City.City_Active = 1;

                    li_ReturnValue = objDalCity.SaveRecord(lrow_City);
                    ViewData["SaveResult"] = li_ReturnValue;

                    IsAuditTrail = System.Configuration.ConfigurationManager.AppSettings.GetValues("IsAuditTrail")[0];

                    // Save Audit Log
                    if (li_ReturnValue > 0 && IsAuditTrail == "1")
                    {
                        DALAuditLog objAuditLog = new DALAuditLog();

                        ls_UserId = ((SECURITY_User)Session["user"]).User_Id;
                        ls_Lable[0] = "Code";
                        ls_Lable[1] = "Title";
                        ls_Lable[2] = "Country";

                        ls_Data[0] = ps_Code;
                        ls_Data[1] = ps_Title;
                        ls_Data[2] = "00001";

                        objAuditLog.SaveRecord(3, ls_UserId, ls_Action, ls_Lable, ls_Data);
                    }
                }

                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
예제 #3
0
        public ActionResult Update(SETUP_City city)
        {
            City dpCity  = new City();
            bool updated = dpCity.Update(city);

            if (updated)
            {
                return(RedirectToAction("ViewDetail", "City", new { id = city.City_Id }));
            }
            else
            {
                TempData["error"] = "Opps! Somthing went wrong!";
                return(RedirectToAction("Edit", "City", new { id = city.City_Id }));
            }
        }
예제 #4
0
        public ActionResult Add(SETUP_City city)
        {
            City dpCity = new City();
            int  id     = dpCity.Add(city);

            if (id > 0)
            {
                return(RedirectToAction("Index", "City"));
            }
            else
            {
                TempData["error"] = "Opps! Somthing went wrong!";
                return(RedirectToAction("Add", "City"));
            }
        }
예제 #5
0
 /// <summary>
 /// Updates modified values of city to the database....
 /// </summary>
 /// <param name="city"></param>
 /// <returns>Returns true if updated successfully else returns false.</returns>
 public bool Update(SETUP_City city)
 {
     using (eSuiteEntities db = new eSuiteEntities())
     {
         try
         {
             db.Entry(city).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
예제 #6
0
 /// <summary>
 /// Adds new city to the database....
 /// </summary>
 /// <param name="city"></param>
 /// <returns>Returns new city id if saved successfully else returns 0</returns>
 public int Add(SETUP_City city)
 {
     using (eSuiteEntities db = new eSuiteEntities())
     {
         try
         {
             db.Entry(city).State = System.Data.Entity.EntityState.Added;
             db.SaveChanges();
             return(city.City_Id);
         }
         catch
         {
             return(0);
         }
     }
 }