Ejemplo n.º 1
0
        protected void chk_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox    chk = (CheckBox)sender;
            GridViewRow gv  = (GridViewRow)chk.NamingContainer;

            foreach (GridViewRow gvr in gvPurchase.Rows)
            {
                if (gvr != gv)
                {
                    ((CheckBox)gvr.FindControl("chk")).Checked = false;
                }
            }

            if (chk.Checked)
            {
                Business.Service.TonerRequest ObjBl = new Business.Service.TonerRequest();
                DataTable dt = ObjBl.Service_Toner_GetAllByCustomerId(long.Parse(gvPurchase.DataKeys[gv.RowIndex].Values[0].ToString()));
                if (dt != null)
                {
                    gvTonner.DataSource = dt;
                    gvTonner.DataBind();
                }

                Business.Service.ServiceBook objServiceBook = new Business.Service.ServiceBook();
                DataSet dsLastMeterReading = objServiceBook.Service_GetLastMeterReadingByCustomerPurchaseId(Int64.Parse(gvPurchase.DataKeys[gv.RowIndex].Values[0].ToString()));
                lblA3BWLastMeterReading.Text = dsLastMeterReading.Tables[0].Rows[0]["A3BWLastMeterReading"].ToString();
                lblA3ClLastMeterReading.Text = dsLastMeterReading.Tables[0].Rows[0]["A3CLLastMeterReading"].ToString();
                lblA4BWLastMeterReading.Text = dsLastMeterReading.Tables[0].Rows[0]["A4BWLastMeterReading"].ToString();
                lblA4ClLastMeterReading.Text = dsLastMeterReading.Tables[0].Rows[0]["A4CLLastMeterReading"].ToString();
            }
            else
            {
                gvTonner.DataBind();
            }
        }
        protected void LoadTonnerRequest()
        {
            Business.Service.TonerRequest objTonerRequest = new Business.Service.TonerRequest();
            Entity.Service.TonerRequest   tonerRequest    = new Entity.Service.TonerRequest();

            tonerRequest.PageIndex           = gvTonnerRequest.PageIndex;
            tonerRequest.PageSize            = gvTonnerRequest.PageSize;
            tonerRequest.RequestNo           = txtTonnerRequestNo.Text.Trim();
            tonerRequest.CustomerName        = txtCustomerName.Text.Trim();
            tonerRequest.ProductId           = int.Parse(ddlProduct.SelectedValue);
            tonerRequest.RequestFromDateTime = (txtFromTonnerRequestDate.Text == "") ? DateTime.MinValue : Convert.ToDateTime(txtFromTonnerRequestDate.Text);
            tonerRequest.RequestToDateTime   = (txtToTonnerRequestDate.Text == "") ? DateTime.MinValue : Convert.ToDateTime(txtToTonnerRequestDate.Text);
            tonerRequest.CallStatusId        = int.Parse(ddlCallStatus.SelectedValue);
            if (HttpContext.Current.User.IsInRole(Entity.HR.Utility.CUSTOMER_LIST_SHOW_ALL))
            {
                tonerRequest.AssignEngineer = 0;
            }
            else
            {
                tonerRequest.AssignEngineer = int.Parse(HttpContext.Current.User.Identity.Name);
            }

            DataSet response = objTonerRequest.Service_TonerRequest_GetAll(tonerRequest);

            if (response != null)
            {
                gvTonnerRequest.DataSource       = response.Tables[0];
                gvTonnerRequest.VirtualItemCount = (response.Tables[1].Rows.Count > 0) ? Convert.ToInt32(response.Tables[1].Rows[0]["TotalCount"].ToString()) : 20;
                gvTonnerRequest.DataBind();
            }
        }
        private void LoadTonerRequest(int pageIndex, int pageSize)
        {
            Business.Service.TonerRequest objTonnerRequest = new Business.Service.TonerRequest();
            Entity.Service.TonerRequest   tonerRequest     = new Entity.Service.TonerRequest();

            tonerRequest.PageIndex = pageIndex;
            tonerRequest.PageSize  = pageSize;
            string callStatusIds = string.Empty;

            callStatusIds = string.Concat(((int)CallStatusType.TonerOpenForApproval).ToString(),
                                          ",",
                                          ((int)CallStatusType.TonerRequestInQueue).ToString(),
                                          ",",
                                          ((int)CallStatusType.TonerResponseGiven).ToString());

            tonerRequest.MultipleCallStatusFilter = callStatusIds;
            if (HttpContext.Current.User.IsInRole(Entity.HR.Utility.CUSTOMER_LIST_SHOW_ALL))
            {
                tonerRequest.AssignEngineer = 0;
            }
            else
            {
                tonerRequest.AssignEngineer = int.Parse(HttpContext.Current.User.Identity.Name);
            }

            DataSet response = objTonnerRequest.Service_TonnerRequest_GetAllMinimal(tonerRequest);

            gvTonnerRequestAsync.DataSource       = response.Tables[0];
            gvTonnerRequestAsync.VirtualItemCount = (response.Tables[1].Rows.Count > 0) ? Convert.ToInt32(response.Tables[1].Rows[0]["TotalCount"].ToString()) : 10;
            gvTonnerRequestAsync.DataBind();
        }
        protected void LoadTonnerRequest()
        {
            Business.Service.TonerRequest objTonnerRequest = new Business.Service.TonerRequest();
            DataTable dt = objTonnerRequest.Service_TonerRequest_GetLast10();

            if (dt != null)
            {
                gvTonnerRequest.DataSource = dt;
                gvTonnerRequest.DataBind();
            }
        }
