public List <Adjustment_Voucher_Record> GetVouchersByCriteria(string status, string sortOrder) { using (StationeryModel context = new StationeryModel()) { var vouchers = from v in context.Adjustment_Voucher_Records where v.status == status select v; switch (sortOrder) { case "number_desc": vouchers = vouchers.OrderByDescending(v => v.voucherID); break; case "Voucher Number": vouchers = vouchers.OrderBy(v => v.voucherID); break; case "Issued By": vouchers = vouchers.OrderBy(v => v.User.name); break; case "issued_by_desc": vouchers = vouchers.OrderByDescending(v => v.User.name); break; default: vouchers = vouchers.OrderBy(v => v.voucherID); break; } return(vouchers.ToList()); } }
public int UpdateAdjustmentVoucherInfo(Adjustment_Voucher_Record voucher) { using (StationeryModel context = new StationeryModel()) { try { Adjustment_Voucher_Record record = (from r in context.Adjustment_Voucher_Records where r.voucherID == voucher.voucherID select r).First(); record.approvalDate = voucher.approvalDate; record.authorisingStaffID = voucher.authorisingStaffID; record.handlingStaffID = voucher.handlingStaffID; record.issueDate = voucher.issueDate; record.remarks = voucher.remarks; record.status = voucher.status; return(context.SaveChanges()); } catch (Exception e) { string errorMessage = String.Format("Error occurs when updating adjustment voucher. ({0})", e.Message); throw new Exception(errorMessage); } } }
//get permission from DB public List <permissionInfo> GetDefinedPermissions() { using (StationeryModel context = new StationeryModel()) { return(context.permissionInfoes.ToList()); } }
public ActionResult updateRetrieve() { StationeryModel entity = new StationeryModel(); if (Request.QueryString["ErrorMessage"] != null) { TempData["ErrorMessage"] = Request.QueryString["ErrorMessage"]; return(RedirectToAction("GenerateRetrieveForm")); } var RetrieveQty = Convert.ToInt32((Request.QueryString["key1"])); var itemCode = Request.QueryString["key2"]; var description = Request.QueryString["key4"]; var Qty = Convert.ToInt32(Request.QueryString["key3"]); var page = Convert.ToInt32(Request.QueryString["key5"]); var stock = Convert.ToInt32(Request.QueryString["key6"]); var status = Request.QueryString["key7"]; if (status != null) { List <Requisition_Detail> list = entity.Requisition_Detail.Where(x => x.itemCode == itemCode).ToList(); foreach (var item in list) { item.allocatedQty = 0; } entity.SaveChanges(); } var rlist = (List <RetrieveForm>)HttpContext.Application["retrieveList"]; rlist.Where(x => x.ItemCode == itemCode).First().retrieveQty = RetrieveQty; HttpContext.Application["retrieveList"] = rlist; TempData["Successful"] = "Retrieve successfully."; return(RedirectToAction("GenerateRetrieveForm", new { pagenumber = page })); }
public List <Stationery> GetStationeriesBasedOnCriteria(string searchString, string categoryID) { using (StationeryModel context = new StationeryModel()) { var stationeries = from s in context.Stationeries select s; if (categoryID != "-1") { stationeries = stationeries.Where(s => s.categoryID.ToString() == categoryID); } if (!String.IsNullOrEmpty(searchString)) { string[] searchStringArray = searchString.Split(); foreach (string s in searchStringArray) { string search = s.ToLower().Trim(); if (!String.IsNullOrEmpty(search)) { stationeries = stationeries.Where(x => x.description.ToLower().Contains(search)); } } } return(stationeries.Include(s => s.Category).ToList()); } }
public User FindByUserID(string userID) { StationeryModel entity = new StationeryModel(); var a = (from user in entity.Users where user.userID == userID select user).First(); return(a); }
public Boolean AddNewDepartment(Department dept) { try { StationeryModel entity = new StationeryModel(); Department department = new Department(); string capDeptCode = dept.departmentCode.ToUpper(); department.departmentCode = capDeptCode; department.departmentName = dept.departmentName; department.contactName = dept.contactName; department.phoneNo = dept.phoneNo; department.faxNo = dept.faxNo; //department.departmentHeadID = dept.departmentHeadID; if (dept.collectionPointID.ToString() == "--Select--") { return(false); } else { department.collectionPointID = dept.collectionPointID; //department.representativeID = dept.representativeID; entity.Departments.Add(department); entity.SaveChanges(); } } catch { return(false); } return(true); }
public RoleInfos GetById(int id) { List <rolePermission> rolePermissionList = new List <rolePermission>(); List <permissionInfo> permissions = new List <permissionInfo>(); string rolename = ""; string description = ""; using (StationeryModel context = new StationeryModel()) { rolePermissionList = context.rolePermissions.Where(x => x.roleID == id).ToList(); if (context.roleInfoes.Where(x => x.roleID == id).ToList().Count > 0) { rolename = context.roleInfoes.Where(x => x.roleID == id).First().roleName.ToString(); description = context.roleInfoes.Where(x => x.roleID == id).First().description.ToString(); foreach (var p in rolePermissionList) { permissions.Add(context.permissionInfoes.Where(x => x.permissionID == p.permissionID).First()); } } } return(new RoleInfos { RoleId = id, RoleName = rolename, Description = description, Permissions = permissions, }); }
//for android: different cos of execution of rd.allocateQty += allocateQty public int UpdateRequisitionDetailsAndroid(string itemcode, int requisitionNo, int?allocateQty) { try { StationeryModel entity = new StationeryModel(); Requisition_Detail rd = new Requisition_Detail(); rd = entity.Requisition_Detail.Where(x => x.itemCode == itemcode && x.requisitionNo == requisitionNo).First(); //start of code added by alex// //deduct retrieve qty after doing allocation List <RetrieveForm> retrievalList = (List <RetrieveForm>)HttpContext.Current.Application["retrieveForm"]; int index = retrievalList.FindIndex(x => x.ItemCode == itemcode); retrievalList[index].retrieveQty -= allocateQty; HttpContext.Current.Application["retrieveForm"] = retrievalList; //end of code// rd.allocatedQty += allocateQty; entity.SaveChanges(); return(0); } catch { return(0); } }
public List <int> FindAllRole(string id) { StationeryModel entity = new StationeryModel(); User user = (from u in entity.Users where u.userID == id select u).First(); return((from a in entity.Users where a.departmentCode == user.departmentCode select a.role).ToList <int>()); }
public List <string> GetStoreRoles() { StationeryModel entity = new StationeryModel(); List <string> roles = (from role in entity.roleInfoes where (role.roleID != 1 && role.roleID != 2 && role.roleID != 3 && role.roleID != 4 && role.roleID != 5 && role.roleID != 8) select role.roleName).ToList <string>(); return(roles); }
public List <WCFRetrievalForm> getRetrievalList() { StationeryModel entity = new StationeryModel(); List <RetrieveForm> list = new List <RetrieveForm>(); DateTime date = DateTime.Now; List <RetrieveForm> model = requisitionRecordService.GetRetrieveFormByDateTime(date); if (HttpContext.Current.Application["retrieveForm"] == null) { HttpContext.Current.Application["retrieveForm"] = model; } else if (HttpContext.Current.Application["retrieveForm"] != null) { List <RetrieveForm> list2 = (List <RetrieveForm>)HttpContext.Current.Application["retrieveForm"]; foreach (var item in model) { foreach (var i in list2) { if (i.ItemCode == item.ItemCode) { item.retrieveQty = i.retrieveQty; } } } HttpContext.Current.Application["retrieveForm"] = model; } //generate list of requisition records for allocation at the same time List <Requisition_Record> rr = entity.Requisition_Records.Where(x => x.status == RequisitionStatus.APPROVED_PROCESSING || x.status == RequisitionStatus.PARTIALLY_FULFILLED).ToList(); HttpContext.Current.Application["requisitionRecordList_allocation"] = rr; return(WCFModelConvertUtility.ConvertToWCFRetrievalList(model)); }
public Stationery FindByItemCode(string itemCode) { StationeryModel context = new StationeryModel(); return((from s in context.Stationeries where s.itemCode == itemCode select s).FirstOrDefault()); }
List <Stationery> IStationeryDAO.GetAllItemCodes() { using (StationeryModel context = new StationeryModel()) { return((from s in context.Stationeries select s).Include(s => s.Category).ToList()); } }
public List <string> GetAllThirdSupplierList() { using (StationeryModel context = new StationeryModel()) { return((from s in context.Stationeries select s.thirdSupplierCode).Distinct().ToList()); } }
public User FindByUserID(string id) { using (StationeryModel entity = new StationeryModel()) { User u = entity.Users.Where(x => x.userID == id).Include(x => x.Department).First(); return(u); } }
public List <string> GetAllSupplierCode() { using (StationeryModel context = new StationeryModel()) { return((from s in context.Suppliers select s.supplierCode).ToList()); } }
public WCFUser GetUser(string userID) { StationeryModel entity = new StationeryModel(); User user = entity.Users.Where(x => x.userID == userID).First(); WCFUser wcfUser = WCFModelConvertUtility.ConvertToWCFUser(user); return(wcfUser); }
public List <DateTime> GetAllStockCheckDate() { using (StationeryModel context = new StationeryModel()) { return((from r in context.Inventory_Status_Records select r.date).Distinct().ToList()); } }
public List <string> GetAllItemCode() { using (StationeryModel context = new StationeryModel()) { return((from s in context.Stationeries select s.itemCode).ToList()); } }
public List <string> GetUOMList() { using (StationeryModel context = new StationeryModel()) { return((from s in context.Stationeries select s.unitOfMeasure).Distinct().ToList()); } }
public List <Category> GetAllCategory() { using (StationeryModel context = new StationeryModel()) { return((from c in context.Categories select c).ToList()); } }
public List <WCFRequisitionDetail> GetRequisitionDetailsByItemCode(string itemCode) { using (StationeryModel entity = new StationeryModel()) { List <Requisition_Detail> temp = entity.Requisition_Detail.Where(x => x.itemCode == itemCode).ToList(); return(WCFModelConvertUtility.ConvertToWCFRequestionDetails(temp)); } }
List <int> ICollectionPointDAO.GetAllCollectionID() { using (StationeryModel context = new StationeryModel()) { return((from c in context.Collection_Points select c.collectionPointID).ToList()); } }
public List <Purchase_Order_Record> GetAllPurchaseOrder() { using (StationeryModel Entity = new StationeryModel()) { List <Purchase_Order_Record> por = Entity.Purchase_Order_Records.ToList(); return(por); } }
public List <Purchase_Order_Record> FindByStatus(string status) { using (StationeryModel Entity = new StationeryModel()) { List <Purchase_Order_Record> por = Entity.Purchase_Order_Records.Where(x => x.status == status).ToList(); return(por); } }
public List <int> GetAllCategoryIDList() { using (StationeryModel context = new StationeryModel()) { return((from s in context.Stationeries select s.categoryID).Distinct().ToList()); } }
public Purchase_Order_Record FindByOrderID(int orderID) { StationeryModel Entity = new StationeryModel(); Purchase_Order_Record por = Entity.Purchase_Order_Records.Where(x => x.orderNo == orderID).First(); return(por); }
//PURCHASE DETAILS// public List <Purchase_Detail> GetPurchaseDetailsByOrderNo(int orderNo) { StationeryModel Entity = new StationeryModel(); List <Purchase_Detail> pd = Entity.Purchase_Detail.Where(x => x.orderNo == orderNo).ToList(); return(pd); }
public bool AddNewPurchaseOrder(Purchase_Order_Record purchase_order_record) { StationeryModel Entity = new StationeryModel(); Entity.Purchase_Order_Records.Add(purchase_order_record); Entity.SaveChanges(); return(true); }
public ActionResult update4(FormCollection form) { Request_StationeryModel rm1 = new Request_StationeryModel(); List<Stationery> lstr = dc.Stationeries.ToList(); Config cf = dc.Configs.OrderByDescending(c => c.BuildDate).ToList().First(); RequestModel rq = new RequestModel(); StationeryModel stmd = new StationeryModel(); Employee e = (Employee)Session["Employee"]; Employee e1 = (Employee)Session["eplo"]; Employee e2 = dc.Employees.Where(ee => ee.EmployeeNumber == e1.RegistrationNumber).ToList().First(); RequestModel22 rq22 = new RequestModel22(); // Employee e1 = dc.Employees.Where(ee => ee.EmployeeNumber == e.RegistrationNumber).ToList().First(); ViewData["lst5"] = rq22.Listrq2().Where(r1 => (e.EmployeeNumber.Equals(r1.RNumber1) && r1.Stte1.Equals("1") && r1.Acc1 == true) || (r1.Stte1.Equals("5") && r1.Acc1 == true)).OrderByDescending(r => r.DDispatch1).ToList(); // string From = cf.MailName; string To = e1.Email; string cc = e2.Email; string type = cf.Type; int post = Convert.ToInt32(cf.Ports); string mailnetword = cf.MailNetwork; string pass = cf.Password; string Subject = "Approved Request " + form["rname"].ToString(); string Message = "<span><b>From:</b> " + e.FullName + "</span><br/>" + "<b>Date Dispatch:</b> " + form["dd"].ToString() + "<br/>" + "<b>Content:</b> " + form["rc"].ToString() + "<br/>" + "<b>Description:</b> " + form["dt"].ToString(); //mail List<Request_Stationery> rqs = dc.Request_Stationeries.Where(s => s.RequestId == Convert.ToInt32(form["requestid"])).ToList(); string str = " "; Session["result"] = true; //test foreach (Stationery st in lstr) { foreach (Request_Stationery rs in rqs) { if (st.ProductId == rs.ProductId && rs.Quantity > st.Quantity) { Session["result"] = false; break; } } } // //print item if (Convert.ToBoolean(Session["result"]) == false) { foreach (Stationery st in lstr) { foreach (Request_Stationery rs in rqs) { if (st.ProductId == rs.ProductId && rs.Quantity > st.Quantity) { str = str + st.ProductName.ToString() + " _ "; } } } } else if (Convert.ToBoolean(Session["result"]) == true) { if (form["st3"].Equals("5")) { if (rq.Send1(From, To, cc, Subject, Message, type, post, mailnetword, pass)) { ////// List<Stationery> stnr = dc.Stationeries.ToList(); List<Request_Stationery> listrq = dc.Request_Stationeries.Where(l => l.RequestId == Convert.ToInt32(form["requestid"])).ToList(); // foreach (Stationery s in stnr) { foreach (Request_Stationery v in listrq) { if (s.ProductId == v.ProductId) stmd.EditST_RQ(v.ProductId, Convert.ToInt32(s.Quantity - v.Quantity)); } } // rq.update(Convert.ToInt32(form["requestid"]), form["rname"].ToString(), form["st"].ToString(), Convert.ToDateTime(form["dd"]), DateTime.Now, Convert.ToBoolean(form["acc"]), form["rc"].ToString(), form["en"].ToString(), form["dt"].ToString(), Convert.ToInt32(form["ctid"])); Session["email"] = 1; } else Session["email"] = 2; // } else { if (rq.Send(From, To, Subject, Message, type, post, mailnetword, pass)) { List<Stationery> stnr = dc.Stationeries.ToList(); List<Request_Stationery> listrq = dc.Request_Stationeries.Where(l => l.RequestId == Convert.ToInt32(form["requestid"])).ToList(); // foreach (Stationery s in stnr) { foreach (Request_Stationery v in listrq) { if(s.ProductId==v.ProductId) stmd.EditST_RQ(v.ProductId, Convert.ToInt32(s.Quantity-v.Quantity)); } } rq.update(Convert.ToInt32(form["requestid"]), form["rname"].ToString(), form["st"].ToString(), Convert.ToDateTime(form["dd"]), DateTime.Now, Convert.ToBoolean(form["acc"]), form["rc"].ToString(), form["en"].ToString(), form["dt"].ToString(), Convert.ToInt32(form["ctid"])); Session["email"] = 1; } else Session["email"] = 2; } } //mail Session["qty"] = str; // return RedirectToAction("MyRequest10"); }
public ActionResult update5(FormCollection form) { Config cf = dc.Configs.OrderByDescending(c => c.BuildDate).ToList().First(); RequestModel22 rq22 = new RequestModel22(); RequestModel rq = new RequestModel(); Employee e = (Employee)Session["Employee"]; Employee e1 = (Employee)Session["eplo1"];//nb req Employee e2 = dc.Employees.Where(ee => ee.EmployeeNumber == e1.RegistrationNumber).ToList().First(); ViewData["lst7"] = rq22.Listrq2().Where(r1 => (e.EmployeeNumber.Equals(r1.RNumber1) && r1.Stte1.Equals("2") && r1.Acc1 == false) || (e.EmployeeNumber.Equals(r1.RNumber1) && r1.Stte1.Equals("7") && r1.Acc1 == false)).OrderByDescending(r => r.DDispatch1).ToList(); string From = cf.MailName; string To = e1.Email; string cc=e2.Email; string type = cf.Type; int post = Convert.ToInt32(cf.Ports); string mailnetword = cf.MailNetwork; string pass = cf.Password; string Subject = "Approved (Request Rject) " + form["rname"].ToString(); string Message = "<span><b>From:</b> " + e.FullName + "</span><br/>" + "<b>Date Dispatch:</b> " + form["dd"].ToString() + "<br/>" + "<b>Content:</b> " + form["rc"].ToString() + "<br/>" + "<b>Description:</b> " + form["dt"].ToString(); if (form["st5"].Equals("7")) { if (rq.Send1(From, To, cc, Subject, Message, type, post, mailnetword, pass)) { StationeryModel stmd = new StationeryModel(); List<Stationery> stnr = dc.Stationeries.ToList(); List<Request_Stationery> listrq = dc.Request_Stationeries.Where(l => l.RequestId == Convert.ToInt32(form["requestid"])).ToList(); // foreach (Stationery s in stnr) { foreach (Request_Stationery v in listrq) { if (s.ProductId == v.ProductId) stmd.EditST_RQ(v.ProductId, Convert.ToInt32(s.Quantity + v.Quantity)); } } // rq.update(Convert.ToInt32(form["requestid"]), form["rname"].ToString(), form["st"].ToString(), Convert.ToDateTime(form["dd"]), DateTime.Now, Convert.ToBoolean(form["acc"]), form["rc"].ToString(), form["en"].ToString(), form["dt"].ToString(), Convert.ToInt32(form["ctid"])); Session["email"] = 1; Session["email1"] = 1; } else Session["email"] = 2; } else { if (rq.Send(From, To, Subject, Message, type, post, mailnetword, pass)) { // StationeryModel stmd = new StationeryModel(); List<Stationery> stnr = dc.Stationeries.ToList(); List<Request_Stationery> listrq = dc.Request_Stationeries.Where(l => l.RequestId == Convert.ToInt32(form["requestid"])).ToList(); // foreach (Stationery s in stnr) { foreach (Request_Stationery v in listrq) { if (s.ProductId == v.ProductId) stmd.EditST_RQ(v.ProductId, Convert.ToInt32(s.Quantity + v.Quantity)); } } // rq.update(Convert.ToInt32(form["requestid"]), form["rname"].ToString(), form["st"].ToString(), Convert.ToDateTime(form["dd"]), DateTime.Now, Convert.ToBoolean(form["acc"]), form["rc"].ToString(), form["en"].ToString(), form["dt"].ToString(), Convert.ToInt32(form["ctid"])); Session["email1"] = 1; Session["email"] = 1; } else Session["email"] = 2; } return RedirectToAction("MyRequest10"); }