private void RefreshGrid()
    {
        DepartmentMaster oDepartmentMaster = new DepartmentMaster();

        DepartmentDTO[] oDepartmentData = oDepartmentMaster.GetData();
        if (oDepartmentData != null)
        {
            if (oDepartmentData.Length > 0)
            {
                dgDepartment.DataSource = oDepartmentData;
                dgDepartment.DataBind();
            }
        }
        else
        {
            dgDepartment.DataSource = null;
            dgDepartment.DataBind();
        }
        txtDepartmentCode.Text = "";
        txtDepartmentName.Text = "";
        oDepartmentData        = null;
        oDepartmentMaster      = null;
    }
        public int AddDepartment(DepartmentMaster _master, string Otype)
        {
            DALCommon dal = new DALCommon(ConStr);

            return(dal.AddDepartment(_master, Otype));
        }
示例#3
0
        public bool Put(DepartmentMaster departmentMaster)
        {
            DepartmentMasterRepository department = new DepartmentMasterRepository();

            return(department.Put(departmentMaster));
        }
        public ActionResult savedata(DepartmentMaster obj, string Save, string Viewshow, string Update)
        {
            #region ##############SAVE##############
            if (!string.IsNullOrEmpty(Save))
            {
                var DepartmentName = obj.DeptName;
                var checkduplicacy = (from x in db.DepartmentMasters
                                      where x.DeptName == DepartmentName && x.DeptState == obj.DeptState
                                      select x
                                      ).ToList();

                if (ModelState.IsValid)
                {
                    if (checkduplicacy.Count > 0)
                    {
                        ViewBag.Statelists = SelectListItem();
                        TempData["alert"]  = "0";
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        db.DepartmentMasters.Add(obj);
                        db.SaveChanges();
                        TempData["alert"] = "1";
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    string messages = string.Join("; ", ModelState.Values
                                                  .SelectMany(x => x.Errors)
                                                  .Select(x => x.ErrorMessage));
                }
            }
            #endregion

            #region #########SHOW###############
            if (!string.IsNullOrEmpty(Viewshow))
            {
                ViewBag.Statelists = SelectListItem();

                ViewBag.DeptName = (from s in db.DepartmentMasters
                                    join sa in db.StateMasters on s.DeptState equals sa.StateId
                                    where s.DeptState == obj.DeptState
                                    select new CommonViewClass
                {
                    DeptId = s.DeptId,
                    DeptName = s.DeptName,
                    DeptDescription = s.DeptDescription,
                    DeptHead = s.DeptHead,
                    DeptHeadSalary = (decimal)s.DeptHeadSalary,
                    StateName = sa.StateName,
                    StateId = sa.StateId
                }).ToList();
                return(View());
            }
            #endregion

            #region #########SHOW###############
            if (!string.IsNullOrEmpty(Update))
            {
                if (ModelState.IsValid)
                {
                    db.Entry(obj).State = EntityState.Modified;
                    db.SaveChanges();
                    TempData["alert"] = "2";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    string messages = string.Join("; ", ModelState.Values
                                                  .SelectMany(x => x.Errors)
                                                  .Select(x => x.ErrorMessage));
                }
            }
            #endregion

            return(RedirectToAction("Index")); // call pageload
        }
示例#5
0
        /// <summary>
        /// Add and Edit Document
        /// </summary>
        /// <param name="data"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public CommonResponse AddAndEditDepartment(DepartmentCustom data, long userId = 0)
        {
            CommonResponse obj = new CommonResponse();

            try
            {
                var res = db.DepartmentMaster.Where(m => m.DepartmentId == data.departmentId).FirstOrDefault();
                if (res == null)
                {
                    try
                    {
                        DepartmentMaster item = new DepartmentMaster();
                        item.DepartmentName        = data.departmentName;
                        item.DepartmentDescription = data.departmentDescription;
                        item.IsActive  = true;
                        item.IsDeleted = false;
                        item.CreatedBy = userId;
                        item.CreatedOn = DateTime.Now;
                        db.DepartmentMaster.Add(item);
                        db.SaveChanges();
                        obj.response = ResourceResponse.AddedSucessfully;
                        obj.isStatus = true;
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex); if (ex.InnerException != null)
                        {
                            log.Error(ex.InnerException.ToString());
                        }
                        obj.response = ResourceResponse.ExceptionMessage;
                        obj.isStatus = false;
                    }
                }
                else
                {
                    try
                    {
                        res.DepartmentName        = data.departmentName;
                        res.DepartmentDescription = data.departmentDescription;
                        res.ModifiedBy            = userId;
                        res.ModifiedOn            = DateTime.Now;
                        db.SaveChanges();
                        obj.response = ResourceResponse.UpdatedSucessfully;
                        obj.isStatus = true;
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex); if (ex.InnerException != null)
                        {
                            log.Error(ex.InnerException.ToString());
                        }
                        obj.response = ResourceResponse.ExceptionMessage;
                        obj.isStatus = false;
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex); if (ex.InnerException != null)
                {
                    log.Error(ex.InnerException.ToString());
                }
                obj.response = ResourceResponse.ExceptionMessage;
                obj.isStatus = false;
            }
            return(obj);
        }
示例#6
0
        public IHttpActionResult Department(DepartmentMaster Department)
        {
            DepartmentMaster _Department = _DepartmentService.GetDepartmentById(Department);

            return(Json(_Department));
        }
示例#7
0
 public void DeleteDepartment(DepartmentMaster Department)
 {
     _DepartmentRepository.Delete(Department);
 }
示例#8
0
 public void UpdateDepartment(DepartmentMaster Department)
 {
     _DepartmentRepository.Update(Department);
 }
示例#9
0
 public DepartmentMaster GetDepartmentById(DepartmentMaster Department)
 {
     return(_DepartmentRepository.Table.Where(i => i.Id == Department.Id).FirstOrDefault());
 }