Example #1
0
    public void btnAdd_Click(object sender, EventArgs e)
    {
        DropDownList ddlinstaller = (DropDownList)Installers.FindControl("ddlInstallers");

        if (esn_sim.Text.Length == 0 && nua_data.Text.Length == 0 && chip.Text.Length == 0 && SelectedEMNo.Text.Length == 0)
        {
            lblValidation.Visible = true;
            lblDropValid.Visible  = false;
            pnlConfirm.Visible    = false;
        }
        else if ((Session[enumSessions.SelectedInstaller.ToString()] == null && enablePostCodeSearch == true) || (ddlinstaller.SelectedValue == "" && enablePostCodeSearch == false))
        {
            lblValidation.Visible = false;
            lblDropValid.Visible  = true;
            pnlConfirm.Visible    = false;
        }
        else
        {
            lblValidation.Visible = false;
            lblDropValid.Visible  = false;

            if (Request.QueryString["dr"].ToString() == "d")
            {
                if (SelectedEMNo.Text.Length > 0 && SelectedEMNo.Text != " ") // ** Emizon
                {
                    if (string.IsNullOrWhiteSpace(SelectedEMNo.Text))
                    {
                        string script = "alertify.alert('" + "Valid EMNo is required." + "');";
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                        return;
                    }

                    if (IsInDisconnectionslist(SelectedEMNo.Text))
                    {
                        string script = "alertify.alert('" + "Unit on Disconnections list already" + "');";
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                        return;
                    }

                    int    RequestReference = EmizonService.AddtoEmizonRequestQueue(SelectedEMNo.Text, typeof(Emizon.APIModels.MSMQTypes.QueueReadytoCease).Name);
                    string emizonQueuePath  = ConfigurationManager.AppSettings["EmizonQueue"].ToString();
                    EmizonOrderController.AddtoMSMQ(emizonQueuePath, new Emizon.APIModels.MSMQTypes.QueueReadytoCease()
                    {
                        em_no    = SelectedEMNo.Text.Trim(),
                        arc_no   = ArcBAL.GetEmizonArcNobyARCID(Session[enumSessions.ARC_Id.ToString()].ToString()),
                        CSLRefNo = RequestReference.ToString()
                    });

                    string ResponseMessage = string.Empty;
                    string ResponseVal     = EmizonService.WaitandGetResponse(RequestReference, ref ResponseMessage);

                    if (string.IsNullOrEmpty(ResponseVal))
                    {
                        string script = "alertify.alert('" + "Unable to verify if unit can be disconnected, please try again later" + "');";
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);

                        return;
                    }
                    else if (ResponseVal != "0")
                    {
                        string script = "alertify.alert('" + "Unit not ready for disconnection due to : " + ResponseMessage + "');";
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);

                        return;
                    }
                    else
                    {
                        ProceedwithRequest(true);
                        return;
                    }
                }
                else // ** CSL Unit
                {
                    if (!string.IsNullOrWhiteSpace(esn_sim.Text))
                    {
                        if (HighilghtRecentPolling(esn_sim.Text))
                        {
                            ProceedwithRequest();
                            string script = "alertify.alert('" + "Please note this Unit has been active in the last 7 days." + "');";
                            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                            return;
                        }
                    }
                }
            }
            ProceedwithRequest();
        }
    }
