Example #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ClientEntity client = Session[PageInfo.SessionKey_Client] as ClientEntity;
         if (client == null)
         {
             Response.Redirect(PageInfo.PathClientLogin + Request.Url.ToString());
             return;
         }
         else if (client.Role.RoleName.Equals(PageInfo.RoleTypeAdmin))
         {
             Response.Write("<script>alert('你没有权限!');  window.location.href = " + PageInfo.PathDefaultPage + "</script>");
             return;
         }
         else if (client.Role.RoleName.Equals(PageInfo.RoleTypeSuperAdmin))
         {
             IList <RoleEntity> roles = new RoleService().GetAllRoles();
             foreach (var role in roles)
             {
                 this.DropDownListRole.Items.Add(new ListItem(role.Description, role.RoleName));
             }
             IList <CatalogEntity> catalogs = new CatalogService().getAll();
             foreach (var catalog in catalogs)
             {
                 this.CheckBoxListCatalog.Items.Add(new ListItem(catalog.CatalogName));
             }
             IList <DepartmentEntity> departments = new DepartmentDao().getAllDepartments();
             foreach (var department in departments)
             {
                 this.DropDownListDepartment.Items.Add(new ListItem(department.Description, department.DepartmentName));
             }
         }
     }
 }
Example #2
0
        public void initAdminClient()
        {
            ClientDao    dao  = new ClientDao();
            ClientEntity temp = dao.getClientByUsername("admin");

            if (temp != null)
            {
                dao.DeleteClient("admin");
            }


            ClientEntity  client        = new ClientEntity();
            RoleDao       roleDao       = new RoleDao();
            DepartmentDao departmentDao = new DepartmentDao();

            client.Username = "******";
            client.Password = "******";
            client.RealName = "yangtf";

            client.Role       = roleDao.getByName("superadmin");
            client.Department = departmentDao.getByName("6");
            client.encryptPassword();

            IList <CatalogEntity> catalogs = new CatalogDao().getAll();

            client.Catalogs = catalogs;


            dao.save(client);
        }
