protected void gvApproval_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Business.Service.ServiceBook objServiceBook = new Business.Service.ServiceBook();
            Entity.Service.ServiceBook   serviceBook    = new Entity.Service.ServiceBook();

            int         approvalId       = int.Parse(e.CommandArgument.ToString());
            int         approvalResponse = 0;
            GridViewRow row     = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);
            string      comment = ((TextBox)row.FindControl("txtComment")).Text.Trim();

            using (DataTable dtApproval = new DataTable())
            {
                dtApproval.Columns.Add("ApprovalId");
                dtApproval.Columns.Add("ServiceBookId");
                dtApproval.Columns.Add("ItemId");
                dtApproval.Columns.Add("ApprovalStatus");
                dtApproval.Columns.Add("IsLowYield");
                dtApproval.Columns.Add("CallStatus");
                dtApproval.Columns.Add("RespondBy");
                dtApproval.Columns.Add("Comment");
                dtApproval.Columns.Add("RequisiteQty");

                DataRow drApprovalItem = dtApproval.NewRow();
                drApprovalItem["ApprovalId"]     = approvalId;
                drApprovalItem["ServiceBookId"]  = 0;
                drApprovalItem["ItemId"]         = 0;
                drApprovalItem["ApprovalStatus"] = (e.CommandName == "Approve") ? (int)ApprovalStatus.Approved : (int)ApprovalStatus.Rejected;
                drApprovalItem["RespondBy"]      = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
                drApprovalItem["Comment"]        = comment;
                dtApproval.Rows.Add(drApprovalItem);
                dtApproval.AcceptChanges();

                serviceBook.ApprovalItems = dtApproval;
                serviceBook.ApprovalItems.AcceptChanges();
                approvalResponse = objServiceBook.Service_ServiceBookDetailsApproval_Save(serviceBook);

                if (approvalResponse > 0)
                {
                    Service_ServiceBookDetailsApproval_GetAll();
                    Message.IsSuccess = true;
                    Message.Text      = "Toner response has been given.";
                }
                else
                {
                    Message.IsSuccess = false;
                    Message.Text      = "Toner response failed.";
                }
                Message.Show = true;
            }
        }
Exemplo n.º 2
0
        private static int Approval_Save(Entity.Service.TonerRequest tonnerRequest, DataTable dtTonnerRequest, bool isLowYield)
        {
            int approvalResponse = 0;

            Business.Service.ServiceBook objServiceBook = new Business.Service.ServiceBook();
            Entity.Service.ServiceBook   serviceBook    = new Entity.Service.ServiceBook();

            using (DataTable dtApproval = new DataTable())
            {
                dtApproval.Columns.Add("ApprovalId");
                dtApproval.Columns.Add("ServiceBookId");
                dtApproval.Columns.Add("ItemId");
                dtApproval.Columns.Add("ApprovalStatus");
                dtApproval.Columns.Add("IsLowYield");
                dtApproval.Columns.Add("CallStatus");
                dtApproval.Columns.Add("RespondBy");
                dtApproval.Columns.Add("Comment");
                dtApproval.Columns.Add("RequisiteQty");
                foreach (TonerIdQuantity item in tonnerRequest.SpareIds)
                {
                    DataRow drApprovalItem = dtApproval.NewRow();
                    drApprovalItem["ApprovalId"]     = 0;
                    drApprovalItem["ServiceBookId"]  = dtTonnerRequest.Rows[0]["ServiceBookId"].ToString();
                    drApprovalItem["ItemId"]         = item.TonerId;
                    drApprovalItem["ApprovalStatus"] = (isLowYield) ? (int)ApprovalStatus.None : (int)ApprovalStatus.Approved;
                    drApprovalItem["IsLowYield"]     = isLowYield;
                    drApprovalItem["CallStatus"]     = (isLowYield) ? (int)CallStatusType.TonerOpenForApproval : (int)CallStatusType.TonerRequestInQueue;
                    drApprovalItem["RespondBy"]      = string.Empty;
                    drApprovalItem["Comment"]        = (isLowYield) ? "NEED TONER APPROVAL" : "AUTO APPROVED";
                    drApprovalItem["RequisiteQty"]   = item.Quantity;
                    dtApproval.Rows.Add(drApprovalItem);
                    dtApproval.AcceptChanges();
                }
                serviceBook.ApprovalItems = dtApproval;
                serviceBook.ApprovalItems.AcceptChanges();
                approvalResponse = objServiceBook.Service_ServiceBookDetailsApproval_Save(serviceBook);
                return(approvalResponse);
            }
        }