Beispiel #1
0
        public DepartmentBO getDeptByEmpDeptId(string deptId)
        {
            Department   dept = da.getDepartmentById(deptId);
            DepartmentBO dbo  = convertDeptBO(dept);

            return(dbo);
        }
        public int RemoveDepartment(DepartmentBO departmentBO)
        {
            SQLHelper helper = SQLHelper.GetInstance(this.connectionString);
            int       numberOfRowImpacted = 0;

            try
            {
                helper.OpenConnection();
                query = @"
                           DELETE FROM [dbo].[DepartmentMaster]
                                WHERE [DepartmentID] = "
                        + departmentBO.DepartmentCD;

                numberOfRowImpacted = helper.ExecuteNonQuery(query);
            }
            catch (Exception ex)
            {
                numberOfRowImpacted = -1;
            }
            finally
            {
                helper.CloseConnection();
            }

            return(numberOfRowImpacted);
        }
        public string GetDepartment(DepartmentBO departmentBO)
        {
            SQLHelper helper = SQLHelper.GetInstance(this.connectionString);

            try
            {
                helper.OpenConnection();
                query = @"
                        SELECT [DepartmentID] as DepartmentCD,[DepartmentName] as DepartmentName, [DepartmentBankAccount] as DepartmentBankAccount
                        FROM [dbo].[DepartmentMaster]
                        WHERE [DepartmentID] = " + departmentBO.DepartmentCD;

                ds = helper.ExecuteDataSet(query);
            }
            catch (Exception ex)
            {
                string err = ex.Message;
            }
            finally
            {
                helper.CloseConnection();
            }
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
            {
                return(StringUtil.SerializeObjectToJSON(ds.Tables[0]));
            }
            else
            {
                return("DB_ERROR : " + dbErrMsg);
            }
        }
        /// <summary>
        /// AddDepartment() is a function which takes DepartmentBO as parameter and insert its data in database.
        /// It returns the number of rows affected by the operation which is 1 in success and 0 in failure.
        /// </summary>
        /// <param name="departmentBO">An object of DepartmentBO class which is used to hold the name and id of department.</param>
        /// <returns>int</returns>
        public int AddDepartment(DepartmentBO departmentBO)
        {
            SQLHelper helper = SQLHelper.GetInstance(this.connectionString);
            int       numberOfRowImpacted = 0;

            try
            {
                helper.OpenConnection();
                query = @"
                           INSERT INTO [dbo].[DepartmentMaster]
                                ([DepartmentID],[DepartmentName], [DepartmentBankAccount])
                            VALUES (
                                CAST((SELECT TOP 1 d.[DepartmentID] FROM [DepartmentMaster] as d ORDER BY CAST(d.[DepartmentID] as int) DESC)+1 as varchar),'"
                        + departmentBO.DepartmentName + @"','"
                        + departmentBO.DepartmentBankAccount +
                        @"')";

                numberOfRowImpacted = helper.ExecuteNonQuery(query);
            }
            catch (Exception ex)
            {
                numberOfRowImpacted = -1;
            }
            finally
            {
                helper.CloseConnection();
            }

            return(numberOfRowImpacted);
        }
        /// <summary>
        /// UpdateDepartment() is a function which takes DepartmentBO as parameter and update its data in database.
        /// It returns the number of rows affected by the operation which is 1 in success and 0 in failure.
        /// </summary>
        /// <param name="departmentBO">An object of DepartmentBO class which is used to hold the name and id of department.</param>
        /// <returns>int</returns>
        public int UpdateDepartment(DepartmentBO departmentBO)
        {
            SQLHelper helper = SQLHelper.GetInstance(this.connectionString);
            int       numberOfRowImpacted = 0;

            try
            {
                helper.OpenConnection();
                query = @"
                           UPDATE [dbo].[DepartmentMaster]
                           SET [DepartmentName] = '" + departmentBO.DepartmentName + @"',
                               [DepartmentBankAccount] = '" + departmentBO.DepartmentBankAccount + @"'
                           WHERE [DepartmentID] = " + departmentBO.DepartmentCD;

                numberOfRowImpacted = helper.ExecuteNonQuery(query);
            }
            catch (Exception ex)
            {
                numberOfRowImpacted = -1;
            }
            finally
            {
                helper.CloseConnection();
            }

            return(numberOfRowImpacted);
        }
        public void PreparingData()
        {
            var listPriority = new List <dynamic>()
            {
                new
                {
                    Name  = Priority.High.GetDescription(),
                    Value = (byte)Priority.High
                },
                new
                {
                    Name  = Priority.Normal.GetDescription(),
                    Value = (byte)Priority.Normal
                },
                new
                {
                    Name  = Priority.Low.GetDescription(),
                    Value = (byte)Priority.Low
                },
            };

            ViewBag.Priorities  = listPriority;
            ViewBag.Departments = DepartmentBO.GetAll();
            ViewBag.Projects    = ProjectBO.GetAll();
        }
        public ActionResult Edit(UserModel model)
        {
            var user = UserBO.GetById(model.Id);

            if (user != null)
            {
                user.Avatar = model.Gender ? "/Content/img/avatar5.png" : "/Content/img/avatar3.png";
                DateTime date;
                if (DateTime.TryParseExact(model.DateOfBirth, "dd/MM/yyyy",
                                           new CultureInfo("en-US"),
                                           DateTimeStyles.None,
                                           out date))
                {
                    user.DateOfBirth = date;
                }

                UserBO.Update(user.Id, user.UserName, user.Password, model.FirstName, model.LastName, model.Address, user.DateOfBirth, model.Gender, model.DepartmentId, model.Email, model.Mission, user.Avatar, model.IsActive, model.IsAdmin, model.IsManager, user.CreateDate, DateTime.Now, user.CreateBy, CurrentUser.Id);
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "Edit not succeed");
            }
            ViewBag.Department = DepartmentBO.GetAll();
            return(View("Create", model));
        }
        public ActionResult Edit(int id)
        {
            ViewBag.CurrentUser = CurrentUser;
            ViewBag.Department  = DepartmentBO.GetAll();
            var user = UserBO.GetById(id);

            if (user == null)
            {
                return(RedirectToAction("NotFound", "Home"));
            }

            var model = new UserModel()
            {
                Id           = user.Id,
                UserName     = user.UserName,
                FirstName    = user.FirstName,
                LastName     = user.LastName,
                Password     = EncryptUtils.Decrypt(user.Password),
                Address      = user.Address,
                Avatar       = user.Avatar,
                DateOfBirth  = user.DateOfBirth.ToString("dd/MM/yyyy"),
                DepartmentId = user.DepartmentId,
                Gender       = user.Gender,
                Email        = user.Email,
                Mission      = user.Mission,
                IsActive     = user.IsActive,
                IsAdmin      = user.IsAdmin
            };

            return(View("Create", model));
        }