Example #3
0
        private string Service_ContentFormLoad(object sender, ContentFormLoadEventArgs e)
        {
            if (e.AttributeName == ContentAttribute.DepartmentId)
            {
                var departmentId = e.Form.GetString(nameof(ContentAttribute.DepartmentId));

                var ddlDepartmentId = new DropDownList
                {
                    ID       = ContentAttribute.DepartmentId,
                    CssClass = "form-control"
                };

                var departmentInfoList = DepartmentDao.GetDepartmentInfoList();

                foreach (var departmentInfo in departmentInfoList)
                {
                    var listItem = new ListItem(departmentInfo.DepartmentName, departmentInfo.Id.ToString());
                    ddlDepartmentId.Items.Add(listItem);
                }
                Utils.SelectSingleItem(ddlDepartmentId, departmentId);

                return($@"
<div class=""form-group form-row"">
    <label class=""col-sm-1 col-form-label text-right"">提交部门</label>
    <div class=""col-sm-6"">
        {Utils.GetControlRenderHtml(ddlDepartmentId)}
    </div>
    <div class=""col-sm-5"">

    </div>
</div>");
            }

            return(string.Empty);
        }
        public IHttpActionResult Insert()
        {
            try
            {
                var request = Context.GetCurrentRequest();
                var siteId  = request.GetQueryInt("siteId");
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(siteId, ApplicationUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var departmentInfo = new DepartmentInfo
                {
                    Id             = 0,
                    SiteId         = siteId,
                    DepartmentName = request.GetPostString("departmentName"),
                    UserNames      = request.GetPostString("userNames").Trim(','),
                    Taxis          = request.GetPostInt("taxis")
                };

                departmentInfo.Id = DepartmentDao.Insert(departmentInfo);

                return(Ok(new
                {
                    Value = departmentInfo
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //Setting up objects as needed
                var depDao =
                    new DepartmentDao(Properties.Settings.Default.conString);
                var dept = depDao.GetDepartments();

                //Adding departments to a list using a foreach loop
                foreach (Department d in dept)
                {
                    ListItem l = new ListItem(d.Name,
                                              depDao.GetDepartmentId(d.Name).ToString());
                    drpDepartment.Items.Add(l);
                }

                //Setting the dropdown to the list of departments as well as selecting
                //a default value from the start
                drpDepartment.DataTextField  = "Name";
                drpDepartment.DataValueField = "Id";
                drpDepartment.DataSource     = dept;
                drpDepartment.DataBind();
                drpDepartment.SelectedIndex = 0;
                drpDepartment.SelectedIndex = 0;
            }
        }
Example #6
0
    private void PopulateControls()
    {
        string departmentId = Request.QueryString["DepartmentID"];
        string categoryId   = Request.QueryString["CategoryID"];

        if (categoryId != null)
        {
            // Retrieve category and department details and display them
            Category cd = CatalogAccess.GetCategoryDetails(categoryId);
            catalogTitleLabel.Text = HttpUtility.HtmlEncode(cd.Name);
            DepartmentDao dao        = new DepartmentDao();
            Department    department = dao.Find(departmentId);
            catalogDescriptionLabel.Text = HttpUtility.HtmlEncode(cd.Description);

            this.Title = HttpUtility.HtmlEncode(CdShopConfiguration.SiteName + ": " + department.Name + ": " + cd.Name);
        }
        else if (departmentId != null)
        {
            DepartmentDao dao        = new DepartmentDao();
            Department    department = dao.Find(departmentId);
            catalogTitleLabel.Text       = HttpUtility.HtmlEncode(department.Name);
            catalogDescriptionLabel.Text = HttpUtility.HtmlEncode(department.Description);
            // Set the title of the page
            this.Title = HttpUtility.HtmlEncode(CdShopConfiguration.SiteName + ": " + department.Name);
        }
    }
Example #7
0
        public List <User> findUserListByDepartmentId(int departmentId, string departmentName)
        {
            List <User> userList   = new List <User>();
            Department  department = new Department();

            department.Name = departmentName; // 传参,减少内部的new Department 操作

            DataSet dataset = DepartmentDao.GetInstance().findUserListByDepartmentId(departmentId);

            if ((dataset != null) && (dataset.Tables[0].Rows.Count > 0))
            {
                for (int i = 0; i < dataset.Tables[0].Rows.Count; i++)
                {
                    User user = new User();
                    user.Name       = dataset.Tables[0].Rows[i]["name"].ToString().Trim();
                    user.Id         = Convert.ToInt32(dataset.Tables[0].Rows[i]["id"].ToString());
                    user.Department = department;

                    if (Convert.ToInt32(dataset.Tables[0].Rows[i]["id"].ToString()) == 1) // 1 -- 男  2--女
                    {
                        user.Sex = "男";
                    }
                    else
                    {
                        user.Sex = "女";
                    }
                    user.Telephone = dataset.Tables[0].Rows[i]["telephone"].ToString().Trim();
                    user.Remarks   = dataset.Tables[0].Rows[i]["remarks"].ToString().Trim();
                    userList.Add(user);
                }
            }
            return(userList);
        }
Example #8
0
        public JsonResult Delete(string listDeputy, string id, string dep)
        {
            if (dep == null || dep == "")
            {
                dep = mEmployee.employee.departmentName;
            }

            var updateDeputy = new DepartmentDao().UpdateDeputy(dep, listDeputy);
            // check and delete permisstion
            var check  = new DepartmentDao().CheckApprovalPermisstion(id);
            var result = true;

            if (!check) // if not exists in deputy list or head => delete permisstion approval
            {
                result = new UserDao().DeleteUserRole(id, 3);
            }
            if (updateDeputy && result)
            {
                return(Json(new { status = true }));
            }
            else
            {
                return(Json(new { status = false }));
            }
        }
Example #9
0
        public JsonResult AddUser(string userId, string dep)
        {
            if (dep == null || dep == "")
            {
                dep = mEmployee.employee.departmentName;
            }
            var checkUser = adWebHelper.GetDetailUserInfo(mEmployee.employee.access_token, userId.Trim());

            if (checkUser != null)
            {
                // Insert user to database
                InsertOrUpdateUser(checkUser);
                GrantPermisstion(checkUser.ad_user_employeeID, 3);

                // Insert new user to deputy list
                var listDepartment = new DepartmentDao().GetListDeputyByDepartment(dep);
                if (listDepartment == null || listDepartment == "")
                {
                    listDepartment = userId;
                }
                else if (!listDepartment.Contains(userId))
                {
                    listDepartment = listDepartment + ";" + userId;
                }
                var updateResult = new DepartmentDao().UpdateDeputy(dep, listDepartment);
                if (updateResult)
                {
                    return(Json(new { result = true }));
                }
            }
            return(Json(new { result = false }));
        }
Example #10
0
        private void RemoveDepartment(DEPARTMENT d)
        {

            DepartmentDao.Instace().Delete(d.DEPT_ID);
            DeparmentLists = null;
            DeparmentLists= new ObservableCollection<DEPARTMENT>(DepartmentDao.Instace().getAll());
        }
Example #11
0
        private void FindDepartment(FrameworkElement p)
        {
            string id = "";
            if (p != null)
            {
                var fe = p as Grid;
                if (fe != null)
                {
                    foreach (var item in fe.Children)
                    {
                        var tx = item as TextBox;
                        if (tx != null)
                        {
                            if (tx.Name.Equals("txtSearch"))
                            {
                                id = tx.Text;
                            }
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(id))
                DeparmentLists = new ObservableCollection<DEPARTMENT>(DepartmentDao.Instace().getListByName(id));
            else
                DeparmentLists = new ObservableCollection<DEPARTMENT>(DepartmentDao.Instace().getAll());

        }
Example #12
0
        public ActionResult Representative(int representativeId)
        {
            int departmentId = Convert.ToInt32(RouteData.Values["departmentId"]);

            DepartmentDao.UpdateDepartmentRepresentative(representativeId, departmentId);
            return(RedirectToAction("Delegate"));
        }
Example #13
0
      private void OKevent(Window p)
      {
          EMPLOYEE em = new EMPLOYEE();

          em.FIRST_NAME         = EmployeeViewObj.first_name;
          em.LAST_NAME          = EmployeeViewObj.last_name;
          em.TITLE              = EmployeeViewObj.title;
          em.START_DATE         = EmployeeViewObj.start_date;
          em.END_DATE           = EmployeeViewObj.end_date;
          em.ASSIGNED_BRANCH_ID = BranchDao.Instance().SelectbyName(EmployeeViewObj.branch).BRANCH_ID;
          em.DEPT_ID            = DepartmentDao.Instace().SelectbyName(EmployeeViewObj.department).DEPT_ID;
          em.SUPERIOR_EMP_ID    = null;
          if (cv == "insert")
          {
              EmployeeDao.Instance().Insert(em);
              evm.EmployeeViewLists = evm.UpdateListview();
          }
          else
          {
              em.EMP_ID = EmployeeViewObj.id;
              EmployeeDao.Instance().Update(em);
              evm.EmployeeViewLists = evm.UpdateListview();
          }
          p.Close();
      }
        public async Task <Result> GetOrderList(In inData)
        {
            DBHelper   db            = new DBHelper();
            List <int> position_list = await PositionDao.GetChildId(db, inData.user.position_id);

            position_list.Add(inData.user.position_id);
            position_list = position_list.Distinct().ToList();
            List <t_procurement> order_list = await ProcurementDao.GetList(db, position_list.ToArray());

            List <OrderItemResult> order_result_list = new List <OrderItemResult>();

            foreach (var item in order_list)
            {
                order_result_list.Add(new OrderItemResult
                {
                    add_time        = item.add_time.ToString("yyyy-MM-dd HH:mm:ss"),
                    department_name = await DepartmentDao.GetDepartmentName(db, item.department_id),
                    position_name   = await Dao.User.PositionDao.GetPositionName(db, item.position_id),
                    name            = await UserDao.GetUserRealName(db, item.id),
                    order_sn        = item.order_sn,
                    remark          = item.remark,
                    status          = item.status
                });
            }

            Result <List <OrderItemResult> > result = new Result <List <OrderItemResult> > {
                result = true, msg = "OK", data = order_result_list
            };

            return(result);
        }
Example #15
0
        public ActionResult Index(string Department)
        {
            List <tbl_User> listDeputy = null;
            var             deputyList = "";
            // For admin config
            SelectList groupList = new SelectList((IEnumerable)GetDepartMent(), "Value", "Value");

            ViewBag.GroupList = groupList;

            if (Department == null || Department == "")
            {
                Department = mEmployee.employee.departmentName;
            }

            ViewBag.HeadName   = new DepartmentDao().GetHeadIdByDepartment(Department);
            ViewBag.Department = Department;
            deputyList         = new DepartmentDao().GetListDeputyByDepartment(Department);
            // add to user
            // add list deputy
            if (deputyList != null && deputyList != "")
            {
                var listUser = deputyList.Split(';').ToList();
                listDeputy = new UserDao().GetListUser(listUser);
            }
            ViewBag.ListDeputy = listDeputy;
            return(View());
        }
Example #16
0
        public ActionResult PickupPoint(int pickupPointId)
        {
            int departmentId = Convert.ToInt32(RouteData.Values["departmentId"]);

            DepartmentDao.UpdatePickUpPoint(departmentId, pickupPointId);
            return(RedirectToAction("Delegate"));
        }
Example #17
0
        public ActionResult CreateRequest()
        {
            // Create GUIID
            Guid idRequest = Guid.NewGuid();

            CreateRequestModel newRequest = new CreateRequestModel();

            newRequest.Id         = idRequest;
            newRequest.EmployeeId = mEmployee.employee.employee_id;
            var employeeInfor = adWebHelper.GetDetailUserInfo(mEmployee.employee.access_token, mEmployee.employee.employee_id);

            newRequest.SLM      = adWebHelper.GetDetailUserInfoByID(mEmployee.employee.access_token, Convert.ToInt32(employeeInfor.parent_id[0].ToString())).ad_user_displayName;
            newRequest.FullName = mEmployee.employee.display_name;
            // Approver Information
            List <tbl_User> listApproval = null;
            var             listApprov   = new DepartmentDao().GetApproverName(mEmployee.employee.departmentName);

            if (listApprov != null && listApprov != "")
            {
                var listUser = listApprov.Split(';').ToList();
                listApproval = new UserDao().GetListUser(listUser);
            }
            ViewBag.ApproverName = string.Join("; ", listApproval.Select(x => x.FullName.ToString()).ToArray());

            // Information the requester

            return(View(newRequest));
        }
Example #18
0
 private void NewEditForm()
 {
     DepartmentEdit depart = new DepartmentEdit("insert", this);
     depart.txtDepID.Text = (DepartmentDao.Instace().GetLastID() + 1).ToString();
     depart.txtDepID.IsReadOnly = true;
     depart.Show();       
 }
        public ActionResult Delete(string ma)
        {
            bool status = false;

            status = new DepartmentDao().Delete(ma);
            return(Json(new { status = status }, JsonRequestBehavior.AllowGet));
        }
Example #20
0
        public void SetViewDepartment(int?selectedId = null)
        {
            var session = (UserLogin)Session[CommonConstants.USER_SESSION];

            var dao = new DepartmentDao();

            ViewBag.Department_ID = new SelectList(dao.ListDepartment(session.DepartmentID), "ID", "Name", selectedId);
        }
 public void Delete(string departmentID)
 {
     using (PersistentManager pm = new PersistentManager())
     {
         DepartmentDao departmentDao = new DepartmentDao();
         departmentDao.DeleteEntity(departmentID);
     }
 }
Example #22
0
 /// <summary>
 /// Constructor
 /// </summary>
 public DepartmentVM()
 {
     DeparmentLists = new ObservableCollection<DEPARTMENT>(DepartmentDao.Instace().getAll());
     FindCommand = new RelayCommand<FrameworkElement>((p) => { return p != null ? true : false; }, (p) => { FindDepartment(p); });
     EditFormCommand = new RelayCommand<DEPARTMENT>((p) => true, (p) => { ShowEditForm(p); });
     DeleteRowCommand = new RelayCommand<DEPARTMENT>((p) => true, (p) => { RemoveDepartment(p); });
     NewFormCommand = new RelayCommand<Window>((p) => true , (p) => { NewEditForm(); });
 }
 public void Save(string departmentID, string departmentName, string remark)
 {
     using (PersistentManager pm = new PersistentManager())
     {
         DepartmentDao departmentDao = new DepartmentDao();
         departmentDao.UpdateEntity(departmentID, departmentName, remark);
     }
 }
 public void Insert(string departmentName, string remark)
 {
     using (PersistentManager pm = new PersistentManager())
     {
         DepartmentDao departmentDao = new DepartmentDao();
         departmentDao.InsertEntity(departmentName, remark);
     }
 }
Example #25
0
 public int GetRowCount(string filter)
 {
     using (PersistentManager persistentManager = new PersistentManager())
     {
         DepartmentDao dao = new DepartmentDao();
         return(dao.GetRowCount(strTableView, filter));
     }
 }
Example #26
0
 public DataSet QueryDepartment(int pageIndex, int pageSize, string filter, string OrderByFields)
 {
     using (PersistentManager persistentManager = new PersistentManager())
     {
         DepartmentDao dao = new DepartmentDao();
         return(dao.Query(strTableView, strPrimaryKey, strQueryFields, pageIndex, pageSize, OrderByFields, filter, strTableView));
     }
 }
Example #27
0
 public string GetNewDeptCode()
 {
     using (PersistentManager persistentManager = new PersistentManager())
     {
         DepartmentDao dao = new DepartmentDao();
         return(dao.GetNewDeptCode());
     }
 }
Example #28
0
        public ActionResult Index(string searchString, int page = 1, int pageSize = 10)
        {
            var dao   = new DepartmentDao();
            var model = dao.ListAllPaging(searchString, page, pageSize);

            ViewBag.SearchString = searchString;

            return(View(model));
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         DepartmentDao dao = new DepartmentDao();
         list.DataSource = dao.GetAll();
         list.DataBind();
     }
 }
Example #30
0
    // Populate the GridView with data
    private void BindGrid()
    {
        // Get a DataTable object containing the catalog departments
        DepartmentDao dao = new DepartmentDao();

        grid.DataSource = dao.GetAll();
        // Bind the data bound controls to the data source
        grid.DataBind();
    }