Example #2
0
    public void btnAdd_Click(object sender, EventArgs e)
    {
        db = new LinqToSqlDataContext();

        DropDownList ddlinstaller = (DropDownList)Installers.FindControl("ddlInstallers");
        string       selectedTo   = (Convert.ToInt32(ddlTo.SelectedValue) / 100).ToString();
        string       selectedFrom = (Convert.ToInt32(ddlFrom.SelectedValue) / 100).ToString();

        if (esn_sim.Text.Length == 0 && nua_data.Text.Length == 0 && chip.Text.Length == 0 && SelectedEMNo.Text.Length == 0)
        {
            lblValidation.Visible  = true;
            lblDropValid.Visible   = false;
            pnlConfirm.Visible     = false;
            lblUpValid.Visible     = false;
            lblDownValid.Visible   = false;
            lblFromToValid.Visible = false;
        }
        else if (Request["dr"].ToString() != "r" && (selectedTo == "0" || selectedFrom == "0"))
        {
            lblFromToValid.Visible = true;
            lblValidation.Visible  = false;
            lblDropValid.Visible   = false;
            lblUpValid.Visible     = false;
            lblDownValid.Visible   = false;
        }
        else if (Request["dr"].ToString() == "r" && ddlTo.SelectedValue == "0")
        {
            lblFromToValid.Visible = true;
            lblValidation.Visible  = false;
            lblDropValid.Visible   = false;
            lblUpValid.Visible     = false;
            lblDownValid.Visible   = false;
        }
        else if (Request["dr"].ToString() == "u" && Convert.ToInt32(selectedTo) < Convert.ToInt32(selectedFrom))
        {
            lblUpValid.Visible     = true;
            lblValidation.Visible  = false;
            lblDropValid.Visible   = false;
            pnlConfirm.Visible     = false;
            lblFromToValid.Visible = false;
        }
        else if (Request["dr"].ToString() == "d" && Convert.ToInt32(selectedTo) > Convert.ToInt32(selectedFrom))
        {
            lblDownValid.Visible   = true;
            lblValidation.Visible  = false;
            lblDropValid.Visible   = false;
            pnlConfirm.Visible     = false;
            lblFromToValid.Visible = false;
        }

        else if ((Session[enumSessions.SelectedInstaller.ToString()] == null && enablePostCodeSearch == true) || (ddlinstaller.SelectedValue == "" && enablePostCodeSearch == false))
        {
            lblUpValid.Visible     = false;
            lblValidation.Visible  = false;
            lblDropValid.Visible   = true;
            pnlConfirm.Visible     = false;
            lblFromToValid.Visible = false;
            lblDownValid.Visible   = false;
        }
        else
        {
            lblValidation.Visible  = false;
            lblDropValid.Visible   = false;
            lblUpValid.Visible     = false;
            lblDownValid.Visible   = false;
            lblFromToValid.Visible = false;


            if (Request.QueryString["dr"].ToString() == "r")
            {
                if (string.IsNullOrWhiteSpace(SelectedEMNo.Text))
                {
                    string script = "alertify.alert('" + "Valid EMNo is required." + "');";
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                    return;
                }
                DateTime RegradeDateTime;
                if (DateTime.TryParse(txtRegradeDateTime.Text, out RegradeDateTime) == false)
                {
                    string script = "alertify.alert('" + "Regrade Time should be a valid future date and time " + "');";
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                    return;
                }

                if (RegradeDateTime <= DateTime.Now.AddMinutes(-5))
                {
                    string script = "alertify.alert('" + "Regrade Time should be a valid future date and time " + "');";
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                    return;
                }

                if (IsInRegradelist(SelectedEMNo.Text))
                {
                    string script = "alertify.alert('" + "Unit on Regrade list already" + "');";
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                    return;
                }

                int RequestReference = EmizonService.AddtoEmizonRequestQueue(SelectedEMNo.Text, typeof(Emizon.APIModels.MSMQTypes.QueueRegradecheckprep).Name);

                EmizonOrderController.AddtoMSMQ(ConfigurationManager.AppSettings["EmizonQueue"].ToString(), new Emizon.APIModels.MSMQTypes.QueueRegradecheckprep()
                {
                    em_no       = SelectedEMNo.Text.Trim(),
                    CSLRefNo    = RequestReference.ToString(),
                    new_product = ddlTo.SelectedValue,
                    arc_no      = ArcBAL.GetEmizonArcNobyARCID(Session[enumSessions.ARC_Id.ToString()].ToString())
                });
                string ResponseMessage = string.Empty;
                string ResponseVal     = EmizonService.WaitandGetResponse(RequestReference, ref ResponseMessage);

                if (string.IsNullOrEmpty(ResponseVal))
                {
                    string script = "alertify.alert('" + "Unable to verify if unit can be regraded, please try again later" + "');";
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);

                    return;
                }
                else if (ResponseVal == "11") //** Engineer Required
                {
                    ProceedwithRequest(true, true);
                    string script = "alertify.alert('" + "An Engineer visit is required as operation cannot be completed remotely." + "');";
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                }
                else if (ResponseVal == "0")
                {
                    ProceedwithRequest(true, false);
                    return;
                }
                else
                {
                    string script = "alertify.alert('" + "This unit is not available for a Regrade due to : " + ResponseMessage + "');";
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);

                    return;
                }
            }
            else
            {
                ProceedwithRequest();
            }
        }
    }