Пример #1
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());
        }
Пример #2
0
        protected void reSubmit_Click(object sender, EventArgs e)
        {
            SA45_Team09_LogicUEntities context = new SA45_Team09_LogicUEntities();
            RequisitionDAO             rdao    = new RequisitionDAO();

            Requisition newRequisition = new Requisition();
            Requisition oldRequisition = rdao.findRequisitionByrequisitionId(reqID);

            if (oldRequisition.status != "pending")
            {
                newRequisition.staffID         = oldRequisition.staffID;
                newRequisition.deptID          = oldRequisition.deptID;
                newRequisition.requisitionDate = DateTime.Now;
                newRequisition.status          = "pending";

                context.Requisitions.Add(newRequisition);

                var oldRequisitionItemsList = oldRequisition.RequisitionItems;
                foreach (RequisitionItem item in oldRequisitionItemsList)
                {
                    RequisitionItem newItem = new RequisitionItem();
                    newItem.requisitionID  = newRequisition.requisitionID;
                    newItem.itemID         = item.itemID;
                    newItem.requisitionQty = item.requisitionQty;

                    context.RequisitionItems.Add(newItem);
                }
                context.SaveChanges();
                Response.Redirect("Emp_MyRequisition.aspx");
            }
            else
            {
                ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Warning', 'You can not resubmit a pending requisition!');</script>");
            }
        }
Пример #3
0
        public int updateDisbursementItemByItemID(cartList_JSON cart_JSON, string disID)
        {
            List <WCFDisbursementCart> cart_wcf = cart_JSON.DiscartList;
            int disID_int = Int32.Parse(disID);

            using (SA45_Team09_LogicUEntities context = new SA45_Team09_LogicUEntities())
            {
                List <DisbursementItem> ldisitem = context.DisbursementItems.Where(x => x.disbursementID == (disID_int)).ToList();
                for (int i = 0; i < cart_wcf.Count; i++)
                {
                    foreach (var j in ldisitem)
                    {
                        if (j.itemID == cart_wcf[i].ItemID)
                        {
                            j.actualQty = cart_wcf[i].Actual;
                            break;
                        }
                    }
                }
                try
                {
                    context.SaveChanges();
                    return(1);
                }
                catch (Exception e)
                {
                    return(0);
                }
            }
        }
        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>");
        }
Пример #5
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>");
            }
        }
Пример #6
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");
        }
Пример #9
0
 private void Initialize()
 {
     instance = new SA45_Team09_LogicUEntities();
 }
        protected void Submit_Click(object sender, EventArgs e)
        {
            string name = this.staffID;
            SA45_Team09_LogicUEntities       m   = new DBEntities().getDBInstance();
            List <AdjustmentVoucherItemcart> lac = new List <AdjustmentVoucherItemcart>();

            lac = (List <AdjustmentVoucherItemcart>)Session["adjvcart"];
            if (lac.Count > 0)
            {
                int num   = 0;
                int judge = 0;
                foreach (Control i in cartRepeater.Items)                                     //get Quantity
                {
                    LinkButton deletebtn  = i.FindControl("cart_deleteButton") as LinkButton; //get itemID
                    TextBox    cartqty    = i.FindControl("cart_qtyTextBox") as TextBox;      //get quantity
                    TextBox    cartrecord = i.FindControl("cart_recordTextBox") as TextBox;   //get record
                    lac[num].ItemID = deletebtn.CommandArgument.ToString();
                    if (cartqty.Text.Trim() == "")
                    {
                        judge = 1;
                        break;
                    }
                    try
                    {
                        lac[num].Qty = Int32.Parse(cartqty.Text.ToString());
                    }
                    catch
                    {
                        judge = 1;
                        break;
                    }
                    if ((lac[num].Qty % 1 != 0) || (lac[num].Qty == 0))
                    {
                        judge = 1;
                        break;
                    }
                    if ((lac[num].Qty < 0) && (Math.Abs(lac[num].Qty) > itemDAO.getItemByitemID(lac[num].ItemID).First().qtyOnHand))
                    {
                        judge = 2;
                        break;
                    }
                    lac[num].Record = cartrecord.Text;
                    num++;
                }
                if (judge == 0)
                {
                    AdjustmentVoucherDAO adjvdao = new AdjustmentVoucherDAO();
                    adjvdao.addAdjustmentVoucher(name, lac);
                    lac = new List <AdjustmentVoucherItemcart>();//clear the cart session
                    Session["adjvcart"] = lac;

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

                    string          confirmDate = DateTime.Now.ToShortDateString();
                    NotificationDAO nDAO        = new NotificationDAO();
                    nDAO.addStoreNotification(supervisorID, clerkName + " has send an adjustment voucher!" + confirmDate, DateTime.Now);

                    Email email = new Email();
                    email.sendAdjustmentEmailToSupervisor(clerkName, supervisorName);

                    HttpContext.Current.Response.Redirect("SC_ViewAdjustmentVoucher.aspx");
                }
                else
                {
                    if (judge == 1)
                    {
                        ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Notice', 'Input must be integer!');</script>");
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Notice', 'Input must be lower than qty on hand!');</script>");
                    }
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage2", "alert('Nothing in cart')", true);
                return;
            }
        }