Exemplo n.º 1
0
        public static void SendNotificaition(Staff fromStaff, string id)
        {
            // get the toStaff
            List <Staff> toStaffList = new List <Staff>();

            switch (fromStaff.Role_ID)
            {
            case "AuthStaff":
            case "Manager":
                Requisition req = RequisitionController.getReqByID(id);
                toStaffList = StaffController.getStaffListById(req.SubmissionStaff_ID);
                break;

            case "Staff":

                toStaffList = StaffController.getApprovStaffListByDepId(fromStaff.Dept_ID);
                break;

            case "RepStaff":
                toStaffList = StaffController.getAllClerk();
                break;

            case "Supervisor":
                toStaffList = StaffController.getSManagerByid(fromStaff);
                break;
            }


            //define the message
            foreach (Staff toStaff in toStaffList)
            {
                string      emailAddressSend = "*****@*****.**";
                MailMessage email            = createNotificaition(toStaff, id);



                // define the mail server
                SmtpClient smtp = new SmtpClient();
                smtp.EnableSsl = true;
                smtp.Host      = "smtp.gmail.com";
                smtp.Port      = 25;

                // define the credential, already define in the app.config, no need show here
                smtp.UseDefaultCredentials = false;
                NetworkCredential NetWorkCre = new NetworkCredential(emailAddressSend, "System!@");
                smtp.Credentials = NetWorkCre;

                // later will change try catch to the code behind
                try
                {
                    smtp.Send(email);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.GetType());
                    Console.ReadLine();
                }
            }
        }
Exemplo n.º 2
0
        protected static MailMessage createNotificaition(Staff toStaff, string id)
        {
            string emailAddressSend = "*****@*****.**";

            string      emailAddressRec = toStaff.Email;
            MailMessage email           = new MailMessage();

            email.From = new MailAddress(emailAddressSend);
            email.To.Add(new MailAddress(emailAddressRec));
            email.IsBodyHtml = true;

            // need to be change later, for the url path
            //string requisitionLink = "path"+req.Requisition_ID;

            switch (toStaff.Role_ID)
            {
            case "Staff":
                Requisition requi = RequisitionController.getReqByID(id);
                email.Subject = "Requisition Approve notification";
                email.Body    = string.Format("<div> Dear {0},<br/> Your Requisition has been {1}.The RequisitionID is <P1>{2}</P1><hr/>This is System Email do not reply</div>", toStaff.Staff_Name, requi.Status, requi.Requisition_ID);
                break;

            case "AuthStaff":
            case "Manager":
                Requisition req = RequisitionController.getReqByID(id);
                email.Subject = "Requisition notification";
                email.Body    = string.Format("<div > Dear {0},<br/> You have Requisition to be approved.The RequisitionID is <P1>{1}</P1><hr/>This is System Email do not reply</div>", toStaff.Staff_Name, req.Requisition_ID);
                break;

            case "StoreClerk":

                email.Subject = "Disbursment Received Notification";
                email.Body    = string.Format("One Disbursment has been Recieved.The Disbursment ID is <P1>{0}</P1><hr/>This is System Email do not reply</div>", id);
                break;

            case "SManager":
                email.Subject = "Adjustment  Notification";
                email.Body    = string.Format("<div > Dear {0},<br/>A Adjustment Voucher has been more than 250 dollars.The Voucher ID is <P1>{0}</P1><hr/>This is System Email do not reply</div>", toStaff.Staff_Name, id);
                break;
            }


            return(email);
        }
Exemplo n.º 3
0
        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();
        }