Ejemplo n.º 5
0
        protected void LoadTonnerRequest()
        {
            Business.Service.TonerRequest objTonnerRequest = new Business.Service.TonerRequest();
            Entity.Service.TonerRequest   tonnerRequest    = new Entity.Service.TonerRequest();

            tonnerRequest.CustomerId = int.Parse(HttpContext.Current.User.Identity.Name.Split('|')[(int)Constants.Customer.ID]);
            DataTable dt = objTonnerRequest.Service_TonerRequest_GetAll(tonnerRequest).Tables[0];

            if (dt != null && dt.Rows.Count > 0)
            {
                gvTonnerRequest.DataSource = dt.AsEnumerable().Take(5).CopyToDataTable();
            }
            else
            {
                gvTonnerRequest.DataSource = null;
            }

            gvTonnerRequest.DataBind();
        }
        private List <Models.TonerModel> GetToner(int employeeId)
        {
            List <Models.TonerModel> model = new List <Models.TonerModel>();

            Business.Service.TonerRequest objTonnerRequest = new Business.Service.TonerRequest();

            Business.HR.EmployeeMaster objEmployeeMaster = new Business.HR.EmployeeMaster();
            Entity.HR.EmployeeMaster   employeeMaster    = new Entity.HR.EmployeeMaster();
            DataTable dtEmployee = objEmployeeMaster.EmployeeMaster_ById(new Entity.HR.EmployeeMaster()
            {
                EmployeeMasterId = employeeId
            });

            if (dtEmployee.AsEnumerable().Any())
            {
                employeeMaster = objEmployeeMaster.AuthenticateUser(dtEmployee.Rows[0]["EmployeeCode"].ToString());
            }

            int assignEngineer = 0;

            if (employeeMaster != null)
            {
                string[] roles = employeeMaster.Roles.Split(',');
                if (roles.Contains(Entity.HR.Utility.CUSTOMER_LIST_SHOW_ALL))
                {
                    assignEngineer = 0;
                }
                else
                {
                    assignEngineer = employeeId;
                }
            }

            string callStatusIds = string.Empty;

            callStatusIds = string.Concat(((int)CallStatusType.TonerOpenForApproval).ToString(),
                                          ",",
                                          ((int)CallStatusType.TonerRequestInQueue).ToString(),
                                          ",",
                                          ((int)CallStatusType.TonerResponseGiven).ToString());

            DataTable response = objTonnerRequest.Service_Toner_GetByCallStatusIds(callStatusIds, assignEngineer);

            if (response != null &&
                response.AsEnumerable().Any())
            {
                foreach (DataRow dr in response.Rows)
                {
                    model.Add(new Models.TonerModel
                    {
                        CallStatus    = string.Format("Call Status: {0}", dr["CallStatus"].ToString()),
                        ContactPerson = string.Format("Contact Person: {0}", dr["ContactPerson"].ToString()),
                        CustomerName  = string.Format("Customer Name: {0}", dr["CustomerName"].ToString()),
                        TonerDateTime = string.Format("Toner Date & Time: {0}", Convert.ToDateTime(dr["RequestDate"].ToString()).ToString("dd MMM yyyy")),
                        TonerNo       = string.Format("Toner No: {0}", dr["TonnerRequestId"].ToString()),
                        ProductName   = string.Format("Product Name: {0}", dr["ProductName"].ToString())
                    });
                }
            }

            return(model);
        }