Beispiel #9
0
        public static bool UpdateDepartment(DepartmentBO departmentBO)
        {
            DeptDesigAndFinInstitutionDAS deptDesigAndFinInstitutionDAS = new DeptDesigAndFinInstitutionDAS();
            int numberOfRowImpacted = 0;

            numberOfRowImpacted = deptDesigAndFinInstitutionDAS.UpdateDepartment(departmentBO);
            return(numberOfRowImpacted > 0);
        }
Beispiel #10
0
        public bool PersonEditing_PreTransitionCRUD(string transition)
        {
            switch (transition)
            {
            case "Save":
                if (!ASPxEdit.AreEditorsValid(popup_PersonCreate))
                {
                    return(false);
                }
                Person person = session.GetObjectByKey <Person>(PersonId);
                {
                    person.Code      = txt_Code.Text;
                    person.Name      = txt_Name.Text;
                    person.RowStatus = Convert.ToInt16(Combo_RowStatus.SelectedItem.Value);
                };
                person.Save();

                var statementLoginAccounts = from la in person.LoginAccounts
                                             where la.RowStatus > 0 &&
                                             la.PersonId == person
                                             select la.LoginAccountId;

                foreach (TMPLoginAccount tmpAccount in Temp_LoginAccount)
                {
                    LoginAccount account;
                    if (statementLoginAccounts.Contains(tmpAccount.LoginAccountId))
                    {
                        account           = session.GetObjectByKey <LoginAccount>(tmpAccount.LoginAccountId);
                        account.Email     = tmpAccount.Email;
                        account.RowStatus = Utility.Constant.ROWSTATUS_ACTIVE;
                        account.Save();
                    }
                    else
                    {
                        account = new LoginAccount(session);
                        account.LoginAccountId       = Guid.NewGuid();
                        account.Email                = tmpAccount.Email;
                        account.RowStatus            = Utility.Constant.ROWSTATUS_ACTIVE;
                        account.RowCreationTimeStamp = DateTime.Now;
                        account.PersonId             = person;
                        account.Save();
                    }
                }

                // update Department
                List <TreeListNode> nodes = ASPxTreeList_OfDepartment.GetSelectedNodes();
                List <NAS.DAL.Nomenclature.Organization.Department> departmentList = new List <NAS.DAL.Nomenclature.Organization.Department>();
                foreach (TreeListNode n in nodes)
                {
                    NAS.DAL.Nomenclature.Organization.Department d = (NAS.DAL.Nomenclature.Organization.Department)n.DataItem;
                    departmentList.Add(d);
                }
                DepartmentBO bo = new DepartmentBO();
                bo.updatePerson(session, departmentList, PersonId, person.Code, person.Name, person.RowStatus);
                return(true);
            }
            return(false);
        }
