protected void ui_save_button_Click(object sender, EventArgs e) { User sUser = (User)Session["user"]; User dUser = new UserController().actionGetUserByID(sUser.id); if (String.IsNullOrEmpty(ui_password_textbox.Text) || String.IsNullOrEmpty(ui_email_textbox.Text)) { Response.Cookies.Add(new HttpCookie("flash_message", "Field(s) marked with * can't be empty.") { Path = "/" }); Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-error") { Path = "/" }); return; } dUser.password = ui_password_textbox.Text; dUser.firstname = ui_firstname_textbox.Text; dUser.lastname = ui_lastname_textbox.Text; dUser.email = ui_email_textbox.Text; dUser.phone_number = ui_phonenumber_textbox.Text; Message msg = new UserController().actionUpdateUser(dUser); if (!msg.condition) { Response.Cookies.Add(new HttpCookie("flash_message", msg.message) { Path = "/" }); Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-error") { Path = "/" }); return; } Response.Cookies.Add(new HttpCookie("flash_message", "Successfully Saved.") { Path = "/" }); Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-success") { Path = "/" }); Session["user"] = new UserController().actionGetUserByID(sUser.id); Response.Redirect("AccountEdit.aspx"); }
protected void Button1_Click(object sender, EventArgs e) { User sUser = (User)Session["user"]; if (sUser == null || sUser.user_type != 1) { Response.Redirect("~/m/Login.aspx"); } User dUser = new UserController().actionGetUserByID(sUser.id); RequisitionController requisitionController = new RequisitionController(); ApplicationLayer.Requisition requisition = new ApplicationLayer.Requisition(); requisition.user_obj = dUser.id; requisition.stationery = Convert.ToInt32(ui_id_hidden.Value); requisition.quantity = Convert.ToInt32(ui_quantity.Text); requisition.department = Convert.ToInt32(dUser.department); Message message = requisitionController.actionCreateRequisition(requisition); if (message.condition) { Response.Cookies.Add(new HttpCookie("flash_message", "Successfully Requested.") { Path = "/" }); Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-success") { Path = "/" }); Response.Redirect("~/m/DepartmentEmployee/Stationeries.aspx"); } else { Response.Cookies.Add(new HttpCookie("flash_message", "Requisition Fail. <br />" + message.message) { Path = "/" }); Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-error") { Path = "/" }); return; } }
protected void Page_Load(object sender, EventArgs e) { User sUser = (User) Session["user"]; if(sUser == null || ((sUser.user_type != 3) && sUser.user_type != 2)) { Response.Redirect("~/Login.aspx"); } if (!Page.IsPostBack) { UserController userController = new UserController(); User user = userController.actionGetUserByID(sUser.id); ui_emplyoees_dropdown.DataSource = new UserController().actionGetEmployeesByDepartmentID(Convert.ToInt32(user.department)); ui_emplyoees_dropdown.DataTextField = "username"; ui_emplyoees_dropdown.DataValueField = "id"; ui_emplyoees_dropdown.DataBind(); ui_delegated_dropdown.DataSource = new UserController().actionGetHeadDelegatedUsersByDepartmentID(Convert.ToInt32(user.department)); ui_delegated_dropdown.DataTextField = "username"; ui_delegated_dropdown.DataValueField = "id"; ui_delegated_dropdown.DataBind(); } //get from session //loginUserId = 15; //BindGridView(loginUserId); }
protected void ui_save_button_Click(object sender, EventArgs e) { UserController userController = new UserController(); User user = new User(); int user_id; //getting hidden field id if (int.TryParse(ui_id_hiddenfield.Value, out user_id)) { user.id = Convert.ToInt32(ui_id_hiddenfield.Value); } if (user.id > 0) { user = userController.actionGetUserByID(user.id); } //fields validation if (String.IsNullOrEmpty(ui_email_textbox.Text) || String.IsNullOrEmpty(ui_password_textbox.Text)) { Response.Cookies.Add(new HttpCookie("flash_message", "Field(s) marked with * can't be empty.") { Path = "/" }); Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-error") { Path = "/" }); return; } //setting up object user.username = ui_username_textbox.Text; user.password = ui_password_textbox.Text; user.firstname = ui_firstname_textbox.Text; user.lastname = ui_lastname_textbox.Text; user.phone_number = ui_phonenumber_textbox.Text; user.email = ui_email_textbox.Text; user.department = null; //updating db; Message message; if (user.id > 0) { message = userController.actionUpdateUser(user); } else { //Default user creation is 1//Employee user.user_type = 4; message = userController.actionCreateUser(user); } //redirecting if (message.condition) { Response.Cookies.Add(new HttpCookie("flash_message", "Successfully Saved.") { Path = "/" }); Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-success") { Path = "/" }); Response.Redirect("~/StoreSupervisor/ClerkDetail.aspx?id=" + user.id); } else { Response.Cookies.Add(new HttpCookie("flash_message", message.message) { Path = "/" }); Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-error") { Path = "/" }); Response.Redirect("~/StoreSupervisor/ClerkDetail.aspx?id=" + user.id); } }
protected void Page_Load(object sender, EventArgs e) { int user_id; if (int.TryParse(Request.QueryString["id"], out user_id)) { user_id = Convert.ToInt16(Request.QueryString["id"].ToString()); if (user_id < 1) { Response.Redirect("~/StoreSupervisor/ClerkList.aspx"); } if (!Page.IsPostBack) { UserController userController = new UserController(); UserView user = userController.actionGetUserViewByUserID(user_id); ui_id_hiddenfield.Value = user.id.ToString(); ui_username_textbox.Text = user.username; ui_password_textbox.Text = ""; ui_firstname_textbox.Text = user.firstname; ui_lastname_textbox.Text = user.lastname; ui_email_textbox.Text = user.email; ui_phonenumber_textbox.Text = user.phone_number; ui_content_title_label.Text = user.firstname + " " + user.lastname; } } else { } }
protected void Page_Load(object sender, EventArgs e) { UserController userController = new UserController(); //ui_user_gridview.DataSource = userController.actionGetUserViews(); //ui_user_gridview.GridLines = GridLines.None; //ui_user_gridview.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { int user_id; if (int.TryParse(Request.QueryString["id"], out user_id)) { user_id = Convert.ToInt16(Request.QueryString["id"].ToString()); if (user_id < 1) { Response.Redirect("~/StoreClerk/UserList.aspx"); } if (!Page.IsPostBack) { UserController userController = new UserController(); UserView user = userController.actionGetUserViewByUserID(user_id); ui_id_hiddenfield.Value = user.id.ToString(); ui_username_textbox.Text = user.username; ui_password_textbox.Text = ""; ui_firstname_textbox.Text = user.firstname; ui_lastname_textbox.Text = user.lastname; ui_email_textbox.Text = user.email; ui_phonenumber_textbox.Text = user.phone_number; ui_usertype_label.Text = user.type; List<Department> departments = new DepartmentController().actionGetDepartments(); ui_department_dropdown.DataSource = departments; ui_department_dropdown.DataTextField = "department_name"; ui_department_dropdown.DataValueField = "id"; if (user.department > 0) { ui_department_dropdown.SelectedValue = user.department.ToString(); } ui_department_dropdown.DataBind(); ui_content_title_label.Text = user.firstname + " " + user.lastname; } } else { String tmp_dept = ui_department_dropdown.SelectedValue; ui_usertype_label.Text = "(Default user type will be emplyoee)"; List<Department> departments = new DepartmentController().actionGetDepartments(); ui_department_dropdown.DataSource = departments; ui_department_dropdown.DataTextField = "department_name"; ui_department_dropdown.DataValueField = "id"; ui_department_dropdown.DataBind(); ui_department_dropdown.SelectedValue = tmp_dept; } }
protected void ui_delegate_button_Click(object sender, EventArgs e) { User currentUser = (User)Session["user"]; int user_id = Convert.ToInt32(ui_emplyoees_dropdown.SelectedValue.ToString()); UserController userController = new UserController(); Message msg = userController.actionGiveHeadPermissionToAnEmployee(user_id, Convert.ToInt32(currentUser.department)); if (msg.condition) { Response.Cookies.Add(new HttpCookie("flash_message", "Successfully Saved.") { Path = "/" }); Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-success") { Path = "/" }); Response.Redirect(Request.RawUrl); } else { Response.Cookies.Add(new HttpCookie("flash_message", msg.message) { Path = "/" }); Response.Cookies.Add(new HttpCookie("flash_css", "alert alert-error") { Path = "/" }); } }
protected void Page_Load(object sender, EventArgs e) { User sUser = (User)Session["user"]; if (sUser == null || (sUser.user_type != 5 && sUser.user_type != 6) ) { Response.Redirect("~/Login.aspx"); } User dUser = new UserController().actionGetUserByID(sUser.id); if (!Page.IsPostBack) { ui_username_label.Text = dUser.username; //ui_password_textbox.Text = dUser.password; ui_firstname_textbox.Text = dUser.firstname; ui_lastname_textbox.Text = dUser.lastname; ui_email_textbox.Text = dUser.email; ui_phonenumber_textbox.Text = dUser.phone_number; } }
protected void Page_Load(object sender, EventArgs e) { User user = (User)Session["user"]; if (user == null || ((user.user_type != 3) && user.user_type != 2)) { Response.Redirect("~/Login.aspx"); } UserController userController = new UserController(); User dUser = userController.actionGetUserByID(user.id); if (!IsPostBack) { Department department = new DepartmentController().actionGetDepartmentByID(Convert.ToInt32(dUser.department)); ddlCollectionPoint.DataSource = new CollectionPointController().actionGetCollectionPoints(); ddlCollectionPoint.DataValueField = "id"; ddlCollectionPoint.DataTextField = "name"; ddlCollectionPoint.DataBind(); ddlCollectionPoint.Items.FindByValue(department.collection_point.ToString()).Selected = true; txtRepresentative.Text = department.representative_name; } }
public static void approveRequisitions(List<RequisitionID> jsonParam) { User sUser = (User)HttpContext.Current.Session["user"]; if (sUser == null) { return; } UserController userController = new UserController(); User dUser = userController.actionGetUserByID(sUser.id); JavaScriptSerializer js = new JavaScriptSerializer(); // System.Diagnostics.Debug.WriteLine("check @@@@@@@@@@@@ approveRequisitions:" + js.Serialize(jsonParam)); System.Diagnostics.Debug.WriteLine("check @@@@@@@@@@@@ approveRequisitions:" + jsonParam.Count()); //actionRequisitionStatusChangeToApproved(int requisition_id) RequisitionController requisitionController = new RequisitionController(); foreach (RequisitionID requisitionId in jsonParam) { System.Diagnostics.Debug.WriteLine("check @@@@@@@@@@@@ param:" + requisitionId.Id); requisitionController.actionRequisitionStatusChangeToApproved(Convert.ToInt32(requisitionId.Id), dUser.id); } }
public static string LoadAllApprovedRequests() { User sUser = (User)HttpContext.Current.Session["user"]; if (sUser == null) { return null; } UserController userController = new UserController(); User dUser = userController.actionGetUserByID(sUser.id); RequisitionController requisitionController = new RequisitionController(); JavaScriptSerializer js = new JavaScriptSerializer(); List<RequisitionView> requisitionDepartmentWise = requisitionController.actionGetApprovedRequisitionViewsByDepartmentID(Convert.ToInt32(dUser.department)); System.Diagnostics.Debug.WriteLine("check @@@@@@@@@@@@ requisitions by department wise:" + requisitionDepartmentWise.Count()); List<UserRequisition> userRequisitionsList = new List<UserRequisition>(); foreach (RequisitionView r in requisitionDepartmentWise) { if (userRequisitionsList.Count == 0) { UserRequisition userRequisition = new UserRequisition(); //Since there are no requisitions made so no question of grouping based on user id userRequisition.EmployeeName = r.firstname + " " + r.lastname; userRequisition.UserId = r.user_obj; Requisition requisition = new Requisition(); requisition.ReqId = r.requisition_id; requisition.Quantity = r.quantity; requisition.StationaryName = r.stationery_name; // requisition.RequisitionDate = r.r userRequisition.UserRequisitions.Add(requisition); userRequisitionsList.Add(userRequisition); } else { bool found = false; //check if requisition from the same user is pending, if yes group the requisition based on that user id foreach (UserRequisition uR in userRequisitionsList) { if (r.user_obj == uR.UserId) { found = true; Requisition requisition = new Requisition(); requisition.ReqId = r.requisition_id; requisition.Quantity = r.quantity; requisition.StationaryName = r.stationery_name; // requisition.RequisitionDate = r.r uR.UserRequisitions.Add(requisition); break; } }//foreach //else simply add the userrequisition to the list, grouping not required if (!found) { UserRequisition userRequisition = new UserRequisition(); userRequisition.EmployeeName = r.firstname + " " + r.lastname; userRequisition.UserId = r.user_obj; Requisition requisition = new Requisition(); requisition.ReqId = r.requisition_id; requisition.Quantity = r.quantity; requisition.StationaryName = r.stationery_name; userRequisition.UserRequisitions.Add(requisition); userRequisitionsList.Add(userRequisition); } } } System.Diagnostics.Debug.WriteLine("check @@@@@@@@@@@@ loadAllPendingRequests:" + js.Serialize(userRequisitionsList)); return js.Serialize(userRequisitionsList); }