示例#1
0
        public User fillUserEntity(string email, string password)
        {
            userEntity = new User();
            if (checkLogIn(email, password))
            {
                //Call to every methods to collect data needed
                user userData = getUserData(email, password);

                //Fill to customize entity from data
                userEntity.UserID = userData.userId;
                userEntity.UserName = userData.name;
                //userEntity.PhoneNo = userData.phoneNo;
                userEntity.Email = userData.email;
                userEntity.Address = userData.address;
                userEntity.DepartmentId = userData.departmentId;
                userEntity.RoleId = userData.roleId;
                userEntity.Password = userData.password;
                role roleData = getRoleData(userData.roleId);
                userEntity.RoleName = roleData.name;
                //get department data
                department departmentData = getDepartmentData(userData.departmentId);
                userEntity.DepartmentName = departmentData.name;
            }
            return userEntity;
        }
示例#2
0
 public User getCurrentDelegateGF(string departmentId)
 {
     user x = ctx.users.FirstOrDefault(o => o.roleId == "d104" && o.departmentId == departmentId);
     if (x != null)
     {
         User u = new User();
         u.UserID = x.userId;
         u.UserName = x.name;
         u.PhoneNo = x.phoneNo;
         u.Email = x.email;
         u.Address = x.address;
         u.DepartmentId = x.departmentId;
         u.RoleId = x.roleId;
         u.Password = x.password;
         if (x.roleId == "d104")
         {
             u.StartDate = Convert.ToDateTime(x.startDate);
             u.EndDate = Convert.ToDateTime(x.endDate);
         }
         else
         {
             u.StartDate = DateTime.Now;
             u.EndDate = DateTime.Now;
         }
         u.DepartmentName = x.department.name;
         u.RoleName = x.role.name;
         return u;
     }
     else {
         return null;
     }
 }
示例#3
0
        public List<User> getAllUserByDepartmentIdGF(string departmentId)
        {
            var item = from a in ctx.users
                       where a.departmentId == departmentId
                       select new
                       {
                           UserID = a.userId,
                           UserName = a.name,
                           PhoneNo = a.phoneNo,
                           Email = a.email,
                           Address = a.address,
                           DepartmentId = a.departmentId,
                           RoleId = a.roleId,
                           Password = a.password
                       };

            List<User> list = new List<User>();
            foreach (var x in item)
            {
                User u = new User();
                u.UserID = x.UserID;
                u.UserName = x.UserName;
                u.PhoneNo = x.PhoneNo;
                u.Email = x.Email;
                u.Address = x.Address;
                u.DepartmentId = x.DepartmentId;
                u.RoleId = x.RoleId;
                u.Password = x.Password;
                list.Add(u);
            }
            return list;
            //gaofan
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            userEntity = (User)Session["UserEntity"];

            assignRepresentativeController = new AssignRepresentativeController();

               //userCollection = assignRepresentativeController.loadController("CPSC");//TODO

            dataBind();
        }
示例#5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["UserEntity"] != null)
     {
         userEntity = (User)Session["UserEntity"];
         userRole = userEntity.RoleId;
         this.aUserName.InnerHtml = " : "+userEntity.UserName;
         this.aDepartmentName.InnerHtml = userEntity.DepartmentName;
         PopulateRootLevel();
         Context.GetOwinContext().Authentication.SignIn();
     }
     else
     {
         Response.Redirect("~/WebPages/Login/Login.aspx");
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            changeCollectionPointController = new ChangeCollectionPointController();

            userEntity = (User)Session["UserEntity"];

            if(!IsPostBack)
            {

                collectionPointCollection = changeCollectionPointController.loadCollectionPointList();
                Session["collectionPointCollection"] = collectionPointCollection;

                string userRole = userEntity.RoleName;
                if (userRole == "storeClerk")
                {
                    departmentCollection = changeCollectionPointController.loadDepartmentList();
                    Session["departmentCollection"] = departmentCollection;
                    var de = departmentCollection.Select(d => new { d.DepartmentName }).ToList();
                    List<string> depNameString = new List<string>();
                    foreach (var d in de)
                    {
                        depNameString.Add(d.DepartmentName);
                    }

                    DepartmentDropDownList.DataSource = depNameString.ToList();
                    DepartmentDropDownList.DataBind();
                    DepartmentDropDownList.Visible = true;
                }
                else
                {
                    colId = changeCollectionPointController.selectCollectionPoint(userEntity.DepartmentId);
                    Session["colId"] = colId;
                    DepartmentDropDownList.Visible = false;
                }

                CollectionPointGridView.ForeColor = Color.Black;
                CollectionPointGridView.DataSource = collectionPointCollection;
                CollectionPointGridView.DataBind();

            }
            else
            {
                departmentCollection = (List<Department>)Session["departmentCollection"];
                collectionPointCollection = (List<CollectionPoint>)Session["collectionPointCollection"];
            }
        }