Beispiel #11
0
        private bool DeleteAction()
        {
            bool result = false;

            switch (this.SelectedTypeCode)
            {
            case "DT":
                DepartmentBO department = new DepartmentBO();
                department.DepartmentCD = this.RequestCode;
                result = DeptDesigAndFinInstitutionBusController.RemoveDepartment(department);
                if (result)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Department Deleted Successfully')", true);
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Department Not Deleted. Some Problem Occurred')", true);
                }
                this.SelectedTypeCode = null;
                break;

            case "DS":
                DesignationBO designation = new DesignationBO();
                designation.DesignationCD = this.RequestCode;
                result = DeptDesigAndFinInstitutionBusController.RemoveDesignation(designation);
                if (result)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Designation Deleted Successfully')", true);
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Designation Not Deleted. Some Problem Occurred')", true);
                }
                this.SelectedTypeCode = null;
                break;

            case "FI":
                FinancialInstitutionBO financialInstitution = new FinancialInstitutionBO();
                financialInstitution.FinancialInstitutionCD = this.RequestCode;
                result = DeptDesigAndFinInstitutionBusController.RemoveFinancialInstitution(financialInstitution);
                if (result)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Financial Institution Deleted Successfully')", true);
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Financial Institution Not Deleted. Some Problem Occurred')", true);
                }
                this.SelectedTypeCode = null;
                break;

            default:
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Bad Request.')", true);
                break;
            }
            return(result);
        }
Beispiel #12
0
 protected void grd_ListUser_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
 {
     string[] para = e.Parameters.Split(',');
     if ((para[0].Equals("Refresh")))
     {
         loadListUsers(trlDepartmentMenu.FocusedNode);
     }
     if (para[0].Equals("Delete"))
     {
         string id = para.Count <string>() == 2 ? para[1] : String.Empty;
         if (id != "")
         {
             DepartmentBO checkID               = new DepartmentBO();
             bool         checkBill             = checkID.checkExistPersonInBill(session, Guid.Parse(id));
             bool         checkVouchesActor     = checkID.checkExistPersonInVouchesActor(session, Guid.Parse(id));
             bool         checkStock            = checkID.checkExistPersonInStockCartActor(session, Guid.Parse(id));
             bool         checkSpecialPrivilege = checkID.checkExistPersonInSpecialPrivilege(session, Guid.Parse(id));
             bool         checkBillActor        = checkID.checkExistPersonInBillActor(session, Guid.Parse(id));
             //bool checkDepartmentPerson = checkID.checkExistPersonInDepartmentPerson(session, Guid.Parse(id));
             //bool checkLoginAccount = checkID.checkExistPersonInLoginAccount(session, Guid.Parse(id));
             if (checkBill || checkVouchesActor || checkStock || checkSpecialPrivilege ||
                 checkBillActor)
             {
                 throw new Exception("Người dùng này không xóa được!");
             }
             else
             {
                 Person p = session.GetObjectByKey <Person>(Guid.Parse(id));
                 if (p != null)
                 {
                     CriteriaOperator criteria = new BinaryOperator("PersonId", p.PersonId, BinaryOperatorType.Equal);
                     XPCollection <DepartmentPerson> dpPersonCL = new XPCollection <DepartmentPerson>(session, criteria);
                     foreach (DepartmentPerson dpPerson in dpPersonCL)
                     {
                         if (dpPerson != null)
                         {
                             dpPerson.RowStatus = -1;
                             dpPerson.Save();
                         }
                     }
                     XPCollection <LoginAccount> lgAccountCL = new XPCollection <LoginAccount>(session, criteria);
                     foreach (LoginAccount lgAccount in lgAccountCL)
                     {
                         if (lgAccount != null)
                         {
                             lgAccount.RowStatus = -1;
                             lgAccount.Save();
                         }
                     }
                     p.RowStatus = -1;
                     p.Save();
                     loadListUsers(trlDepartmentMenu.FocusedNode);
                 }
             }
         }
     }
 }
