示例#1
0
        public static void RejectVoucher(int voucherId, DateTime datetime, string remarks, int count)
        {
            string to;

            using (StationeryStoreEntities context = new StationeryStoreEntities())
            {
                var item = context.Voucher.Where(c => c.VoucherID == voucherId).Single();
                item.Status       = "Rejected";
                item.ApprovalDate = datetime;
                item.Remarks      = remarks;
                context.SaveChanges();
                to = item.Employee.Email;
            }

            if (count == 0)
            {
                //mail to employee who raised request
                String from    = "*****@*****.**";
                String subject = "[Auto Notification] Voucher Status";
                String body    = String.Format("Sorry! Your Voucher {0} has been rejected." +
                                               "\n\nNote: This is an auto-generated email.  Please do not reply to this email." +
                                               "\n\nThis email is confidential and may be privileged.If you are not the intended recipient, " +
                                               "please delete it and notify us immediately; you should not copy or use it for any purpose, " +
                                               "nor disclose its contents to any other person.\n\nThank you.", voucherId);
                MailBizLogic.sendMail(from, to, subject, body);
            }
        }
示例#2
0
        public static void UpdateStatus(int voucherId, int count)
        {
            string to;

            using (StationeryStoreEntities context = new StationeryStoreEntities())
            {
                var item = context.Voucher.Where(c => c.VoucherID == voucherId).Single();

                item.Status = "Pending Manager Approval";

                context.SaveChanges();
                to = item.Employee.Email;
            }
            if (count == 0)
            {
                //mail to employee who raised request
                String from    = "*****@*****.**";
                String subject = "[Auto Notification] Voucher Status";
                String body    = String.Format("Your voucher {0} has been moved to Manager notice, as the amount of item is more than $250." +
                                               "\n\nNote: This is an auto-generated email.  Please do not reply to this email." +
                                               "\n\nThis email is confidential and may be privileged.If you are not the intended recipient, " +
                                               "please delete it and notify us immediately; you should not copy or use it for any purpose, " +
                                               "nor disclose its contents to any other person.\n\nThank you.", voucherId);
                MailBizLogic.sendMail(from, to, subject, body);
            }
        }
示例#3
0
        public void SendScheduleMail(List <CatalogueInventoryViewModel> list) // argument: List<CatalogueInventoryViewModel> list
        {
            //configure smtpClient
            SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);

            smtpClient.Credentials = new System.Net.NetworkCredential()
            {
                UserName = "******",
                Password = "******"
            };

            foreach (CatalogueInventoryViewModel c in list)
            {
                List <String> toAddress = MailBizLogic.ClerkEmail();
                foreach (String to in toAddress)
                {
                    MailMessage mailMessage = new MailMessage();
                    mailMessage.To.Add(to);
                    mailMessage.From    = new MailAddress("*****@*****.**");
                    mailMessage.Subject = String.Format("[Auto Notification] Item {0} is low in stock - {1}", c.ItemID, c.ItemDescription);
                    mailMessage.Body    = String.Format(" Item {0} is low in stock - {1}" +
                                                        "\n\nNote: This is an auto-generated email.  Please do not reply to this email." +
                                                        "\n\nThis email is confidential and may be privileged.If you are not the intended recipient, " +
                                                        "please delete it and notify us immediately; you should not copy or use it for any purpose, " +
                                                        "nor disclose its contents to any other person.\n\nThank you.", c.ItemID, c.ItemDescription);

                    smtpClient.EnableSsl = true;
                    smtpClient.Send(mailMessage);
                }
            }
        }
        public static void CreateDelegation(int EmpID, DateTime start, DateTime end, int DepID)
        {
            using (StationeryStoreEntities context = new StationeryStoreEntities())
            {
                Delegation s = new Delegation
                {
                    EmployeeID   = EmpID,
                    StartDate    = start,
                    EndDate      = end,
                    DepartmentID = DepID,
                };
                context.Delegation.Add(s);
                context.SaveChanges();

                Employee e       = context.Employee.Where(x => x.EmployeeID == EmpID).FirstOrDefault();
                String   from    = "*****@*****.**";
                String   to      = e.Email;
                String   subject = "[Auto Notification] Delegation Status";
                String   body    = String.Format("You are Delegated from " + start + " to " + end +
                                                 "\n\nNote: This is an auto-generated email.  Please do not reply to this email." +
                                                 "\n\nThis email is confidential and may be privileged.If you are not the intended recipient, " +
                                                 "please delete it and notify us immediately; you should not copy or use it for any purpose, " +
                                                 "nor disclose its contents to any other person.\n\nThank you.");
                MailBizLogic.sendMail(from, to, subject, body);
            }
        }
示例#5
0
        public static void ApproveVoucher(string itemId, int actualqty, int voucherId, DateTime datetime, string remarks, int count)
        {
            string to;

            using (StationeryStoreEntities context = new StationeryStoreEntities())
            {
                var item = context.CatalogueInventory.Where(c => c.ItemID == itemId).Single();

                item.ActualQty = actualqty;

                var item2 = context.Voucher.Where(c => c.VoucherID == voucherId).Single();
                item2.Status       = "Approved";
                item2.ApprovalDate = datetime;
                item2.Remarks      = remarks;
                to = item2.Employee.Email;

                //update Stockcard
                StockCard sc = new StockCard();
                sc.ItemID      = itemId;
                sc.SCCatID     = 18001;
                sc.Description = context.Voucher.Where(x => x.VoucherID == voucherId).Select(y => y.Employee.Name).FirstOrDefault();
                //sc.AdjustedQty = actualqty;
                sc.AdjustedQty     = context.VoucherDetail.Where(x => x.VoucherID == voucherId && x.ItemID == itemId).Select(y => y.AdjustedQty).FirstOrDefault();
                sc.TransactionDate = DateTime.Now.Date;
                context.StockCard.Add(sc);

                context.SaveChanges();
            }
            if (count == 0)
            {
                //mail to employee who raised request
                String from    = "*****@*****.**";
                String subject = "[Auto Notification] Voucher Status";
                String body    = String.Format("Your Voucher {0} has been approved." +
                                               "\n\nNote: This is an auto-generated email.  Please do not reply to this email." +
                                               "\n\nThis email is confidential and may be privileged.If you are not the intended recipient, " +
                                               "please delete it and notify us immediately; you should not copy or use it for any purpose, " +
                                               "nor disclose its contents to any other person.\n\nThank you.", voucherId);
                MailBizLogic.sendMail(from, to, subject, body);
            }
        }
        public static void DeleteDelegation(int DelegationID)
        {
            Delegation s;

            using (StationeryStoreEntities context = new StationeryStoreEntities())
            {
                s = context.Delegation.Where(p => p.DelegationID == DelegationID).First <Delegation>();
                Employee e = context.Employee.Where(x => x.EmployeeID == s.EmployeeID).FirstOrDefault <Employee>();
                context.Delegation.Remove(s);
                e.isDelegated = 0;
                context.SaveChanges();


                String from    = "*****@*****.**";
                String to      = e.Email;
                String subject = "[Auto Notification] Delegation Status";
                String body    = String.Format("Your delegation {0} has been cancelled." +
                                               "\n\nNote: This is an auto-generated email.  Please do not reply to this email." +
                                               "\n\nThis email is confidential and may be privileged.If you are not the intended recipient, " +
                                               "please delete it and notify us immediately; you should not copy or use it for any purpose, " +
                                               "nor disclose its contents to any other person.\n\nThank you.", DelegationID);
                MailBizLogic.sendMail(from, to, subject, body);
            }
        }