示例#7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            userEntity = (User)Session["UserEntity"];
            userId = userEntity.UserID;
            userRole = userEntity.RoleName;
            //departmentId = userEntity.DepartmentId;

            //string userRole = Convert.ToString(Session["userRole"]);
            if(!IsPostBack)
            {
                List<ListItem> list = new List<ListItem>();

                if (userRole == "storeClerk")
                {
                    DepartmentDropDownList.DataSource = controller.acceptDepartmentList();
                    DepartmentDropDownList.DataBind();

                    list.Add(new ListItem("Approved"));
                    list.Add(new ListItem("In Progress"));
                    list.Add(new ListItem("Outstanding"));
                }
                else
                {
                    DepartmentDropDownList.Visible = false;
                    DepLab.Visible = false;

                    list.Add(new ListItem("Approved"));
                    list.Add(new ListItem("Rejected"));
                    list.Add(new ListItem("Cancelled"));
                    list.Add(new ListItem("In Progress"));
                    list.Add(new ListItem("Outstanding"));
                    list.Add(new ListItem("Completed"));
                }

                //StatusDropDownList.DataSource = list;
                //StatusDropDownList.DataBind();
                StatusRadioButtonList.DataSource = list;
                StatusRadioButtonList.DataBind();

            }
        }
示例#8
0
        public List<User> getUsersWithRole(string roleName)
        {
            List<User> userCollection = new List<User>();

            try
            {
                var users = from u in ctx.users
                         where
                           u.roleId ==
                            ((from r in ctx.roles
                              where
                                r.name == roleName
                              select new
                              {
                                  r.roleId
                              }).FirstOrDefault().roleId)

                              && u.status == "Active"
                         select new
                         {
                             uid = u.userId,
                             name = u.name,
                             email = u.email,
                             start = u.startDate,
                             end = u.endDate,
                         };

                foreach(var u in users)
                {
                    User user = new User();
                    user.UserID = u.uid;
                    user.UserName = u.name;
                    user.Email = u.email;
                    if(roleName=="departmentDeputy")
                    {
                        user.StartDate = (DateTime)u.start.Value;
                        user.EndDate = (DateTime)u.end.Value;
                    }
                    userCollection.Add(user);
                }
            }
            catch (Exception exception)
            {
                errorobj.WriteErrorLog("UserFacade-getUsersWithRole():::" + exception.ToString());
                userCollection = new List<User>();
            }
            return userCollection;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            userEntity = (User)Session["UserEntity"];
            userId = userEntity.UserID;
            departmentId = userEntity.DepartmentId;
            /*if (Session["UserId"] != null)
            {
                userId = Convert.ToString(Session["UserId"]);
            }*/

            departmentId = sRController.getDepartmentId(userId);

            date = Convert.ToDateTime(System.DateTime.Now.ToShortDateString());
            lblRequisitionDate.Text = date.ToString();

            if (!this.IsPostBack)
            {
                setAsDefault();
            }
        }
示例#10
0
        public User getManagerGF()
        {
            user x = ctx.users.FirstOrDefault(o => o.roleId == "d104");
            User u = new User();
            if (x != null)
            {

                u.UserID = x.userId;
                u.UserName = x.name;
                u.PhoneNo = x.phoneNo;
                u.Email = x.email;
                u.Address = x.address;
                u.DepartmentId = x.departmentId;
                u.RoleId = x.roleId;
                u.Password = x.password;
                if (x.roleId == "d104")
                {
                    u.StartDate = Convert.ToDateTime(x.startDate);
                    u.EndDate = Convert.ToDateTime(x.endDate);
                }
                else
                {
                    u.StartDate = DateTime.Now;
                    u.EndDate = DateTime.Now;
                }
                u.DepartmentName = x.department.name;
                u.RoleName = x.role.name;
                return u;
            }
            else
            {
                user m = ctx.users.FirstOrDefault(o => o.roleId == "d103");
                u.UserID = m.userId;
                u.UserName = m.name;
                u.PhoneNo = m.phoneNo;
                u.Email = m.email;
                u.Address = m.address;
                u.DepartmentId = m.departmentId;
                u.RoleId = m.roleId;
                u.Password = m.password;
                if (x.roleId == "d104")
                {
                    u.StartDate = Convert.ToDateTime(x.startDate);
                    u.EndDate = Convert.ToDateTime(x.endDate);
                }
                else
                {
                    u.StartDate = DateTime.Now;
                    u.EndDate = DateTime.Now;
                }
                u.DepartmentName = m.department.name;
                u.RoleName = m.role.name;
                return u;
            }
        }