Beispiel #13
0
 public DepartmentBO convertDeptBO(Department d)
 {
     dbo                     = new DepartmentBO();
     dbo.DeptId              = d.DepartmentID;
     dbo.DeptName            = d.DepartmentName;
     dbo.DeptRep             = d.RepID;
     dbo.DeptCollectionPoint = d.CollectionPointID;
     return(dbo);
 }
Beispiel #14
0
        public ActionResult Create(TasksModel model)
        {
            if (!CurrentUser.IsManager)
            {
                return(RedirectToAction("NotFound", "Home"));
            }

            if (!string.IsNullOrEmpty(model.Name))
            {
                var task = new Task();
                task.ProjectId   = model.ProjectId;
                task.Leader      = model.Leader;
                task.Name        = model.Name;
                task.Priority    = model.Priority;
                task.Description = model.Description;
                task.CreateBy    = CurrentUser.Id;
                task.ModifyBy    = CurrentUser.Id;
                task.CreateDate  = DateTime.Now;
                task.ModifyDate  = DateTime.Now;
                if (!string.IsNullOrEmpty(model.StartAndEndDate) && model.StartAndEndDate.Split('-').Length == 2)
                {
                    var      strStart = model.StartAndEndDate.Split('-')[0].Trim();
                    var      strEnd   = model.StartAndEndDate.Split('-')[1].Trim();
                    DateTime sdate;
                    DateTime edate;
                    if (DateTime.TryParseExact(strStart, Helper.FormatDate,
                                               new CultureInfo("en-US"),
                                               DateTimeStyles.None,
                                               out sdate))
                    {
                        task.StartDate = sdate;
                    }

                    if (DateTime.TryParseExact(strEnd, Helper.FormatDate,
                                               new CultureInfo("en-US"),
                                               DateTimeStyles.None,
                                               out edate))
                    {
                        task.EndDate = edate;
                    }

                    TaskBO.Insert(task);
                    var department = DepartmentBO.GetById(task.Leader);
                    if (department != null && department.UserId > 0)
                    {
                        AlertBO.Insert(task.Name, (int)AlertType.Task, 0, department.UserId);
                    }

                    //TODO ... Insert document
                }
                return(RedirectToAction("Index"));
            }

            PreparingData();
            return(View(model));
        }
Beispiel #15
0
        public ActionResult Create()
        {
            ViewBag.CurrentUser = CurrentUser;
            ViewBag.Department  = DepartmentBO.GetAll();
            var model = new UserModel {
                Gender = true, IsActive = true
            };

            return(View(model));
        }
Beispiel #16
0
 public void loadListUsers(TreeListNode node)
 {
     if (node != null)
     {
         NAS.DAL.Nomenclature.Organization.Department selectedDP = (NAS.DAL.Nomenclature.Organization.Department)node.DataItem;
         DepartmentBO  bo             = new DepartmentBO();
         List <Person> LoginPersonLST = bo.getAllPeopleInDepartments(session, selectedDP);
         grd_ListUser.DataSource = LoginPersonLST;
         grd_ListUser.DataBind();
     }
 }
Beispiel #17
0
        public static DepartmentPO MapDepartmentBOtoPO(DepartmentBO frmDepartmentBO)
        {
            DepartmentPO toDepartmentPO = new DepartmentPO();

            toDepartmentPO.DeptID                 = frmDepartmentBO.DeptID;
            toDepartmentPO.DeptName               = frmDepartmentBO.DeptName;
            toDepartmentPO.Description            = frmDepartmentBO.Description;
            toDepartmentPO.DeptHead               = frmDepartmentBO.DeptHead;
            toDepartmentPO.DeptHeadSpecialization = frmDepartmentBO.DeptHeadSpecialization;
            toDepartmentPO.AlumniCount            = frmDepartmentBO.AlumniCount;
            return(toDepartmentPO);
        }