Ejemplo n.º 7
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (ComplainValidation())
            {
                Business.Service.TonerRequest objTonnerRequest = new Business.Service.TonerRequest();
                Entity.Service.TonerRequest   tonnerRequest    = new Entity.Service.TonerRequest();
                Business.Service.ServiceBook  objServiceBook   = new Business.Service.ServiceBook();
                Entity.Service.ServiceBook    serviceBook      = new Entity.Service.ServiceBook();

                foreach (GridViewRow gvr in gvPurchase.Rows)
                {
                    if (((CheckBox)gvr.FindControl("chk")).Checked)
                    {
                        tonnerRequest.CustomerPurchaseId = int.Parse(gvPurchase.DataKeys[gvr.RowIndex].Values[0].ToString());
                        serviceBook.CustomerPurchaseId   = int.Parse(gvPurchase.DataKeys[gvr.RowIndex].Values[0].ToString());
                    }
                }

                tonnerRequest.CustomerId      = int.Parse(HttpContext.Current.User.Identity.Name.Split('|')[(int)Constants.Customer.ID]);;
                tonnerRequest.RequestNo       = "";
                tonnerRequest.RequestDateTime = DateTime.Now;
                tonnerRequest.isCustomerEntry = true;
                tonnerRequest.CallStatusId    = (int)CallStatusType.TonerRequestInQueue;
                if (txtA3BWMeterReading.Text.Trim() == string.Empty)
                {
                    tonnerRequest.A3BWMeterReading = null;
                }
                else
                {
                    tonnerRequest.A3BWMeterReading = int.Parse(txtA3BWMeterReading.Text.Trim());
                }
                if (txtA4BWMeterReading.Text.Trim() == string.Empty)
                {
                    tonnerRequest.A4BWMeterReading = null;
                }
                else
                {
                    tonnerRequest.A4BWMeterReading = int.Parse(txtA4BWMeterReading.Text.Trim());
                }
                if (txtA3CLMeterReading.Text.Trim() == string.Empty)
                {
                    tonnerRequest.A3CLMeterReading = null;
                }
                else
                {
                    tonnerRequest.A3CLMeterReading = int.Parse(txtA3CLMeterReading.Text.Trim());
                }
                if (txtA4CLMeterReading.Text.Trim() == string.Empty)
                {
                    tonnerRequest.A4CLMeterReading = null;
                }
                else
                {
                    tonnerRequest.A4CLMeterReading = int.Parse(txtA4CLMeterReading.Text.Trim());
                }
                tonnerRequest.Remarks   = txtRequest.Text.Trim();
                tonnerRequest.CreatedBy = int.Parse(HttpContext.Current.User.Identity.Name.Split('|')[(int)Constants.Customer.ID]);

                foreach (GridViewRow toner in gvTonner.Rows)
                {
                    if (((CheckBox)toner.FindControl("chk1")).Checked)
                    {
                        tonnerRequest.SpareIds.Add(new TonerIdQuantity
                        {
                            TonerId  = long.Parse(gvTonner.DataKeys[toner.RowIndex].Values[0].ToString()),
                            Quantity = int.Parse(((TextBox)toner.FindControl("txtRequisiteQty")).Text)
                        });
                    }
                }

                if (txtA3BWMeterReading.Text.Trim() == string.Empty)
                {
                    serviceBook.A3BWMeterReading = null;
                }
                else
                {
                    serviceBook.A3BWMeterReading = int.Parse(txtA3BWMeterReading.Text.Trim());
                }
                if (txtA4BWMeterReading.Text.Trim() == string.Empty)
                {
                    serviceBook.A4BWMeterReading = null;
                }
                else
                {
                    serviceBook.A4BWMeterReading = int.Parse(txtA4BWMeterReading.Text.Trim());
                }
                if (txtA3CLMeterReading.Text.Trim() == string.Empty)
                {
                    serviceBook.A3CLMeterReading = null;
                }
                else
                {
                    serviceBook.A3CLMeterReading = int.Parse(txtA3CLMeterReading.Text.Trim());
                }
                if (txtA4CLMeterReading.Text.Trim() == string.Empty)
                {
                    serviceBook.A4CLMeterReading = null;
                }
                else
                {
                    serviceBook.A4CLMeterReading = int.Parse(txtA4CLMeterReading.Text.Trim());
                }

                DataTable dtTonnerRequest     = objTonnerRequest.Service_TonerRequest_Save(tonnerRequest);
                bool      isTonerLowYield     = objTonnerRequest.Service_TonerLowYieldCheck(tonnerRequest);
                int       meterUpdateResponse = objServiceBook.Service_MeterReading_Update(serviceBook);

                if (dtTonnerRequest.Rows.Count > 0 && meterUpdateResponse > 0)
                {
                    string message = "Toner request received. Your request no : " + dtTonnerRequest.Rows[0]["TonnerRequestNo"].ToString() + ". ";

                    /* Checking whether machine is in contract or not*/
                    Business.Service.Contract objContract = new Business.Service.Contract();
                    int approvalResponse = Approval_Save(tonnerRequest, dtTonnerRequest, isTonerLowYield);

                    if (!objContract.Service_MachineIsInContractCheck(CustomerPurchaseId) || isTonerLowYield) //Out of Contract AND Low Yield
                    {
                        if (approvalResponse > 0)
                        {
                            //Appending low toner warning
                            message += Server.HtmlDecode("<span style='color:red'>Warning: Your request is under verification</span>");
                            //SentNotification(objServiceBook, dtTonnerRequest);
                        }
                    }
                    ResetControls(dtTonnerRequest);
                    Message.IsSuccess = true;
                    Message.Text      = message;
                }
                else
                {
                    Message.IsSuccess = false;
                    Message.Text      = "Sorry! we can not receive your request. Please try again.";
                }
                Message.Show = true;
            }
        }