public UserModel FindDeptRep() { SSISEntities context = new SSISEntities(); Department dept = context.Departments.Where(x => x.dept_code == this.department.dept_code).ToList().First(); string repUser = dept.rep_user; UserModel repUserModel = new UserModel(repUser); return(repUserModel); }
private void BindGrid() { using (SSISEntities ctx = new SSISEntities()) { int depAutPerson = Convert.ToInt32(ctx.Departments.Where(x => x.Department_Head == dhhid).Select(x => x.Department_Authorized_Person).First()); GridView1.DataSource = ctx.Employees.Where(x => x.Id == depAutPerson).ToList(); GridView1.DataBind(); } }
public ItemModel(Stock_Inventory stock) { itemCode = stock.item_code; description = stock.item_description; category = stock.Category; catName = category.cat_name; unitOfMeasure = stock.unit_of_measure; imagePath = stock.image_path; currentQuantity = stock.current_qty; reorderLevel = stock.reorder_level; reorderQuantity = stock.reorder_qty; //Changes for dashboard var stockItems = stock.Tender_List_Details.Where(w => w.deleted != "Y" && w.Tender_List.deleted != "Y" && w.Tender_List.tender_date.Year == DateTime.Now.Year); prices = new Dictionary <Supplier, double>(); using (SSISEntities context = new SSISEntities()) { // get tender list details associated with this item code IEnumerable <Tender_List_Details> details = context.Tender_List_Details .Where(w => w.Tender_List.tender_date.Year == DateTime.Now.Year && w.Tender_List.deleted != "Y" && w.item_code == itemCode && w.deleted != "Y") // Get distinct .GroupBy(d => d.Tender_List.supplier_id) .Select(group => group.FirstOrDefault()); Supplier sup = context.Suppliers.First(); if (details.Count() == 0) { // cannot find for whatever reason prices.Add(sup, 0.0); } else { // can find foreach (var detail in details) { prices.Add(detail.Tender_List.Supplier, Convert.ToDouble(detail.price)); } } } //foreach (var stockItem in stockItems) //{ // if (! prices.ContainsKey(stockItem.Tender_List.Supplier)) // { // prices.Add(stockItem.Tender_List.Supplier, Convert.ToDouble(stockItem.price)); // } //} //prices = stockItems.ToDictionary(x => x.Tender_List.Supplier, x => Convert.ToDouble(x.price)); //prices = stock.Tender_List_Details.Where(w => w.deleted != "Y" && w.Tender_List.deleted != "Y" && w.Tender_List.tender_date.Year == DateTime.Now.Year).ToDictionary(x => x.Tender_List.Supplier, x => Convert.ToDouble(x.price)); }
protected void btn_add_new_suppl_Click(object sender, EventArgs e) { String Name = tbx_name.Text; String iD = tbx_id.Text; String Address = tbx_address.Text; int num = Convert.ToInt32(tbx_contactno.Text); String Cname = tbx_cntctname.Text; int fno = Convert.ToInt32(tbx_fax.Text); String GST = tbx_gst.Text; String Remark = tbx_remark.Text; try { using (SSISEntities entity = new SSISEntities()) { Supplier sup = new Supplier { Supplier_ID = iD, Supplier_Name = Name, Address = Address, Contact_Number = num, Contact_Name = Cname, Fax_Number = fno, GST_Number = GST, Remarks = Remark }; entity.Suppliers.Add(sup); entity.SaveChanges(); foreach (ListItem item in ListBox1.Items) { if (item.Selected) { string ItemNumber = item.Value; Supplier_Item si = new Supplier_Item { Supplier_ID = iD, Item_Number = ItemNumber }; entity.Supplier_Item.Add(si); entity.SaveChanges(); } } } } catch { lblexcep.Text = "Supplier ID already Exist.Please try with different Id."; lblexcep.BackColor = System.Drawing.Color.Red; lblexcep.ForeColor = System.Drawing.Color.White; lblexcep.Visible = true; } Response.Redirect("~/com.ssis.PurchaseDepartmentRepresentative/MaintainSupplierInformation.aspx"); }
protected void Page_Load(object sender, EventArgs e) { String name = "zeck"; UserModel usermodel = new UserModel(name); String dept_code = usermodel.Department.dept_code; SSISEntities context = new SSISEntities(); var result = context.Approval_Duties.Where(x => x.deleted == "N" && x.dept_code.Equals("dept_code")).Select(x => x.end_date).Max(); Label1.Text = result.ToString(); }
protected void btnUpdate_Click(object sender, EventArgs e) { using (SSISEntities ctx = new SSISEntities()) { Department d = ctx.Departments.Where(x => x.Department_Representative == deptRepId).First(); d.CollectionPoint_ID = Int32.Parse(rblCollectionPoint.SelectedValue); ctx.SaveChanges(); } ShowMessage("Collection details updated successfully", MessageType.Success); }
protected void Page_Load(object sender, EventArgs e) { context = new SSISEntities(); requisitionID = Request.QueryString["ID"].ToString(); requisitionlbl.Text = requisitionID; //GridView1.DataSource = context.Requisition_Items.Where(x => x.Requisition_ID == rid).ToList(); //GridView1.DataBind(); }
public bool isDepartmentRep() { using (SSISEntities context = new SSISEntities()) { // Check if user is department rep int count = context.Departments.Where(d => d.rep_user == username).Count(); return(count > 0); } }
protected void btnGo_Click(object sender, EventArgs e) { using (SSISEntities context = new SSISEntities()) { // For all item codes that are not set, go and add things to stuff var details = context.Tender_List_Details.GroupBy(x => x.item_code).ToList(); var existingItemCodes = details.Select(s => s.Key); var otherItemCodes = context.Stock_Inventory.Select(s => s.item_code).ToList(); foreach (var item in existingItemCodes) { otherItemCodes.Remove(item); } // otherItemCodes has been filtered Random r = new Random(); List <int> tenderYearIds = context.Tender_List.Select(x => x.tender_year_id).ToList(); foreach (var item in otherItemCodes) { int toRemove = r.Next(0, 4); List <int> filteredTenderYearIds = tenderYearIds.ToList(); // select 3 supplier ids filteredTenderYearIds.RemoveAt(toRemove); // add a newdetail for each of the supplier ids, with each a random price double price = r.NextDouble() * 2 + 0.2d; foreach (int tenderYeadId in filteredTenderYearIds) { // add a new tenderListDetail Tender_List_Details newDetail = new Tender_List_Details(); decimal priceChange = (decimal)((r.NextDouble() * 0.4) - 0.2); decimal newPrice = ((decimal)price) + priceChange; newDetail.price = newPrice; newDetail.rank = 0; newDetail.tender_year_id = tenderYeadId; newDetail.item_code = item; newDetail.deleted = "N"; context.Tender_List_Details.Add(newDetail); } } context.SaveChanges(); } }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { String Category = DropDownList1.SelectedValue; using (SSISEntities entity = new SSISEntities()) { List <String> ProductList = entity.Stationery_Catalogue.Where(x => x.Category == Category).Select(y => y.Description).ToList(); DropDownList2.DataSource = ProductList; DropDownList2.DataBind(); } }
private void FillPage() { // need to login if (!User.Identity.IsAuthenticated) { Response.Redirect("~/login.aspx?return=Views/DepartmentHead/HeadDashboard.aspx"); } string username = User.Identity.Name.ToString(); UserModel user = new UserModel(username); string currentDept = user.Department.dept_code; var requestInfo = (from o in context.Requests where (currentDept == o.dept_code) && (o.current_status == RequestStatus.PENDING | o.current_status == RequestStatus.UPDATED) select new { o.request_id, o.username, o.date_time, o.reason }).ToList(); GridView1.DataSource = requestInfo; GridView1.DataBind(); string pendingnum = GridView1.Rows.Count.ToString(); lblPendingNum.Text = "You Have " + pendingnum + " Requests(s) to View"; string currentUser = Page.User.Identity.Name; string fullName = ""; using (SSISEntities context = new SSISEntities()) { fullName = context.Dept_Registry.Find(currentUser).fullname; } lblFullName.Text = "Welcome, " + fullName; Department dept = context.Departments.Where(x => currentDept == x.dept_code).First(); Collection_Point colpoint = context.Collection_Point.Where(y => y.collection_pt_id == dept.collection_point).First(); Dept_Registry dr = context.Dept_Registry.Where(x => x.username == dept.rep_user).First(); lblrep.Text = dr.fullname; lblcolpoint.Text = colpoint.location + " (" + colpoint.day_of_week + " - " + colpoint.date_time.ToShortTimeString() + ")"; var deldept = (from x in context.Approval_Duties select x.dept_code).ToList(); if (deldept.Contains(currentDept)) { List <Approval_Duties> ads = context.Approval_Duties.Where(x => currentDept == x.dept_code).ToList(); foreach (Approval_Duties ad in ads) { DateTime start = ad.start_date; DateTime end = ad.end_date; if ((DateTime.Now > start && DateTime.Now < end) && (ad.deleted == "N")) { lbldelegation.Text = ad.username + " (" + start + " - " + end + ")"; break; } } } }
protected void btnchangecoll_Click(object sender, EventArgs e) { //Yin SSISEntities context = new SSISEntities(); string loginUser = Page.User.Identity.Name; string logindepCode = context.Dept_Registry.Where(b => b.username == loginUser).Select(c => c.dept_code).First().ToString(); Department dept = context.Departments.Where(d => d.dept_code == logindepCode).Single(); Session["sDept"] = dept; Response.Redirect("~/Views/DepartmentHead/ChangeCollectionnRep.aspx"); }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { string name = DropDownList1.SelectedValue; SSISEntities s = new SSISEntities(); var list = s.Tender_List_Details.Where(x => x.Stock_Inventory.item_description == name).Select(x => new { x.tender_id, x.item_code, x.Stock_Inventory.item_description, x.Tender_List.Supplier.name, x.Tender_List.Supplier.contact_num, x.rank, x.price }).ToList(); GridView1.DataSource = list; GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { using (SSISEntities context = new SSISEntities()) { Category c = context.Categories.Find(1); Label1.Text = c.cat_name; context.Categories.Find(1).cat_name = "Penssss"; Label2.Text = c.cat_name; } }
protected void btnOldGo_Click(object sender, EventArgs e) { using (SSISEntities context = new SSISEntities()) { // Get all tender list details currently // Get item codes from there // get price too // foreach tender list detail, add one for supplier ALPA (year_id 7) // set price to be price += random from -0.5 to 0.5. if price is below zero, add 1 // set rank 0, set deleted 'N' var details = context.Tender_List_Details.GroupBy(x => x.item_code).ToList(); Random r = new Random(); int count = details.Count; int i = 0; foreach (var detail in details) { string code = detail.Key; decimal price = detail.First().price; decimal priceChange = (decimal)(r.NextDouble() - 0.2); decimal newPrice = price + priceChange; newPrice = newPrice < 0 ? newPrice + 0.5m : newPrice; Tender_List_Details newDetail = new Tender_List_Details(); newDetail.price = newPrice; newDetail.rank = 0; if (i <= count / 2) { newDetail.tender_year_id = 10; } else { newDetail.tender_year_id = 11; } newDetail.item_code = code; newDetail.deleted = "N"; context.Tender_List_Details.Add(newDetail); i++; } context.SaveChanges(); } }
public ActionResult DisbursementListFOrRep() { if (Session == null) { RedirectToAction("Login", "Home"); } SSISEntities db = new SSISEntities(); string employeeID = Session["EmployeeID"].ToString(); List <Disbursement> disburseList = disburseBizLogic.GetDisbursementListForUser(Session); return(View(disburseList)); }
protected void Page_Load(object sender, EventArgs e) { SSISEntities entities = new SSISEntities(); if (!IsPostBack) { DropDownList1.DataSource = entities.Departments.OrderBy(u => u.name).Select(u => u.name).ToList(); DropDownList1.DataBind(); DropDownList2.DataSource = entities.Collection_Point.OrderBy(c => c.location).Select(c => c.location).ToList(); DropDownList2.DataBind(); } }
protected void CreateOrder(object sender, EventArgs e) { Button btn = (Button)sender; GridViewRow gvr = (GridViewRow)btn.NamingContainer; bool duplicate = false; string itemcode = ((Label)gvr.FindControl("Label_ItemCode")).Text; SSISEntities context = new SSISEntities(); Stock_Inventory item = context.Stock_Inventory.Where(x => x.item_code == itemcode).First(); HashSet <Stock_Inventory> itemList = (HashSet <Stock_Inventory>)Session["item"]; if (itemList == null) { itemList = new HashSet <Stock_Inventory>(); itemList.Add(item); lblResult.Visible = true; lblduplicate.Visible = false; lblResult.Text = "Added Item Code (" + itemcode + ") Successfully"; Session["item"] = itemList; } else { foreach (Stock_Inventory s in itemList) { if (s.item_code == item.item_code) { duplicate = true; break; } } if (!duplicate) { itemList.Add(item); lblResult.Visible = true; lblduplicate.Visible = false; lblResult.Text = "Added Item Code (" + itemcode + ") Successfully"; Session["item"] = itemList; } else { lblduplicate.Visible = true; lblResult.Visible = false; lblduplicate.Text = "Duplicate item!"; Session["item"] = itemList; } } }
protected void btnCancelRequest_Click(object sender, EventArgs e) { int requestId = (int)Session[SESSION_REQ_EDIT_ID]; string username = User.Identity.Name; using (SSISEntities context = new SSISEntities()) { FacadeFactory.getRequestService(context).setRequestToCancelled(requestId, username); context.SaveChanges(); } Response.Redirect("EmpRequestHistory.aspx", false); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } panelNoItems.Visible = false; panelNormal.Visible = false; using (SSISEntities context = new SSISEntities()) { var allocated = FacadeFactory.getRetrievalService(context).getAllRetrievingByClerk(User.Identity.Name); if (allocated.Count == 0) { panelNoItems.Visible = true; return; } panelNormal.Visible = true; var itemGroups = allocated.SelectMany(sm => sm.Items .Select(s => new { s.Key.ItemCode, s.Key.Description, Quantity = s.Value, sm.Department.dept_code, sm.RequestId, sm.Department.name }) ).GroupBy(k => k.ItemCode, v => v).ToList(); List <ConfirmRetrievalViewModel> list = new List <ConfirmRetrievalViewModel>(); foreach (var itemGroup in itemGroups) { int itemQty = itemGroup.Select(s => s.Quantity).Aggregate((a, b) => a + b); List <int> reqIds = itemGroup.Select(s => s.RequestId).ToList(); ConfirmRetrievalViewModel model = new ConfirmRetrievalViewModel(); model.ItemCode = itemGroup.Key; model.ItemDescription = itemGroup.First().Description; //model.DeptCode = deptGroup.Key; //model.DeptName = deptGroup.First().name; model.QuantityExpected = itemQty; model.QuantityActual = itemQty; model.RequestIds = reqIds; //model.Include = true; list.Add(model); } Session[SESSION_RETRIEVING_LIST] = list; _refreshGrid(list); } }
private void _sendEmail(string currentUser, List<string> deptCodes) { UserModel currentUserModel = new UserModel(currentUser); List<UserModel> repUsers = new List<UserModel>(); using (SSISEntities context = new SSISEntities()) { foreach (var deptCode in deptCodes) { string repUser = context.Departments.Find(deptCode).rep_user; UserModel repUserModel = new UserModel(repUser); repUsers.Add(repUserModel); } /* Email logic */ string fromEmail = currentUserModel.Email; string fromName = currentUserModel.Fullname; //UserModel deptHead = currentUserModel.FindDelegateOrDeptHead(); foreach (var repUserModel in repUsers) { string toEmail = repUserModel.Email; string toName = repUserModel.Fullname; string subject = string.Format("New disbursement for collection"); StringBuilder sb = new StringBuilder(); sb.AppendLine("Dear " + toName + ","); sb.AppendLine("<br />"); sb.AppendLine("<br />"); sb.AppendLine(string.Format("{0} has scheduled some items for collection.", fromName)); sb.AppendLine("<br />"); Collection_Point collectionPt = repUserModel.Department.Collection_Point1; sb.AppendLine(string.Format("The collecton point is: {0}, on {1} at {2}.", collectionPt.location, collectionPt.day_of_week, collectionPt.date_time.ToShortTimeString())); sb.AppendLine("<br />"); sb.AppendLine(string.Format("Please <a href=\"{0}\">follow this link to login to the system</a>.", "https://rebrand.ly/ssis-login")); sb.AppendLine("<br />"); sb.AppendLine("<br />"); sb.AppendLine("Thank you."); sb.AppendLine("<br />"); sb.AppendLine("<br />"); sb.AppendLine("<i>This message was auto-generated by the Stationery Store Inventory System.</i>"); string body = sb.ToString(); new Emailer(fromEmail, fromName).SendEmail(toEmail, toName, subject, body); } } /* End of email logic */ }
protected void btnReject_Click(object sender, EventArgs e) { string reason = txtReason.Text; int id = Int32.Parse(Session["Requisition_ID"].ToString()); using (SSISEntities ctx = new SSISEntities()) { Stationery_Requisition sr = ctx.Stationery_Requisition.Where(x => x.Requisition_ID == id).First(); sr.Status = "Rejected"; sr.Reason = reason; ctx.SaveChanges(); } Response.Redirect("PendingRequisitions.aspx"); }
protected void Page_Load(object sender, EventArgs e) { ssisEntities = new SSISEntities(); Stationery_Requisition stationeryRequest = new Stationery_Requisition(); LoginDetails loginDetails = User.Identity as LoginDetails; string userId = loginDetails.UserId; Session["Mysession"] = Convert.ToInt32(userId); if (IsPostBack) { selectedproductList = (List <Stationery_Catalogue>)Session["Cart"]; } }
private void fillFields(Tender_List_Details order) { using (SSISEntities context = new SSISEntities()) { Stock_Inventory item = context.Stock_Inventory.Where(x => x.item_code == order.item_code).First();//Find(order.ISBN); itemDesc = item.item_description; supplierName = context.Suppliers.Where(x => x.supplier_id == order.Tender_List.supplier_id).Select(x => x.name).First(); price = order.price; tenderId = order.tender_id; quantity = item.reorder_qty; supplierId = order.Tender_List.supplier_id; } }
public List <UserModel> FindAllDeptUser() { SSISEntities context = new SSISEntities(); string dept = this.department.dept_code; List <Dept_Registry> regList = context.Dept_Registry.Where(x => x.dept_code == dept).ToList(); List <UserModel> deptList = new List <UserModel>(); foreach (Dept_Registry i in regList) { UserModel user = new UserModel(i.username); deptList.Add(user); } return(deptList); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int id = Int32.Parse(Session["Requisition_ID"].ToString()); using (SSISEntities ctx = new SSISEntities()) { Stationery_Requisition sr = ctx.Stationery_Requisition.Where(x => x.Requisition_ID == id).First(); lblRequistionFormID.Text = sr.Requisition_ID.ToString(); lblRequistionDate.Text = Convert.ToDateTime(sr.Requisition_Date).ToString("dd-MMMMM-yyyy"); lblSubmittedBy.Text = sr.Employee.Name.ToString(); } } }
// Private Methods protected DateTime _getLatestDateTime() { using (SSISEntities context = new SSISEntities()) { Request request = context.Requests.Find(RequestId); var requestEvents = request.Request_Details.SelectMany(sm => sm.Request_Event); if (requestEvents.Count() == 0) { return(request.date_time.HasValue ? request.date_time.Value : DateTime.Now); } return(requestEvents.OrderByDescending(o => o.date_time).First().date_time); } }
protected void Page_Load(object sender, EventArgs e) { var result = from t1 in entities.Departments join t2 in entities.Requests on t1.dept_code equals t2.dept_code join t3 in entities.Request_Details on t2.request_id equals t3.request_id join t4 in entities.Request_Event on t3.request_detail_id equals t4.request_detail_id join t5 in entities.Stock_Inventory on t3.item_code equals t5.item_code where t1.deleted.Equals("N") && t2.deleted.Equals("N") && t3.deleted.Equals("N") && t4.deleted.Equals("N") && t5.deleted.Equals("N") orderby t5.item_description select new { t5.item_description, t1.dept_code, t4.quantity }; using (SSISEntities context = new SSISEntities()) { //var result2 = FacadeFactory.getAllocatedService(context).getAllAllocated() } GridView1.DataSource = result.ToList(); GridView1.DataBind(); MergeCells(); //var result = from t1 in entities.Departments // join t2 in entities.Requests // on t1.dept_code equals t2.dept_code // join t3 in entities.Request_Details // on t2.request_id equals t3.request_id // join t4 in entities.Request_Event // on t3.request_detail_id equals t4.request_detail_id // join t5 in entities.Stock_Inventory // on t3.item_code equals t5.item_code // group t4 by new { t5.item_description} into g // select new { // item_description = g.Key.item_description, // quantity = g.Sum(t4=> t4.quantity) // }; }
public static List <WCFRetieve> GetAllPossibleRetrievalsForUser(string currentUser) { List <WCFRetieve> wcfList = new List <WCFRetieve>(); using (SSISEntities context = new SSISEntities()) { //Move all from allocated to retrieving automatically var allocated = FacadeFactory.getAllocatedService(context).getAllAllocated(); if (allocated.Count > 0) { foreach (var allocModel in allocated) { List <string> items = allocModel.Items.Select(s => s.Key.ItemCode).ToList(); FacadeFactory.getRequestMovementService(context).moveFromAllocatedToRetrieving(allocModel.RequestId, items, currentUser); } } context.SaveChanges(); var retrieving = FacadeFactory.getRetrievalService(context).getAllRetrievingByClerk(currentUser); var itemGroups = retrieving.SelectMany(sm => sm.Items .Select(s => new { s.Key.ItemCode, s.Key.Description, Quantity = s.Value, sm.Department.dept_code, sm.RequestId, sm.Department.name }) ).GroupBy(k => k.ItemCode, v => v).ToList(); foreach (var itemGroup in itemGroups) { int itemQty = itemGroup.Select(s => s.Quantity).Aggregate((a, b) => a + b); //List<int> reqIds = itemGroup.Select(s => s.RequestId).ToList(); WCFRetieve wcfItem = new WCFRetieve(); wcfItem.ItemDes = itemGroup.First().Description; wcfItem.TotalQty = itemQty.ToString(); wcfItem.ItemCode = itemGroup.Key; wcfList.Add(wcfItem); } } return(wcfList); }
public UserModel FindDelegateOrDeptHead() { SSISEntities context = new SSISEntities(); // Check delegate table if there is a delegate entry for this time period // If yes, return that person var delegateHead = FindDelegateHead(); if (delegateHead != null) { return(delegateHead); } string username = ""; Department dept = this.department; List <Dept_Registry> allDeptEmp = context.Dept_Registry.Where(x => x.dept_code == dept.dept_code).ToList(); foreach (Dept_Registry i in allDeptEmp) { var roles = Roles.GetRolesForUser(i.username); if (roles.Length == 0) { continue; } if (roles.First().ToString() == "DeptHead") { username = i.username; break; } } // Backup search if (username == "") { username = dept.head_user; } UserModel deptHead = new UserModel(username); return(deptHead); }