Beispiel #18
0
        public static DepartmentBO GetDepartmentBO(DepartmentBO departmentBO)
        {
            DeptDesigAndFinInstitutionDAS deptDesigAndFinInstitutionDAS = new DeptDesigAndFinInstitutionDAS();
            string jsondata = deptDesigAndFinInstitutionDAS.GetDepartment(departmentBO);
            List <DepartmentBO> departmentBOs;

            if (!jsondata.StartsWith("DB_ERROR"))
            {
                departmentBOs = StringUtil.DeserializeObjectFromJSON <List <DepartmentBO> >(jsondata);
                departmentBO  = departmentBOs.ElementAt(0);
            }
            return(departmentBO);
        }
    public List <DepartmentBO> getDistictDepList()
    {
        List <Department>   dLst   = sdda.getDistinctDepList();
        List <DepartmentBO> dboLst = new List <DepartmentBO>();

        foreach (Department d in dLst)
        {
            DepartmentBO dbo = dbConversion.convertDeptBO(d);
            dboLst.Add(dbo);
        }

        return(dboLst);
    }
Beispiel #20
0
        protected void ASPxGridView_Person_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            e.Cancel = true;
            string id = e.Keys[ASPxGridView_Person.KeyFieldName].ToString();

            if (id.Equals("") || id != null)
            {
                DepartmentBO checkID               = new DepartmentBO();
                bool         checkBill             = checkID.checkExistPersonInBill(session, Guid.Parse(id));
                bool         checkVouchesActor     = checkID.checkExistPersonInVouchesActor(session, Guid.Parse(id));
                bool         checkStock            = checkID.checkExistPersonInStockCartActor(session, Guid.Parse(id));
                bool         checkSpecialPrivilege = checkID.checkExistPersonInSpecialPrivilege(session, Guid.Parse(id));
                bool         checkBillActor        = checkID.checkExistPersonInBillActor(session, Guid.Parse(id));
                //bool checkDepartmentPerson = checkID.checkExistPersonInDepartmentPerson(session, Guid.Parse(id));
                //bool checkLoginAccount = checkID.checkExistPersonInLoginAccount(session, Guid.Parse(id));
                if (checkBill || checkVouchesActor || checkStock || checkSpecialPrivilege ||
                    checkBillActor)
                {
                    throw new Exception("Người dùng này không xóa được!");
                }
                else
                {
                    Person p = session.GetObjectByKey <Person>(Guid.Parse(id));
                    if (p != null)
                    {
                        CriteriaOperator criteria = new BinaryOperator("PersonId", p.PersonId, BinaryOperatorType.Equal);
                        XPCollection <DepartmentPerson> dpPersonCL = new XPCollection <DepartmentPerson>(session, criteria);
                        foreach (DepartmentPerson dpPerson in dpPersonCL)
                        {
                            if (dpPerson != null)
                            {
                                dpPerson.RowStatus = -1;
                                dpPerson.Save();
                            }
                        }
                        XPCollection <LoginAccount> lgAccountCL = new XPCollection <LoginAccount>(session, criteria);
                        foreach (LoginAccount lgAccount in lgAccountCL)
                        {
                            if (lgAccount != null)
                            {
                                lgAccount.RowStatus = -1;
                                lgAccount.Save();
                            }
                        }
                        p.RowStatus = -1;
                        p.Save();
                        loadListUsers(ASPxTreeList_Department2.FocusedNode);
                    }
                }
            }
        }
Beispiel #21
0
        public void updatePerson(Person p)
        {
            List <TreeListNode> nodes = trlDepartment.GetSelectedNodes();
            List <NAS.DAL.Nomenclature.Organization.Department> departmentList = new List <NAS.DAL.Nomenclature.Organization.Department>();

            foreach (TreeListNode n in nodes)
            {
                NAS.DAL.Nomenclature.Organization.Department d = (NAS.DAL.Nomenclature.Organization.Department)n.DataItem;
                departmentList.Add(d);
            }
            DepartmentBO bo = new DepartmentBO();

            bo.updatePerson(session, departmentList, PersonId, p.Code, p.Name, p.RowStatus);
        }
 public ActionResult Delete(int departmentId)
 {
     if (DepartmentBO.GetById(departmentId) != null)
     {
         DepartmentBO.Delete(departmentId);
         return(RedirectToAction("Index"));
     }
     else
     {
         //ModelState.AddModelError("", "Có lỗi trong quá trình xóa");
         return(RedirectToAction("NotFound", "Home"));
     }
     return(View());
 }
