private void BindGrid(string DPcode) { LastADEntities entities = new LastADEntities(); var c = entities.Requisitions.Where(p => p.Status == "Waiting For Delivery" && p.Employee.DepartmentCode.Equals(DPcode)) .Join(entities.Employees, m => m.EmployeeId, f => f.UserId, (m, f) => new { m.RequId, f.Name, m.RequestedDate, m.Status, m.ReceivedBy }) .ToList(); GridView1.DataSource = c; GridView1.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { String DpCode = Session["DpCode"].ToString(); LastADEntities ctx = new LastADEntities(); Department c = ctx.Departments.Where(x => x.DepartmentCode == DpCode).First(); c.CollectionPointId = RadioButtonList1.SelectedIndex + 1; ctx.SaveChanges(); }
protected void Page_Load(object sender, EventArgs e) { //This is to show reminders to the store clerk on the number of requisition forms submitted by the departments // and the items needed to reorder. LastADEntities entities = new LastADEntities(); int i = entities.Requisitions.Where(x => x.Status.Equals("Waiting for Collection")).Count(); int j = entities.ItemLists.Where(x => x.Stock < x.ReOrderLevel && x.PurchaseOrderDetails.Contains(null)).Count(); Label7.Text = "There are " + i + " requsitionForm waiting for collection."; Label1.Text = "There are " + j + " item need to reorder."; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindGrid(); LastADEntities ctx = new LastADEntities(); var c = ctx.Requisitions.Join(ctx.Employees, m => m.EmployeeId, f => f.UserId, (m, f) => new { Requid = m.RequId, name = f.Name, SubmittedDate = m.RequestedDate, status = m.Status }).Where(x => x.status == "Pending Approval").ToList(); Label8.Text = (String)Session["count"]; } }
protected void Page_Load(object sender, EventArgs e) { LastADEntities ctx = new LastADEntities(); //var c = ctx.Departments.Where(x => x.CollectionPointId == RadioButtonList1.SelectedIndex); //MAY need to changed RadioButtonList1.SelectedIndex if (!IsPostBack) { if (Session["CollectionPoint"] != null) { Label1.Text = Session["CollectionPoint"].ToString(); } } }
private void BindGrid() { LastADEntities entities = new LastADEntities(); if (Session["wfcrequid"] != null) { int RequId = (int)Session["approvedrequid"]; var c = entities.RequDetails.Where(p => p.RequId == RequId) .Join(entities.ItemLists, m => m.ItemId, f => f.ItemId, (m, f) => new { f.Description, m.RequestedQuantity, m.OutstandingQuantity }) .ToList(); GridView1.DataSource = c; GridView1.DataBind(); Label5.Text = RequId.ToString(); } }
private void BindGrid() { if (Session["DpCode"] != null) { string dpid = Session["DpCode"].ToString(); LastADEntities entities = new LastADEntities(); var c = entities.Employees.Where(x => x.DepartmentCode.Equals(dpid)).Join(entities.Roles.Where(p => p.RoleId > 3), m => m.RoleId, f => f.RoleId, (m, f) => new Employeerole { Name = m.Name, RoleDescription = f.RoleDescription, Userid = m.UserId }).ToList(); GridView1.DataSource = c; GridView1.DataBind(); } }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState & DataControlRowState.Edit) > 0) { Employeerole employeerole = (Employeerole)e.Row.DataItem; DropDownList dp = (DropDownList)e.Row.FindControl("DropDownList1"); if (dp != null) { LastADEntities entities = new LastADEntities(); var c = entities.Roles.Where(q => q.RoleId > 3).ToList(); dp.DataSource = c; dp.DataTextField = "RoleDescription"; dp.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //To generate data for DropDownList1 using (LastADEntities b = new LastADEntities()) { var itemcat = (from ic in b.ItemCategories select ic.CategoryName).ToList(); itemcat.Insert(0, "---Select---"); DropDownList1.SelectedIndex = 0; DropDownList1.DataSource = itemcat; DropDownList1.DataBind(); //To generate the options for departments var depts = from dept in b.Departments select dept.DepartmentName; DeptList.DataSource = depts.ToArray(); DeptList.DataBind(); DeptList.Items.Remove(DeptList.Items.FindByText("Stationary Store Dept")); } } }
protected void CreateTable(object sender, EventArgs e) { using (LastADEntities b = new LastADEntities()) { string selecteditemcat = DropDownList1.SelectedValue; string DeptSelected = ""; string Deptname = ""; List <int> MthSelected = new List <int>(); string[] months = new string[13] { "", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; //To get all the departments chosen by user for (int i = 0; i < DeptList.Items.Count; i++) { if (DeptList.Items[i].Selected) { String temp = DeptList.Items[i].Value.ToString(); Department dd = b.Departments.Where(p => p.DepartmentName.Contains(temp)).First(); DeptSelected = dd.DepartmentCode; Deptname = dd.DepartmentName; } } //To get all the months chosen by user for (int j = 0; j < CheckBoxList2.Items.Count; j++) { if (CheckBoxList2.Items[j].Selected) { MthSelected.Add(Int32.Parse(CheckBoxList2.Items[j].Value)); } } var sd = yearrange[0]; var ed = yearrange[1]; //Setting up chart properties Chart1.ChartAreas.Add("ChartArea2"); Chart1.ChartAreas[0].AxisX.Title = Deptname; Chart1.ChartAreas[0].AxisY.Title = "Quantity Ordered"; Chart1.ChartAreas[0].BorderDashStyle = ChartDashStyle.Solid; Chart1.ChartAreas[0].AxisX.Interval = 1; Chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false; Chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = false; Chart1.Legends.Add("QuantityOrdered"); Title title = new Title(); title.Font = new Font("Arial", 14, FontStyle.Bold); title.Text = "Month Breakdown of Item Quantity Ordered from " + selecteditemcat + " Category by " + Deptname; Chart1.Titles.Add(title); //Getting datapoints according to what user selected for (int i = sd; i <= ed; i++) { var xy = b.Transactions.Where(p => (p.ItemList.ItemCategory.CategoryName.Contains(selecteditemcat)) && (p.EntryDate.Value.Year == i)) .Join(b.Requisitions, m => m.Requid, f => f.RequId, (m, f) => new { Requid = m.Requid, EmployeeId = f.EmployeeId, m.EntryDate, m.Quantity }) .Join(b.Employees.Where(p => p.DepartmentCode.Equals(DeptSelected)), q => q.EmployeeId, p => p.UserId, (q, p) => new { q.EntryDate, p.DepartmentCode, q.Quantity }) .GroupBy(n => n.EntryDate.Value.Month) .Select(g => new { b = g.Key, a = g.Sum(a => a.Quantity) }).OrderBy(x => x.b).ToList(); List <string> xcoor = new List <string>(); List <int> ycoor = new List <int>(); //Converting datapoints into coordinates if (MthSelected.Count == 0) { for (int p = 0; p < xy.Count; p++) { xcoor.Add(months[xy[p].b]); ycoor.Add((int)(xy[p].a)); } } else { for (int p = 0; p < xy.Count; p++) { if (MthSelected.Contains(xy[p].b)) { xcoor.Add(months[xy[p].b]); ycoor.Add((int)(xy[p].a)); } } } string yearseries = i.ToString(); Chart1.Series.Add(yearseries); //More Chart properties Chart1.Series[yearseries].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Column; Chart1.Series[yearseries].Points.DataBindXY(xcoor, ycoor); Chart1.Series[yearseries].IsVisibleInLegend = true; Chart1.Series[yearseries].IsValueShownAsLabel = true; Chart1.Series[yearseries].BorderWidth = 1; Chart1.Series[yearseries].ToolTip = "Quantity Ordered: #VALY"; Chart1.Series[yearseries].Font = new System.Drawing.Font("Arial", 12); Chart1.Series[yearseries]["LabelStyle"] = "Top"; Chart1.Series[yearseries].LabelBackColor = Color.LightCyan; Chart1.Series[yearseries]["PixelPointWidth"] = "50"; Chart1.AlignDataPointsByAxisLabel(); Chart1.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { IIdentity id = User.Identity; LastADEntities entities = new LastADEntities(); Employee employee = new Employee(); employee = entities.Employees.Where(x => x.Name == id.Name).First(); string dept = employee.DepartmentCode; string role = employee.Role.RoleDescription; string employeename = employee.Name; string collectionpoint = "0"; string Bossemail = "0"; string employeeid = employee.UserId.ToString(); if (employee.StartDate != null && employee.EndDate != null) { if (DateTime.Now.Date.CompareTo(employee.StartDate) >= 0 && DateTime.Now.Date.CompareTo(employee.EndDate) <= 0) { employee.RoleId = 6; entities.SaveChanges(); } else if (DateTime.Now.Date.CompareTo(employee.EndDate) > 0) { if (User.IsInRole("Employee")) { employee.RoleId = 4; employee.StartDate = null; employee.EndDate = null; entities.SaveChanges(); } else { employee.RoleId = 5; employee.StartDate = null; employee.EndDate = null; entities.SaveChanges(); } } } if (!dept.Contains("STNR")) { collectionpoint = employee.Department.CollectionPoint.CollectionPointName; int?ii = 6; Bossemail = entities.Employees.Where(x => x.DepartmentCode == dept && (x.RoleId == ii)).First().Email; } else { Bossemail = "*****@*****.**"; collectionpoint = "0"; } Session["EmpName"] = employeename; Session["DpCode"] = dept; Session["EmpRole"] = role; Session["CollectionPoint"] = collectionpoint; Session["EmpId"] = employeeid; Session["BossEmail"] = Bossemail; if (id.IsAuthenticated) { if (User.IsInRole("Store Clerk")) { Response.Redirect("~/4StoreClerk/ClerkHome.aspx"); } else if (User.IsInRole("Supervisor")) { Response.Redirect("~/6StoreSupervisor/SupervisorAdjVoucher.aspx"); } else if (User.IsInRole("Manager")) { Response.Redirect("~/5StoreManager/mt250AdjustmentVoucher.aspx"); } else if (User.IsInRole("Employee")) { Response.Redirect("~/1DepartmentEmployee/EmployeeHome.aspx"); } else if (User.IsInRole("Department Representative")) { Response.Redirect("~/3DepartmentRep/RepHome.aspx"); } else if (User.IsInRole("Department Head")) { Response.Redirect("~/2DepartmentHead/HeadHome.aspx"); } } }