示例#11
0
        // modify in 3/11
        protected void SelectGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "AddToTable")
            {
                int index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row = SelectGridView.Rows[index];

                TextBox t = ((TextBox)row.Cells[6].FindControl("TextBox1"));
                int num;
                if (!(int.TryParse(t.Text.ToString(), out num)))
                {
                    row.ForeColor = Color.Red;
                    //Statement.Text = "You need to enter an integer";
                    this.Message("You need to enter an integer");
                }
                else if (Convert.ToInt32(t.Text) < 1)
                {
                    row.ForeColor = Color.Red;
                    //Statement.Text = "Quantity cannot be zero ";
                    this.Message("Quantity cannot be zero ");
                }
                else
                {
                    //Statement.Text = "";
                    row.ForeColor = Color.Black;
                    string itemName = controller.ConvertName(row.Cells[0].Text);
                    int qty = Convert.ToInt16(((TextBox)row.Cells[6].FindControl("TextBox1")).Text);
                    string supplierName = ((DropDownList)row.Cells[7].FindControl("SupplierDropDownList")).SelectedValue;
                    double price = controller.selectAddtoOrder(itemName, supplierName);
                    double amount = qty * price;

                    userEntity = (User)Session["UserEntity"];
                    ReorderItem r = new ReorderItem();
                    r.ItemName = itemName;
                    r.UserId = userEntity.UserID;
                    r.QtyToOrder = qty;
                    r.SupplierName = supplierName;
                    r.Price = Convert.ToDouble(price);
                    r.Amount = Convert.ToDouble(amount);
                    List<ReorderItem> orderList = new List<ReorderItem>();
                    int Index = 0;
                    if (Session["orderList"] != null)
                    {
                        orderList = (List<ReorderItem>)Session["orderList"];
                        bool flag = false;

                        for (int i = 0; i < orderList.Count; i++)
                        {
                            if (orderList[i].ItemName.Equals(itemName) && orderList[i].SupplierName.Equals(supplierName))
                            {
                                flag = true;
                                Index = i;
                            }
                        }
                        if (flag == false)
                        {
                            orderList.Add(r);
                        }
                        else
                        {
                            ReorderItem ri = orderList[Index];
                            ri.QtyToOrder = ri.QtyToOrder + qty;
                            ri.Amount = (ri.QtyToOrder + qty) * price;
                        }
                    }
                    else
                    {
                        orderList.Add(r);
                    }
                    Session["orderList"] = orderList;

                    UpdateGridView.DataSource = orderList;
                    UpdateGridView.DataBind();
                    SubmitBtn.Visible = true;
                }

            }
        }
示例#12
0
 public void updateUserRoleIdByNameGF(User u)
 {
     user x = ctx.users.FirstOrDefault(o => o.name == u.UserName);
     x.roleId = "d103";
     ctx.SaveChanges();
     //gaofan
 }
示例#13
0
 public void updateUserGF(User u)
 {
     user us = ctx.users.FirstOrDefault(o => o.userId == u.UserID);
     us.roleId = u.RoleId;
     us.startDate = u.StartDate;
     us.endDate = u.EndDate;
     ctx.SaveChanges();
 }
示例#14
0
 public void updateRoleBack(User e)
 {
     user x = ctx.users.FirstOrDefault(o => o.name == e.UserName);
     x.roleId = "d101";
     ctx.SaveChanges();
     //gaofan
 }
示例#15
0
 public User getUserByEmailGF(string email)
 {
     //
     user x = ctx.users.FirstOrDefault(o => o.email == email);
     User u = new User();
     u.UserID = x.userId;
     u.UserName = x.name;
     u.PhoneNo = x.phoneNo;
     u.Email = x.email;
     u.Address = x.address;
     u.DepartmentId = x.departmentId;
     u.RoleId = x.roleId;
     u.Password = x.password;
     if (x.roleId == "d104")
     {
         u.StartDate = Convert.ToDateTime(x.startDate);
         u.EndDate = Convert.ToDateTime(x.endDate);
     }
     else
     {
         u.StartDate = DateTime.Now;
         u.EndDate = DateTime.Now;
     }
     u.DepartmentName = x.department.name;
     u.RoleName = x.role.name;
     u.Status = x.status;
     return u;
     //gaofan
 }