Beispiel #23
0
        public static bool IsDepartmentPresent(DepartmentBO department)
        {
            DeptDesigAndFinInstitutionDAS deptDesigAndFinInstitutionDAS = new DeptDesigAndFinInstitutionDAS();
            string jsondata = deptDesigAndFinInstitutionDAS.GetDepartment(department);

            if (!jsondata.StartsWith("DB_ERROR"))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public ActionResult ViewAllDepartment()
        {
            ActionResult response = null;

            if (Session["RoleID"] != null)
            {
                if ((int)Session["RoleID"] == 1 || (int)Session["RoleID"] == 2 || (int)Session["RoleID"] == 3)
                {
                    List <DepartmentDO> departmentObjectList = DepartmentDataAccessLayer.ReadDepartment();

                    List <DepartmentBO> departmentBOList = new List <DepartmentBO>();
                    foreach (DepartmentDO objectList in departmentObjectList)
                    {
                        DepartmentBO mappedDepartmentBO = Mapper.MapDepartmentDOtoBO(objectList);
                        departmentBOList.Add(mappedDepartmentBO);
                    }
                    List <AlumniBO> alumniBOList     = new List <AlumniBO>();
                    AlumniDAL       alumniDataAccess = new AlumniDAL();

                    List <AlumniDO> alumniDAOList = alumniDataAccess.ReadAlumniRecord();
                    foreach (AlumniDO objectList in alumniDAOList)
                    {
                        AlumniBO mappedAlumniBO = Mapper.MapAlumniDOtoBO(objectList);
                        alumniBOList.Add(mappedAlumniBO);
                    }


                    List <DepartmentBO> departmentBOListCount = AlumniBusinessLogicLayer.LinkedToAlumniAndDepartment(departmentBOList, alumniBOList);

                    List <DepartmentPO> departmentList = new List <DepartmentPO>();
                    foreach (DepartmentBO objectList in departmentBOList)
                    {
                        DepartmentPO mappedDepartmentPO = Mapper.MapDepartmentBOtoPO(objectList);
                        departmentList.Add(mappedDepartmentPO);
                    }

                    response = View(departmentList);
                }
                else
                {
                    response = RedirectToAction("Index", "Home");
                }
            }
            else
            {
                response = RedirectToAction("Index", "Home");
            }
            return(response);
        }
Beispiel #25
0
        public List <DepartmentBO> getDepartmentList()
        {
            List <DepartmentBO> dbo = new List <DepartmentBO>();

            var query = (from x in context.Departments
                         select new { x.DepartmentID, x.DepartmentName }).ToList();

            foreach (var q in query)
            {
                DepartmentBO b = new DepartmentBO();
                b.DeptId   = q.DepartmentID;
                b.DeptName = q.DepartmentName;
                dbo.Add(b);
            }
            return(dbo);
        }
Beispiel #26
0
        protected void uc_btn_submit_Click(object sender, EventArgs e)
        {
            DepartmentBO department = new DepartmentBO();

            department.DepartmentName        = uc_txt_Name.Text;
            department.DepartmentBankAccount = uc_txt_BankAcc.Text;
            bool result = DeptDesigAndFinInstitutionBusController.AddDepartment(department);

            if (result)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Department Added Successfully')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Department Not Added. Some Problem Occurred')", true);
            }
        }
 public ActionResult Create(DepartmentModel model)
 {
     if (model != null && Validate(model))
     {
         if (Validate(model))
         {
             DepartmentBO.Create(model.Name, model.UserId, DateTime.Now, DateTime.Now, CurrentUser.Id, CurrentUser.Id);
             return(RedirectToAction("Index"));
         }
     }
     else
     {
         ModelState.AddModelError("", "Create deparment not succeed");
         return(RedirectToAction("Create"));
     }
     return(View(model));
 }
 public ActionResult Edit(DepartmentModel model)
 {
     if (DepartmentBO.GetById(model.Id) != null)
     {
         if (Validate(model))
         {
             DepartmentBO.Update(model.Id, model.Name, model.UserId, DateTime.Now, DateTime.Now, CurrentUser.Id, CurrentUser.Id);
             return(RedirectToAction("Index"));
         }
     }
     else
     {
         return(RedirectToAction("NotFound", "Home"));
     }
     ViewBag.ListUsers = UserBO.GetAll();
     return(View(model));
 }
