Ejemplo n.º 1
0
        public JsonResult AddNotification(Notification notification)
        {
            var status = new NotificationDAO().Add(notification);

            NotificationHub.SendNotifications();
            return(Json(status, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public JsonResult Update(int ID)
        {
            var obj = new NotificationDAO().Update(ID);

            NotificationHub.SendNotifications();
            return(Json(obj, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a notification
        /// </summary>
        /// <param name="notification">NotificationCreationModel</param>
        /// <returns>NotificationModel</returns>
        public async Task <NotificationModel> CreateNotification(NotificationCreationModel notification)
        {
            var date = DateTime.UtcNow;

            NotificationDAO notificationDao = new NotificationDAO()
            {
                NotificationText = notification.NotificationText,
                CreationDate     = date,
                UpdateDate       = date,
                ResponseId       = notification.ResponseId.ToString(),
                Status           = notification.Status,
                Tags             = notification.Tags,
                Title            = notification.Title,
                User             = notification.User
            };

            notificationDao.Id = await _repoNotifications.CreateItemAsync(notificationDao);

            if (_repoNotifications.IsDocumentKeyNull(notificationDao))
            {
                throw new Exception($"An error occured when creating a new notification");
            }

            NotificationModel output = _mapper.Map <NotificationModel>(notificationDao);

            return(output);
        }
Ejemplo n.º 4
0
        /***********************this confirm button simulates the scene after scanning QRcode (only for Test)**********************************/
        /**********************To confirm specified dept disbursement**************************************************************/
        protected void Button3_Click(object sender, EventArgs e)
        {
            int disburseID = Convert.ToInt32(ViewState["disburseID"]);

            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('you are generate the Disbursement " + disburseID + " ?')", true);
            //here should send message box yes or no

            DisbursementDAO disDAO = new DisbursementDAO();

            //disburList
            ConfirmBtn.Enabled = false;
            disDAO.updateDisbursementStatus(Convert.ToInt32(ViewState["disburseID"]), "Completed");
            disburseGridView.SelectedIndex = -1;
            disburseBindGrid();
            disburseUpdatePanel.Update();
            disburseItemGridView.DataSource = null;
            disburseItemGridView.DataBind();

            //send email and notification to rep
            SA45_Team09_LogicUEntities context = new SA45_Team09_LogicUEntities();
            string          repID       = context.Departments.Where(x => x.deptID == deptid).Select(x => x.repStaffID).ToList().First();
            string          repName     = context.DeptStaffs.Where(x => x.staffID == repID).Select(x => x.staffName).ToList().First();
            string          confirmDate = DateTime.Now.ToShortDateString();
            NotificationDAO nDAO        = new NotificationDAO();

            nDAO.addDeptNotification(repID, "Disbursement " + disburseID + " is confirmed on " + confirmDate, DateTime.Now);

            Email email = new Email();

            email.sendConfirmedDisbursementEmailToRep(repName, confirmDate, disburseID.ToString());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                /////Line Chart Data
                BindDropdownlist();
                deptName  = dept_dropList.SelectedItem.Text;
                deptid    = dpd.findDepartmentIdByName(deptName);
                dataChart = getBarChartDataByDeptID(deptid);
            }
            string                   loginID = Session["loginID"].ToString();
            NotificationDAO          nDAO    = new NotificationDAO();
            List <StoreNotification> nList   = nDAO.getAllStoreNotificationByID(loginID);

            notice_Repeater.DataSource = nList;
            notice_Repeater.DataBind();
            foreach (StoreNotification item in nList)
            {
                nDAO.setStoreNotificationStatusAsOld(item.notificationID);
            }
            deptName = dept_dropList.SelectedItem.Text;
            deptid   = dpd.findDepartmentIdByName(deptName);
            ////Pie Chart Data
            pieChartData = getPieChartData();

            ////DepartmentRep Table Chart Data
            deptRepChartData = getDeptRepChartData();

            ////Outstanding Chart Data
            outstandingChartData = getOutstandingChartData(deptid);

            chartData.InnerHtml = "<script>var dataChart =" + dataChart + "; var pieData = " +
                                  pieChartData + "; var deptRepData = " + deptRepChartData +
                                  "; var outstandingData = " + outstandingChartData + ";</script>";
        }
Ejemplo n.º 6
0
        // GET: Admin/Notification
        public ActionResult Index(string SearchNotification, int page = 1, int pagesize = 4)
        {
            var dao   = new NotificationDAO();
            var model = dao.ListAllPaging(SearchNotification, page, pagesize);

            ViewBag.SearchNotification = SearchNotification;
            return(View(model));
        }
Ejemplo n.º 7
0
        public void LoadDetailNotification(Guid?nOTIFICATION_Id)
        {
            var dao = new NotificationDAO();
            // Call the broadcastMessage method to update clients.
            var model = dao.GetById(nOTIFICATION_Id);

            Clients.All.broadcastNotificationDetail(model.NOTIFICATION_To, model.ACCOUNT.ACCOUNT_Name, model.ACCOUNT.ACCOUNT_Avatar, model.NOTIFICATION_Content, model.NOTIFICATION_Time.Value.ToString("dd/MM/yyyy HH:mm"), model.NOTIFICATION_Url);
        }
Ejemplo n.º 8
0
        public void LoadNotification(Guid?To)
        {
            var dao = new NotificationDAO();

            // Call the broadcastMessage method to update clients.
            Notification = dao.ListNotification(To).Select(x => x.NOTIFICATION_Url).Distinct().Count();
            Clients.All.broadcastNotification(Notification, To);
        }
Ejemplo n.º 9
0
        public ActionResult Edit(long id)
        {
            var dao          = new NotificationDAO();
            var notification = dao.GetNotificationByID(id);

            setViewBag(notification.ID);

            return(View(notification));
        }
Ejemplo n.º 10
0
        protected int getTNFid()
        {
            TNFDAO          tnfDAO          = new TNFDAO();
            NotificationDAO notificationDAO = new NotificationDAO();

            int          notificationID      = Convert.ToInt32(Request.QueryString["n"]);
            Notification currentNotification = notificationDAO.getNotificationByID(notificationID);
            TNF          currentTNF          = tnfDAO.getIndividualTNFByID(currentNotification.getUserIDFrom(), currentNotification.getTNFID());

            return(currentTNF.getTNFID());
        }
Ejemplo n.º 11
0
        public ActionResult ListHistoryNotification()
        {
            var userprofile = Session["UserProfile"] as UserProfileVM;

            if (userprofile == null)
            {
                return(Json("", JsonRequestBehavior.AllowGet));
            }
            IEnumerable <NotificationViewModel> model = new NotificationDAO().GetHistoryNotification(userprofile.User.ID);

            return(View(model));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string                   loginID = Session["loginID"].ToString();
            NotificationDAO          nDAO    = new NotificationDAO();
            List <StoreNotification> nList   = nDAO.getAllStoreNotificationByID(loginID);

            notice_Repeater.DataSource = nList;
            notice_Repeater.DataBind();
            foreach (StoreNotification item in nList)
            {
                nDAO.setStoreNotificationStatusAsOld(item.notificationID);
            }
        }
Ejemplo n.º 13
0
        protected void btnApprover_Click(object sender, EventArgs e)
        {
            TNFDAO          tnfDAO          = new TNFDAO();
            UserDAO         userDAO         = new UserDAO();
            NotificationDAO notificationDAO = new NotificationDAO();

            TNF          tnf                  = tnfDAO.getIndividualTNFByID(GridView1.SelectedRow.Cells[1].Text, int.Parse(GridView1.SelectedRow.Cells[3].Text));
            User         currentUser          = userDAO.getUserByID(GridView1.SelectedRow.Cells[2].Text);
            Notification selectedNotification = notificationDAO.getNotificationByID(int.Parse(GridView1.SelectedRow.Cells[7].Text));

            Workflow_Approve.makeApproval(tnf, currentUser, selectedNotification, "");
            Response.Redirect("testIndividualRouting.aspx");
        }
        public JsonResult GetNotification(Guid?id)
        {
            var         model = new NotificationDAO().ListNotification(id).OrderByDescending(x => x.NOTIFICATION_Time).ToList();
            List <Guid> data  = new List <Guid>();
            string      url   = null;

            foreach (var item in model)
            {
                if (url != item.NOTIFICATION_Url)
                {
                    url = item.NOTIFICATION_Url;
                    data.Add(item.NOTIFICATION_Id);
                }
            }
            return(Json(new { data = data }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 15
0
        protected void cfmRejectBtn_Click(object sender, EventArgs e)
        {
            TNFDAO          tnfDAO          = new TNFDAO();
            UserDAO         userDAO         = new UserDAO();
            NotificationDAO notificationDAO = new NotificationDAO();

            int notificationID = Convert.ToInt32(Request.QueryString["n"]);

            Notification currentNotification = notificationDAO.getNotificationByID(notificationID);
            TNF          currentTNF          = tnfDAO.getIndividualTNFByID(currentNotification.getUserIDFrom(), currentNotification.getTNFID());
            User         approver            = userDAO.getUserByID(currentNotification.getUserIDTo());


            Workflow_Reject.makeRejection(currentTNF, approver, currentNotification, remarksInput.Text);
            Response.Redirect("rejectionConfirmation.aspx");
        }
Ejemplo n.º 16
0
        public async Task <bool> Create(Notification Notification)
        {
            NotificationDAO NotificationDAO = new NotificationDAO();

            NotificationDAO.Id                   = Notification.Id;
            NotificationDAO.Title                = Notification.Title;
            NotificationDAO.Content              = Notification.Content;
            NotificationDAO.OrganizationId       = Notification.OrganizationId;
            NotificationDAO.NotificationStatusId = Notification.NotificationStatusId;
            DataContext.Notification.Add(NotificationDAO);
            await DataContext.SaveChangesAsync();

            Notification.Id = NotificationDAO.Id;
            await SaveReference(Notification);

            return(true);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string loginRole = Session["loginRole"].ToString();

            if (loginRole == "supervisor")
            {
                Label1.Text = Session["loginName"].ToString();
                string loginID = Session["loginID"].ToString();
                img.Src = "../picture/" + loginID + ".jpg";
                NotificationDAO nDAO = new NotificationDAO();
                var             storeNotifications = nDAO.getNewStoreNotificationByID(loginID);
                notificationNum.Text = storeNotifications.Count().ToString();
            }
            else
            {
                Response.Redirect("login.aspx");
            }
        }
Ejemplo n.º 18
0
        public async Task <bool> BulkMerge(List <Notification> Notifications)
        {
            List <NotificationDAO> NotificationDAOs = new List <NotificationDAO>();

            foreach (Notification Notification in Notifications)
            {
                NotificationDAO NotificationDAO = new NotificationDAO();
                NotificationDAO.Id                   = Notification.Id;
                NotificationDAO.Title                = Notification.Title;
                NotificationDAO.Content              = Notification.Content;
                NotificationDAO.OrganizationId       = Notification.OrganizationId;
                NotificationDAO.NotificationStatusId = Notification.NotificationStatusId;
                NotificationDAOs.Add(NotificationDAO);
            }
            await DataContext.BulkMergeAsync(NotificationDAOs);

            return(true);
        }
Ejemplo n.º 19
0
        protected override void OnCustomCommand(int command)
        {
            EventLog.Source = "Deployment Update Windows Service";
            try
            {
                if (command == 0)
                {
                    this.EventLog.WriteEntry("Service stopping ...");
                    NotificationDAO.Stop();
                    host.Close();
                    host = null;
                    NotificationDAO.UpdateRegistered  -= new EventHandler <UpdateNotificationEventArgs>(NotificationDAO_UpdateRegistered);
                    NotificationDAO.WarningRegistered -= new EventHandler <UnhandledExceptionEventArgs>(NotificationDAO_WarningRegistered);
                    NotificationDAO.ErrorRegistered   -= new EventHandler <UnhandledExceptionEventArgs>(NotificationDAO_ErrorRegistered);
                }
                else if (command == 1)
                {
                    this.EventLog.WriteEntry("Service starting ...");
                    NotificationDAO.UpdateRegistered  += new EventHandler <UpdateNotificationEventArgs>(NotificationDAO_UpdateRegistered);
                    NotificationDAO.WarningRegistered += new EventHandler <UnhandledExceptionEventArgs>(NotificationDAO_WarningRegistered);
                    NotificationDAO.ErrorRegistered   += new EventHandler <UnhandledExceptionEventArgs>(NotificationDAO_ErrorRegistered);

                    if (host != null)
                    {
                        host.Close();
                    }
                    host = new ServiceHost(typeof(ConfigurationService));
                    host.Open();

                    EventLog.WriteEntry(String.Format("WCF ConfigurationService hosted at {0} ({1})", host.BaseAddresses.FirstOrDefault().AbsoluteUri, host.State));
                    NotificationDAO.Start();
                }
                else if (command == 2)
                {
                    this.EventLog.WriteEntry("Service restarting ...");
                    NotificationDAO.Stop();
                    NotificationDAO.Start();
                }
            }
            catch (Exception ex)
            {
                this.EventLog.WriteEntry(String.Format("Following error was encountered {0}{1}{0}{2}{0}{3}", Environment.NewLine, ex.Message, ex.InnerException != null?ex.InnerException.Message:String.Empty, ex.StackTrace), System.Diagnostics.EventLogEntryType.Error);
            }
        }
Ejemplo n.º 20
0
 //private readonly NotificationChannelDAO _notificationChannelDAO;
 //private readonly EmployeeDAO _employeeDAO;
 public StoreClerkController()
 {
     this._disbursementDAO         = new DisbursementDAO();
     this._requisitionDAO          = new RequisitionDAO();
     this._requisitionItemDAO      = new RequisitionItemDAO();
     this._stockRecordDAO          = new StockRecordDAO();
     this._disbursementItemDAO     = new DisbursementItemDAO();
     this._purchaseOrderDAO        = new PurchaseOrderDAO();
     this._itemDAO                 = new ItemDAO();
     this._statusDAO               = new StatusDAO();
     this._purchaseOrderDetailsDAO = new PurchaseOrderDetailsDAO();
     this._employeeDAO             = new EmployeeDAO();
     this._collectionpointDAO      = new CollectionPointDAO();
     this._notificationChannelDAO  = new NotificationChannelDAO();
     this._notificationDAO         = new NotificationDAO();
     this._supplierItemDAO         = new SupplierItemDAO();
     //this._notificationChannelDAO = new NotificationChannelDAO();
     //this._employeeDAO = new EmployeeDAO();
 }
Ejemplo n.º 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string loginRole = Session["loginRole"].ToString();

            if (loginRole == "head" || loginRole == "outOfOfficeHead" || loginRole == "delegeteHead")
            {
                Label1.Text = Session["loginName"].ToString();
                string loginID = Session["loginID"].ToString();
                loginRole = Session["loginRole"].ToString();
                img.Src   = "../picture/" + loginID + ".jpg";
                NotificationDAO nDAO = new NotificationDAO();
                var             deptNotifications = nDAO.getNewDeptNotificationByID(loginID);
                notificationNum.Text = deptNotifications.Count.ToString();
            }
            else
            {
                Response.Redirect("login.aspx");
            }
        }
Ejemplo n.º 22
0
        public async Task <bool> Update(Notification Notification)
        {
            NotificationDAO NotificationDAO = DataContext.Notification.Where(x => x.Id == Notification.Id).FirstOrDefault();

            if (NotificationDAO == null)
            {
                return(false);
            }
            NotificationDAO.Id                   = Notification.Id;
            NotificationDAO.Title                = Notification.Title;
            NotificationDAO.Content              = Notification.Content;
            NotificationDAO.OrganizationId       = Notification.OrganizationId;
            NotificationDAO.NotificationStatusId = Notification.NotificationStatusId;
            await DataContext.SaveChangesAsync();

            await SaveReference(Notification);

            return(true);
        }
        protected void btnUpdateRep_Click(object sender, EventArgs e)
        {
            //Update
            string    newRepName = ddlEmp.SelectedValue;
            DeptStaff newRep     = new DeptStaff();

            if (newRepName != "---Select Name---")
            {
                newRep    = deptStaffDAO.findStaffByName(newRepName);
                logInDept = newRep.deptID;
                Department dept   = deptDAO.findByDeptId(logInDept);
                DeptStaff  oldRep = deptStaffDAO.findDeptRep(logInDept);
                deptStaffDAO.updateRepName(newRep, oldRep);
                deptDAO.UpdateDeptRep(dept, newRep);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please Select Name First!')", true);
                return;
            }

            //send feedback email and notification to employee
            SA45_Team09_LogicUEntities context = new SA45_Team09_LogicUEntities();
            string headID    = Session["loginID"].ToString();
            string headName  = Session["loginName"].ToString();
            string staffID   = newRep.staffID;
            string staffName = newRepName;

            NotificationDAO nDAO = new NotificationDAO();

            nDAO.addDeptNotification(staffID, headName + " chose you as representative. ", DateTime.Now);

            Email email = new Email();

            email.sendRepNotificationToEmployee(staffName, headName);

            //Refesh display
            DisplayCurrentRep(logInDept);
            DisplayAvaliableEmp(logInDept);
            ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('', 'Successful!');</script>");
        }
Ejemplo n.º 24
0
        public JsonResult GetNotifications(int?userID)
        {
            var userprofile = Session["UserProfile"] as UserProfileVM;

            if (userID == null)
            {
                return(Json("", JsonRequestBehavior.AllowGet));
            }
            var listNotifications = new NotificationDAO().ListNotifications(userID.Value);
            var total             = 0;
            var listID            = new List <int>();

            foreach (var item in listNotifications)
            {
                if (item.Seen == false)
                {
                    total++;
                    listID.Add(item.ID);
                }
            }
            return(Json(new { arrayID = listID.ToArray(), total = total, data = listNotifications }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 25
0
        protected void submit_button_Click(object sender, EventArgs e)
        {
            string selectedStaffId = employee_dropList.SelectedValue.ToString();

            if (textBox_startDate.Text != "" || textBox_endDate.Text != "")
            {
                DateTime sDate = Convert.ToDateTime(textBox_startDate.Text);
                DateTime eDate = Convert.ToDateTime(textBox_endDate.Text);
                if (IsValidDate(sDate, eDate))
                {
                    delegateDAO.addDelegate(selectedStaffId, sDate, eDate);
                    bindData(deptID);

                    //send feedback email and notification to employee
                    SA45_Team09_LogicUEntities context = new SA45_Team09_LogicUEntities();
                    string headID    = Session["loginID"].ToString();
                    string headName  = Session["loginName"].ToString();
                    string staffID   = selectedStaffId;
                    string staffName = context.DeptStaffs.Where(x => x.staffID == staffID).Select(x => x.staffName).ToList().First();


                    NotificationDAO nDAO = new NotificationDAO();
                    nDAO.addDeptNotification(staffID, headName + " delegate you as head from " + sDate + " to " + eDate, DateTime.Now);

                    Email email = new Email();
                    email.sendDelegateEmailToEmployee(staffName, headName, sDate.ToShortDateString(), eDate.ToShortDateString());

                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Notice', 'Delegated succussfully!');</script>");
                }
                else
                {
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Notice', 'Please select valid date!');</script>");
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Notice', 'Please select valid date!');</script>");
            }
        }
Ejemplo n.º 26
0
        public IEnumerable <NotificationViewModel> GetAllNotifications(int UserID)
        {
            var messages = new List <NotificationViewModel>();

            using (var connection = new SqlConnection(_connString))
            {
                connection.Open();
                var sql = @"SELECT [ID]
                                  ,[UserID]
                                  ,[NotificationID]
                                  ,[Seen]
                                  ,[CreateTime]
                              FROM [KPI].[dbo].[NotificationDetails]";
                using (var command = new SqlCommand(sql, connection))
                {
                    //command.Parameters.AddWithValue("@UserID", UserID);
                    command.Notification = null;

                    var dependency = new SqlDependency(command);
                    dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);

                    if (connection.State == ConnectionState.Closed)
                    {
                        connection.Open();
                    }

                    var reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        //messages.Add(item: new NotificationViewModel { ID = reader["ID"].ToInt() , UserID=reader["UserID"].ToInt(),Username=reader["Username"].ToSafetyString(), KPIName = reader["KPIName"].ToSafetyString(), Period =  reader["Period"].ToSafetyString(), Seen = reader["Seen"].ToBool(), Link = reader["Link"].ToSafetyString(), CreateTime = Convert.ToDateTime(reader["CreateTime"]), Tag = reader["Tag"].ToSafetyString(),Title=reader["Title"].ToSafetyString() });
                    }
                    messages = new NotificationDAO().ListNotifications(UserID);
                }
            }

            return(messages);
        }
Ejemplo n.º 27
0
        protected void Btn_Approve_Click(object sender, EventArgs e)
        {
            string supervisor = (string)Session["loginID"];

            {
                if (dropdownlist1.Text != "---Select Clerk for this time---" && dropdownlist2.Text != "---Select Clerk for this time---" &&
                    dropdownlist3.Text != "---Select Clerk for this time---" && dropdownlist4.Text != "---Select Clerk for this time---" &&
                    dropdownlist5.Text != "---Select Clerk for this time---" && dropdownlist6.Text != "---Select Clerk for this time---")
                {
                    string staff1 = storeStaffDAO.getStoreStaffIDbyName(dropdownlist1.Text);
                    string staff2 = storeStaffDAO.getStoreStaffIDbyName(dropdownlist2.Text);
                    string staff3 = storeStaffDAO.getStoreStaffIDbyName(dropdownlist3.Text);
                    string staff4 = storeStaffDAO.getStoreStaffIDbyName(dropdownlist4.Text);
                    string staff5 = storeStaffDAO.getStoreStaffIDbyName(dropdownlist5.Text);
                    string staff6 = storeStaffDAO.getStoreStaffIDbyName(dropdownlist6.Text);

                    collectionDAO.updatecollection(staff1, Label_CollectionPoint1.Text);
                    collectionDAO.updatecollection(staff2, Label_CollectionPoint2.Text);
                    collectionDAO.updatecollection(staff3, Label_CollectionPoint3.Text);
                    collectionDAO.updatecollection(staff4, Label_CollectionPoint4.Text);
                    collectionDAO.updatecollection(staff5, Label_CollectionPoint5.Text);
                    collectionDAO.updatecollection(staff6, Label_CollectionPoint6.Text);

                    NotificationDAO nDAO           = new NotificationDAO();
                    string          supervisorName = Session["loginName"].ToString();
                    nDAO.addStoreNotification(staff1, supervisorName + " assigned you in collection point " + Label_CollectionPoint1.Text, DateTime.Now);
                    nDAO.addStoreNotification(staff2, supervisorName + " assigned you in collection point " + Label_CollectionPoint2.Text, DateTime.Now);
                    nDAO.addStoreNotification(staff3, supervisorName + " assigned you in collection point " + Label_CollectionPoint3.Text, DateTime.Now);
                    nDAO.addStoreNotification(staff4, supervisorName + " assigned you in collection point " + Label_CollectionPoint4.Text, DateTime.Now);
                    nDAO.addStoreNotification(staff5, supervisorName + " assigned you in collection point " + Label_CollectionPoint5.Text, DateTime.Now);
                    nDAO.addStoreNotification(staff6, supervisorName + " assigned you in collection point " + Label_CollectionPoint6.Text, DateTime.Now);
                }
                else
                {
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Notice', 'Please select all the clerks name for this time disbursements!');</script>");
                }
            }
        }
Ejemplo n.º 28
0
        protected void NotifyButton_Click(object sender, EventArgs e)
        {
            NotifyButton.Enabled = false;
            //send email and notification to rep
            Label  s          = disburseGridView.SelectedRow.FindControl("disburseIDLabel") as Label;
            string a          = s.Text;
            int    disburseID = Convert.ToInt32(a);
            SA45_Team09_LogicUEntities context = new SA45_Team09_LogicUEntities();
            Disbursement    disbursement       = disDAO.getDisbursmentbyId(disburseID);
            string          deptid             = disbursement.deptID;
            string          repID             = context.Departments.Where(x => x.deptID == deptid).Select(x => x.repStaffID).ToList().First();
            string          repName           = context.DeptStaffs.Where(x => x.staffID == repID).Select(x => x.staffName).ToList().First();
            string          disbursementDate  = disbursement.disburseDate.ToShortDateString();
            string          collectionPointID = context.Departments.Where(x => x.deptID == deptid).Select(x => x.collectionPointID).ToList().First();
            string          collectionPoint   = context.CollectionPoints.Where(x => x.collectionPointID == collectionPointID).Select(x => x.description).ToList().First();
            NotificationDAO nDAO = new NotificationDAO();

            nDAO.addDeptNotification(repID, "Disbursement " + disbursement.disbursementID + " is confirmed on " + disbursementDate, DateTime.Now);

            Email email = new Email();

            email.sendDisbursementEmailToRep(repName, disbursementDate, collectionPoint);
        }
        protected void btn_SendToManager_Click(object sender, EventArgs e)
        {
            AdjustmentVoucher adjv = adjvdao.findAdjustmentVoucherByadjvId(adjvoucherID);

            adjvdao.SendtoManageranother(adjv);//Method2

            //send email and notification to rep
            SA45_Team09_LogicUEntities context = new SA45_Team09_LogicUEntities();
            string     supervisorName          = Session["loginName"].ToString();
            StoreStaff manager     = context.StoreStaffs.Where(x => x.role == "manager").ToList().First();
            string     managerID   = manager.storeStaffID;
            string     managerName = manager.storeStaffName;

            string          confirmDate = DateTime.Now.ToShortDateString();
            NotificationDAO nDAO        = new NotificationDAO();

            nDAO.addStoreNotification(managerID, supervisorName + " has send an adjustment voucher!" + confirmDate, DateTime.Now);

            Email email = new Email();

            email.sendAdjustmentEmailToManager(supervisorName, managerName);

            Response.Redirect("./SS_ViewAdjustment.aspx");
        }
        protected void Btn_Reject_Click(object sender, EventArgs e)
        {
            string      remark = TextBox_Remarks.Text;
            Requisition req    = reqDAO.findRequisitionByrequisitionId(reqID);

            reqDAO.updateRequisition(req, remark, "Rejected");
            //send feedback email and notification to employee
            SA45_Team09_LogicUEntities context = new SA45_Team09_LogicUEntities();
            string headID          = Session["loginID"].ToString();
            string headName        = Session["loginName"].ToString();
            string staffID         = req.staffID;
            string staffName       = context.DeptStaffs.Where(x => x.staffID == staffID).Select(x => x.staffName).ToList().First();
            string requisitionDate = req.requisitionDate.ToString();

            NotificationDAO nDAO = new NotificationDAO();

            nDAO.addDeptNotification(staffID, headName + " rejected your requisition on " + requisitionDate, DateTime.Now);

            Email email = new Email();

            email.sendFeedBackEmailToEmployee(staffName, headName, requisitionDate, "Rejected");

            Response.Redirect("./DH_ViewPendingRequisition.aspx");
        }