static void PurchaseOrderIsApproved(int poNumber) { PORecord po; double totalPrice = 0; string supplierEmail; using (SA45Team12AD ctx = new SA45Team12AD()) { po = ctx.PORecords.Where(x => x.PONumber == poNumber).FirstOrDefault(); supplierEmail = ctx.SupplierLists.Where(x => x.SupplierID == po.SupplierID).Select(x => x.EmailAddress).FirstOrDefault(); List <PORecordDetail> poDList = ctx.PORecordDetails.Where(x => x.PONumber == poNumber).ToList(); foreach (PORecordDetail p in poDList) { InventoryLogic.UpdateUnitsOnOrder(p.ItemID, (int)p.Quantity); totalPrice += (double)(p.UnitPrice * p.Quantity); } } //Creating a thread to send the PDF email in background to prevent lagging the Website. Thread bgThread = new Thread(delegate() { using (EmailControl em = new EmailControl()) { em.SendPurchaseOrder(supplierEmail, po.PONumber, po.RecipientName, po.DeliveryAddress, GetSuppilerName(po.SupplierID), (DateTime)po.ExpectedDelivery, totalPrice); } }); bgThread.Start(); }
public static bool UpdateDisbursementStatus(int disbursementId, string status) { string email; string collectPoint; string dateTime; bool success = false; using (SA45Team12AD ctx = new SA45Team12AD()) { DisbursementList dL = ctx.DisbursementLists.Where(x => x.DisbursementID == disbursementId).FirstOrDefault(); email = Utility.Utility.GetEmailAddressByName(dL.RepresentativeName); collectPoint = GetCurrentCPWithTimeByID(dL.CollectionPointID); dateTime = ((DateTime)dL.CollectionDate).ToString("d"); dL.Status = status; ctx.SaveChanges(); success = true; } if (status == "Cancelled") { using (EmailControl em = new EmailControl()) { em.CancelStationeryCollectionNotification(email, collectPoint, dateTime); } } return(success); }
//------------ Lim Chang Siang's Code Ends Here-------------------------------// //------ Li Jianing'S Code start Here------------------------------// public static int AddText(string Deliverto, string Address, string SupplierID, DateTime RequestedDate, string userName, DateTime ExpectedBy) { //Put here so other methods can use even after the EF object is disposed. PORecord poRecord; using (SA45Team12AD entities = new SA45Team12AD()) { poRecord = new PORecord(); poRecord.RecipientName = Deliverto; poRecord.DeliveryAddress = Address; poRecord.SupplierID = SupplierID; poRecord.Status = "Pending"; poRecord.DateRequested = RequestedDate; poRecord.CreatedBy = userName; poRecord.ExpectedDelivery = ExpectedBy; entities.PORecords.Add(poRecord); entities.SaveChanges(); } //Using System.Web.Security feature. List <MembershipUser> userList = Utility.Utility.GetListOfMembershipUsers(); string[] approveAuthList = Roles.GetUsersInRole("Supervisor"); string clerkName = HttpContext.Current.Profile.GetPropertyValue("fullname").ToString(); foreach (string s in approveAuthList) { var User = userList.Find(x => x.UserName == s); using (EmailControl em = new EmailControl()) { em.NewPurchaseOrderForApprovalNotification(User.Email.ToString(), clerkName, poRecord.PONumber.ToString(), DateTime.Now.Date.ToString("d")); } } //Return the new PONumber. return(poRecord.PONumber); }
public static void UpdateDelegate(DDelegateDetail dDelegateinput, DateTime newstartdate, DateTime newenddate) { //if (Roles.IsUserInRole(DisbursementLogic.GetUserName(dDelegateinput.DepartmentHeadDelegate, dDelegateinput.DepartmentID), "HOD")) { using (SA45Team12AD entities = new SA45Team12AD()) { DDelegateDetail dDelegate = entities.DDelegateDetails.Where(p => p.DepartmentHeadDelegate == dDelegateinput.DepartmentHeadDelegate).Where(x => x.DepartmentID == dDelegateinput.DepartmentID).Where(x => x.StartDate == dDelegateinput.StartDate).Where(x => x.EndDate == dDelegateinput.EndDate).First(); dDelegate.StartDate = newstartdate; dDelegate.EndDate = newenddate; entities.SaveChanges(); } using (EmailControl em = new EmailControl()) { List <string> depuseremails = new List <string>(); depuseremails = Utility.Utility.GetAllUserEmailAddressListForDept(dDelegateinput.DepartmentID); } } }
public int CreateDisbursementList(string deptId, int collectPtId, DateTime collectionDate, string deptRep) { DisbursementList dList = new DisbursementList(); using (SA45Team12AD ctx = new SA45Team12AD()) { dList.DepartmentID = deptId; dList.CollectionPointID = collectPtId; dList.CollectionDate = collectionDate; dList.RepresentativeName = deptRep; dList.Status = "Pending Collection"; ctx.DisbursementLists.Add(dList); ctx.SaveChanges(); } using (EmailControl em = new EmailControl()) { em.NewStationeryCollectionNotification(Utility.Utility.GetEmailAddressByName(deptRep), GetCurrentCPWithTimeByID(collectPtId), collectionDate.ToString("d")); } return(dList.DisbursementID); }
void SendEmail() { //申请批准后超时提醒 DataTable alertApprovalDT = applicationInfo.SelectAlertApproval(); if (alertApprovalDT.Rows.Count > 0) { foreach (DataRow dr in alertApprovalDT.Rows) { try { EmailControl.ApplicationAlert(dr["TransNo"].ToString(), dr["ApplicantsName"].ToString(), dr["ApplicantsDate"].ToString()); } catch { EmailControl.AlertException(dr["TransNo"].ToString(), dr["ApplicantsName"].ToString(), dr["ApplicantsDate"].ToString()); } } } }
public static void UpdateCollectionPoint(string depid, int cpid) { using (SA45Team12AD entities = new SA45Team12AD()) { Department department = entities.Departments.Where(p => p.DeptID == depid).First <Department>(); department.CollectionPointID = cpid; entities.SaveChanges(); } Thread collectPointThread = new Thread(delegate() { using (EmailControl em = new EmailControl()) { List <string> clerkemails = Utility.Utility.GetClerksEmailAddressList(); string newCPID = GetCurrentCPIDByDep(depid); string newCPName = GetCurrentCPWithTimeByID(Int32.Parse(newCPID)); em.DisburstmentPointChangeNotification(clerkemails, GetDepNameByDepID(depid), GetDeptRepFullName(depid), newCPName); } }); collectPointThread.Start(); }
//Send reminder email to department rep 2 days before the collection date public static void SendCollectionReminder(DateTime date) { string email; string collectPoint; string dateTime; using (SA45Team12AD ctx = new SA45Team12AD()) { List <DisbursementList> dList = ctx.DisbursementLists.Where(x => x.CollectionDate == date.Add(TimeSpan.FromDays(2))).ToList(); foreach (DisbursementList d in dList) { email = Utility.Utility.GetEmailAddressByName(d.RepresentativeName); collectPoint = GetCurrentCPWithTimeByID(d.CollectionPointID); dateTime = ((DateTime)d.CollectionDate).ToString("d"); using (EmailControl em = new EmailControl()) { em.RemindStationeryCollectionNotification(email, collectPoint, dateTime); } } } }
public static void UpdateDeptRep(String newrepfullname, String dept) { Roles.AddUserToRole(GetDeptRepUserName(GetCurrentDep()), "Employee"); Roles.RemoveUserFromRole(GetDeptRepUserName(GetCurrentDep()), "Rep"); Roles.AddUserToRole(GetUserName(newrepfullname, dept), "Rep"); Roles.RemoveUserFromRole(GetUserName(newrepfullname, dept), "Employee"); using (SA45Team12AD entities = new SA45Team12AD()) { Department department = entities.Departments.Where(x => x.DeptID == dept).FirstOrDefault(); department.RepresentativeName = newrepfullname; entities.SaveChanges(); } //Chang Siang suggested using Thread function here Thread bgThread = new Thread(delegate() { using (EmailControl em = new EmailControl()) { List <string> allemails = new List <string>(); List <string> clerkemails = Utility.Utility.GetClerksEmailAddressList(); List <string> depusersemails = Utility.Utility.GetAllUserEmailAddressListForDept(dept); foreach (string s in clerkemails) { allemails.Add(s); } foreach (string s in depusersemails) { allemails.Add(s); } em.CollectionRepChangeNotification(allemails, GetDepNameByDepID(dept), newrepfullname); } }); bgThread.Start(); }
static void Main(string[] args) { /** * References * https://www.devmedia.com.br/como-implementar-o-design-pattern-observer-no-net/32846 * * */ ISubject emailControl = new EmailControl(); var first = new User("First"); var second = new User("Second"); var third = new User("Thrid"); Console.ForegroundColor = ConsoleColor.Green; //--------- newlester for all users ----------// emailControl.Subscribe(first); emailControl.Subscribe(second); emailControl.Subscribe(third); //--------- send email-----------------------// emailControl.SendEmail(); Console.WriteLine(Environment.NewLine); //------ the second user has unsubcribe ----// emailControl.Unsubscribe(second); //--------- newlester for all users ----------// emailControl.SendEmail(); Console.ReadKey(); }
public static void UpdatePurchaseOrderStatus(int poNumber, string status, DateTime dateProcessed, string handledBy) { PORecord po; string email = ""; using (SA45Team12AD entities = new SA45Team12AD()) { po = entities.PORecords.Where(x => x.PONumber == poNumber).FirstOrDefault(); po.Status = status; po.DateProcessed = dateProcessed; po.HandledBy = handledBy; entities.SaveChanges(); email = Utility.Utility.GetUserEmailAddress(po.CreatedBy); } if (status == "Approved") { PurchaseOrderIsApproved(poNumber); } using (EmailControl em = new EmailControl()) { em.ChangeInPurchaseOrderStatusNotification(email, poNumber.ToString(), dateProcessed.ToString("d"), status); } }
private void RefreshPreviewContent() { String value = this.Preview_RadioButtonList.SelectedValue; String page = String.Empty; Outage outage = (Outage)Session["Outage"]; String ExcelPath = Server.MapPath("~/excel/Blog.xlsx"); switch (value.ToLower()) { case "email": page = "Customers.aspx"; this.EmailControl.Visible = true; this.KBControl.Visible = false; this.ExcelControl.Visible = false; EmailControl.Refresh(outage); break; case "kb": page = "Knowledgebase.aspx"; this.EmailControl.Visible = false; this.KBControl.Visible = true; this.ExcelControl.Visible = false; KBControl.Refresh(outage); break; case "excel": page = "Excel.aspx"; this.EmailControl.Visible = false; this.KBControl.Visible = false; OutageRecovery or = GetOutages(); String newFilePath = new ExcelMarshall(or, ExcelPath, 5).Marshall(); ExcelControl.Refresh("~/excel/" + newFilePath); this.ExcelControl.Visible = true; break; default: return; } ///this.PreviewFrame.Attributes["src"] = page; }