示例#16
0
        public List<User> getUsers(string departmentId)
        {
            List<User> userCollection = new List<User>();

            try
            {
                var users = from u in ctx.users
                            where
                              u.departmentId == departmentId
                              where
                               !(new string[] {"d102", "d104" }).Contains(u.roleId)
                                 && u.status == "Active"
                            select new
                            {
                                uid = u.userId,
                                name = u.name,
                                email = u.email,
                                start = u.startDate,
                                end = u.endDate,
                                roleId = u.roleId,
                                roleName = u.role.name
                            };

                foreach (var u in users)
                {
                    User user = new User();
                    user.UserID = u.uid;
                    user.UserName = u.name;
                    user.Email = u.email;
                    if (u.roleName == "departmentDeputy")
                    {
                        user.StartDate = (DateTime)u.start.Value;
                        user.EndDate = (DateTime)u.end.Value;
                    }
                    user.RoleId = u.roleId;
                    user.RoleName = u.roleName;
                    userCollection.Add(user);
                }
            }
            catch (Exception exception)
            {
                errorobj.WriteErrorLog("UserFacade-getUsersWithRole():::" + exception.ToString());
                userCollection = new List<User>();
            }
            return userCollection;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            userEntity = (User)Session["UserEntity"];
            userId = userEntity.UserID;
            departmentId = userEntity.DepartmentId;

            if(Session["UserId"]!=null)
            {
                userId = Convert.ToString(Session["UserId"]);
            }
            departmentId = arRequisitionController.getDepartmentId(userId);
            if(!IsPostBack)
            {
                dgvRequisitionListDataBind();
            }
        }
示例#18
0
 public void updateRoleBack(User e)
 {
     usergf.updateRoleBack(e);
 }
示例#19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            manageDeputyController = new ManageDeputyController();

            userEntity = (User)Session["UserEntity"];

            if(!IsPostBack)
            {
                dataBind();
                //List<User> userCollection = manageDeputyController.loadController("CPSC");//TODO
                //if(userCollection.Count!=0)
                //{
                //    User user = userCollection[0];
                //    UIDLabel.Text = user.UserID;
                //    NameLabel.Text = user.UserName;
                //    Session["startDate"] = user.StartDate;
                //    StartDateLabel.Text = "Start Date : "+user.StartDate.Date.ToString("d");
                //    EndDateLabel.Text = "End Date : "+user.EndDate.Date.ToString("d");
                //    Session["EndDate"] = user.EndDate;
                //    Panel1.Visible = true;
                //    EmployeeGridView.Visible = false;
                //    Panel2.Visible = false;
                //}
                //else
                //{
                //    EmployeeGridView.DataSource = manageDeputyController.selectEmployee("CPSC");//TODO
                //    EmployeeGridView.DataBind();
                //    Panel1.Visible = false;
                //    Panel2.Visible = false;
                //}

                MessageLabel.Visible = false;
            }
        }
示例#20
0
 public void updateUser(User e)
 {
     usergf.updateUserGF(e);
 }
示例#21
0
 public void updateUserRoleIdByName(User u)
 {
     usergf.updateUserRoleIdByNameGF(u);
 }
示例#22
0
        public List<User> getEmployeeByDepartmentIdGF(string partId)
        {
            var uu = ctx.users.Where(o => o.roleId == "d101" && o.departmentId == partId);
            List<User> ulist = new List<User>();
            foreach(user x in uu.ToList())
            {
                User u = new User();
                u.UserID = x.userId;
                u.UserName = x.name;
                u.PhoneNo = x.phoneNo;
                u.Email = x.email;
                u.Address = x.address;
                u.DepartmentId = x.departmentId;
                u.RoleId = x.roleId;
                u.Password = x.password;
                if (x.roleId == "d104")
                {
                    u.StartDate = Convert.ToDateTime(x.startDate);
                    u.EndDate = Convert.ToDateTime(x.endDate);
                }
                else
                {
                    u.StartDate = DateTime.Now;
                    u.EndDate = DateTime.Now;
                }
                u.DepartmentName = x.department.name;
                u.RoleName = x.role.name;
                ulist.Add(u);
            }

            return ulist;
        }