public static void createRequisition(List <RequisitionItem> reqItemList, string submitStaff_id, string type, string status) { Requisition newReq = new Requisition(); Staff fromStaff = StaffController.getStaffById(submitStaff_id); // use sample data to test newReq.Requisition_ID = "REQ" + DateTime.Now.ToString("yyyyMMddHHmmss"); newReq.SubmissionStaff_ID = submitStaff_id; // approve staff can be null , for test use sample data //newReq.ApprovedByStaff_ID = "STF0002"; newReq.Create_Date = DateTime.Now; newReq.RequisitonType = type; newReq.Status = status; using (InventorySysDBEntities cntx = new InventorySysDBEntities()) { cntx.Requisitions.Add(newReq); cntx.SaveChanges(); foreach (RequisitionItem reqItem in reqItemList) { reqItem.Requisition_ID = newReq.Requisition_ID; cntx.RequisitionItems.Add(reqItem); } cntx.SaveChanges(); } if (type != "Special") { SendNotificationController.SendNotificaition(fromStaff, newReq.Requisition_ID); } }
public static void ConfirmRecivedItems(string DI, List <DisbursementDetail> ddlist, string deptID) { Staff rep = new Staff(); using (InventorySysDBEntities cntx = new InventorySysDBEntities()) { rep = StaffController.getRepByDepID(deptID); //update disbursmentdetail foreach (DisbursementDetail dd in ddlist) { updateDisbursmentDetail(cntx, dd); updateItemTransReceived(cntx, deptID, dd); } //update disbursment Disbursement disbursment = cntx.Disbursements.Find(DI); disbursment.Receive_Date = DateTime.Now; disbursment.Status = "Received"; // update Requisition List <Requisition> reqList = getRequisitionsByDI(DI); foreach (Requisition req in reqList) { Requisition reqData = cntx.Requisitions.Find(req.Requisition_ID); reqData.Update_Date = DateTime.Now; reqData.Status = "Received"; } cntx.SaveChanges(); } SendNotificationController.SendNotificaition(rep, DI); }
//approve requisitions public void ApproveRequisition(string reqId, string managerID) { Staff frmStaff = StaffController.getStaffById(managerID); var t = from x in ctx.Requisitions where x.Requisition_ID == reqId select x; Requisition r = t.First(); r.Status = "Approved"; r.ApprovedByStaff_ID = managerID; r.Update_Date = DateTime.Now; ctx.SaveChanges(); SendNotificationController.SendNotificaition(frmStaff, r.Requisition_ID); }
//reject requisitions public static void RejectRequisition(string reqId, string managerID, string RejectReason) { Staff frmStaff = StaffController.getStaffById(managerID); using (InventorySysDBEntities cntx = new InventorySysDBEntities()) { var t = from x in cntx.Requisitions where x.Requisition_ID == reqId select x; Requisition r = t.First(); r.Status = "Rejected"; r.ApprovedByStaff_ID = managerID; r.Update_Date = DateTime.Now; r.Remark = RejectReason; cntx.SaveChanges(); SendNotificationController.SendNotificaition(frmStaff, r.Requisition_ID); } }
public static void Main(string[] args) { //Email sendemail = new Email(); //sendemail.SendNotification(); //Staff newstaff = new Staff(); //BL.Public.Register re = new Public.Register(); //BL.Public.Login lg = new Public.Login(); //bool result = re.CreateUser("*****@*****.**", "qwer1234","staff"); //Console.WriteLine(result); //bool roleResult = re.CreateRole("staff"); //Console.WriteLine(roleResult); //bool loginReuslt = lg.checkLogin("*****@*****.**", "qwer1234"); //Console.WriteLine(loginReuslt); //Console.ReadLine(); //BL.Store.CreatePurchaseOrderControl pr = new Store.CreatePurchaseOrderControl(); //Console.WriteLine( pr.GetDefaultItem()); // test checkDisbursmentID //string ID = "DDS00003"; //Staff f = UserManager.getStaffById("STF0007"); //Console.WriteLine(DeptDisbursmentList.checkDisbursmentID(ID, f)); // test getDisbursmentItem foreach (dynamic q in ConfirmReceivedController.getDisbursmentItems("D020150107")) { Console.WriteLine(q.ItemCode); } //Console.WriteLine(StaffManager.getStaffListById("STF0002").First().Staff_Name); //get Manager by Dep ID Console.WriteLine(StaffController.getApprovStaffListByDepId("CPSC").Count); // //Mobile RequisitionItem_M //foreach (RequisitionItem_M reqm in (RequisitionControl.getRequisitionItem_M("ReqS0001"))) //{ // Console.WriteLine(string.Format("Reqitem {0}, {1} {2}", reqm.ItemName, reqm.NeedQty, reqm.UOM)); //} SendNotificationController de = new SendNotificationController(); Staff std = StaffController.getStaffById("STF0002"); Staff std1 = StaffController.getStaffById("STF0011"); Requisition req = RequisitionController.getReqByID("REQ20160314113326"); //DepEmailManager.SendNotificaition(std1, req); //Console.ReadLine(); //List<RequisitionItem> reqList = new List<RequisitionItem>(); //RequisitionItem req = new RequisitionItem(); //req.Item_ID = "c001"; //req.Required_Qty = 40; //RequisitionItem req1 = new RequisitionItem(); //req.Item_ID = "c001"; //req.Required_Qty = 40; //reqList.Add(req); //reqList.Add(req1); //reqList = reqList.GroupBy(x => x.Item_ID) // .Select(y => new RequisitionItem { Item_ID = y.Key, Required_Qty = y.Sum(t => t.Required_Qty) }).ToList(); DateTime DT = Convert.ToDateTime("02/01/2015"); ReportController.getReqByDep(DT); Console.WriteLine(ReportController.getReqByDep(DT).Count); foreach (MonthDepReportReq mr in ReportController.getReqByDep(DT)) { Console.WriteLine(mr.Status); } Console.ReadLine(); }