Beispiel #29
0
        private void EditAction()
        {
            string postbackurl = ResourceTable("PageURL");

            switch (this.SelectedTypeCode)
            {
            case "DT":
                DepartmentBO department = new DepartmentBO();
                department.DepartmentCD = this.RequestCode;
                department                  = DeptDesigAndFinInstitutionBusController.GetDepartmentBO(department);
                lbl_Dept_title.Text         = ResourceTable("EditDept");
                this.txtDeptName.Text       = department.DepartmentName;
                this.txtBankAcc.Text        = department.DepartmentBankAccount;
                postbackurl                += "?CD=" + StringUtil.Encode(department.DepartmentCD);
                this.btnAddDept.PostBackUrl = postbackurl;
                this.btnAddDept.Text        = ResourceTable("StringUpdate");
                break;

            case "DS":
                DesignationBO designation = new DesignationBO();
                designation.DesignationCD = this.RequestCode;
                designation                  = DeptDesigAndFinInstitutionBusController.GetDesignationBO(designation);
                lbl_Desig_title.Text         = ResourceTable("EditDesig");
                this.txtDesigName.Text       = designation.DesignationName;
                postbackurl                 += "?CD=" + StringUtil.Encode(designation.DesignationCD);
                this.btnDesigAdd.PostBackUrl = postbackurl;
                this.btnDesigAdd.Text        = ResourceTable("StringUpdate");
                break;

            case "FI":
                FinancialInstitutionBO financialInstitution = new FinancialInstitutionBO();
                financialInstitution.FinancialInstitutionCD = this.RequestCode;
                financialInstitution        = DeptDesigAndFinInstitutionBusController.GetFinancialInstitutionBO(financialInstitution);
                lbl_Fin_title.Text          = ResourceTable("EditFin");
                this.txtFinInstName.Text    = financialInstitution.FinancialInstitutionName;
                this.txtFinInstAddress.Text = financialInstitution.FinancialInstitutionAddress;
                postbackurl += "?CD=" + StringUtil.Encode(financialInstitution.FinancialInstitutionCD);
                this.btnFinInstAdd.PostBackUrl = postbackurl;
                this.btnFinInstAdd.Text        = ResourceTable("StringUpdate");
                break;

            default:
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Bad Request.')", true);
                break;
            }
        }
Beispiel #30
0
        public ActionResult Index(UserSearchModel searchModel)
        {
            var listUser = new List <UserDisplayModel>();

            if (searchModel == null)
            {
                searchModel = new UserSearchModel();
            }

            var departments = new List <Department>();

            departments.Add(new Department {
                Id = 0, Name = "--- All ---"
            });
            departments.AddRange(DepartmentBO.GetAll());
            ViewBag.Departments = departments;
            var users = UserBO.Search(searchModel.UserName, searchModel.FullName, searchModel.DepartmentId);

            foreach (var item in users)
            {
                var department = DepartmentBO.GetById(item.DepartmentId);
                var model      = new UserDisplayModel
                {
                    Id             = item.Id,
                    UserName       = item.UserName,
                    FirstName      = item.FirstName,
                    LastName       = item.LastName,
                    Password       = item.Password,
                    Address        = item.Address,
                    Avatar         = item.Avatar,
                    DateOfBirth    = item.DateOfBirth.ToString("dd/MM/yyyy"),
                    DepartmentId   = item.DepartmentId,
                    DepartmentName = department == null? string.Empty : department.Name,
                    Gender         = item.Gender,
                    Email          = item.Email,
                    Mission        = item.Mission,
                    IsActive       = item.IsActive,
                    IsAdmin        = item.IsAdmin,
                    CreatedDate    = item.CreateDate == null ? string.Empty : ((DateTime)item.CreateDate).ToString(Helper.FormatDate),
                };
                listUser.Add(model);
            }

            searchModel.Users = listUser;
            return(View(searchModel));
        }