コード例 #1
0
ファイル: DALDepartment.cs プロジェクト: khwwas/SCMS
        public int SaveRecord(SETUP_Department lrow_Department)
        {
            int li_ReturnValue = 0;

            try
            {
                SCMSDataContext dbSCMS = Connection.Create();
                SETUP_Department lRow_ExistingData = dbSCMS.SETUP_Departments.Where(c => c.Dpt_Id.Equals(lrow_Department.Dpt_Id)).SingleOrDefault();

                if (lRow_ExistingData != null)
                {
                    lRow_ExistingData.Dpt_Title = lrow_Department.Dpt_Title;
                    lRow_ExistingData.Loc_Id = lrow_Department.Loc_Id;
                }
                else
                {
                    dbSCMS.SETUP_Departments.InsertOnSubmit(lrow_Department);
                }
                dbSCMS.SubmitChanges();

                li_ReturnValue = Convert.ToInt32(lrow_Department.Dpt_Id);
            }
            catch
            {
                return 0;
            }

            return li_ReturnValue;
        }
コード例 #2
0
ファイル: DepartmentController.cs プロジェクト: khwwas/SCMS
        // Insertion
        public ActionResult SaveRecord(String ps_Code, String Location, String Title)
        {
            Int32 li_ReturnValue = 0;

            try
            {
                SETUP_Department lrow_Department = new SETUP_Department();

                if (String.IsNullOrEmpty(ps_Code))
                {
                    if (DALCommon.AutoCodeGeneration("SETUP_Department") == 1)
                    {
                        ps_Code = DALCommon.GetMaximumCode("SETUP_Department");
                    }
                }

                if (!String.IsNullOrEmpty(ps_Code))
                {
                    lrow_Department.Dpt_Id = ps_Code;
                    lrow_Department.Dpt_Code = ps_Code;
                    lrow_Department.Dpt_Title = Title;
                    lrow_Department.Loc_Id = Location;
                    lrow_Department.Dpt_Active = 1;

                    li_ReturnValue = objdalDeparment.SaveRecord(lrow_Department);
                    ViewData["SaveResult"] = li_ReturnValue;
                }

                return PartialView("GridData");
            }
            catch
            {
                return PartialView("GridData");
            }
        }
コード例 #3
0
        public ActionResult Update(SETUP_Department department)
        {
            Department dpDepartment = new Department();
            bool       updated      = dpDepartment.Update(department);

            if (updated)
            {
                return(RedirectToAction("ViewDetail", "Department", new { id = department.Dep_Id }));
            }
            else
            {
                TempData["error"] = "Opps! Somthing went wrong!";
                return(RedirectToAction("Edit", "Department", new { id = department.Dep_Id }));
            }
        }
コード例 #4
0
        public ActionResult Add(SETUP_Department department)
        {
            Department dpDepartment = new Department();
            int        id           = dpDepartment.Add(department);

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