Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        UserAccessValidation();
        if (UDFLib.ConvertToInteger(Request.QueryString["IsPreference"]) == 1)
        {
            cmdApprove.Visible = false;
        }

        if (Request.QueryString["requestid"] != null)
        {
            try
            {
                requestID        = Convert.ToInt32(Request.QueryString["requestid"].ToString());
                ltRequestid.Text = requestID.ToString();
                if (!IsPostBack)
                {
                    BLL_TRV_TravelRequest objT  = new BLL_TRV_TravelRequest();
                    DataTable             dtsts = objT.Get_Request_ApprovalStatus(requestID);
                    if (dtsts.Rows.Count > 0)
                    {
                        if (dtsts.Rows[0]["Sent_For_Approval"].ToString() == "1" && dtsts.Rows[0]["currentStatus"].ToString() == "QUOTE RECEIVED")
                        {
                            IsApproving = 1;
                        }
                    }

                    ViewState["ChepeastAmount"] = null;

                    GetTravelRequestDetails();

                    GetCheapestOptions();

                    GetQuotationForEvaluation();
                    BLL_TRV_QuoteRequest objAppHis = new BLL_TRV_QuoteRequest();

                    gvApprovals.DataSource = objAppHis.Get_Approval_History(requestID);
                    gvApprovals.DataBind();

                    BLL_TRV_QuoteRequest QR = new BLL_TRV_QuoteRequest();


                    DataTable dt = QR.Get_Qtn_Approver_DeptMgr(0, 0);

                    lstMngApprList.DataSource = dt;
                    lstMngApprList.DataBind();
                    lstMngApprList.Items.Insert(0, new ListItem("SELECT", "0"));
                    lstMngApprList.SelectedIndex = 0;
                    ListItem itemrmv = lstMngApprList.Items.FindByValue(Session["userid"].ToString());
                    lstMngApprList.Items.Remove(itemrmv);


                    ListBoxPOApprover.DataSource = QR.Get_Qtn_Approver();
                    ListBoxPOApprover.DataBind();
                    ListBoxPOApprover.Items.Insert(0, new ListItem("SELECT", "0"));
                    ListBoxPOApprover.SelectedIndex = 0;

                    lstMngApprList.Items.Remove(itemrmv);
                }
            }
            catch { }
        }
    }
Exemple #2
0
    protected void cmdApprove_Click(object sender, EventArgs e)
    {
        BLL_TRV_QuoteRequest  QR       = new BLL_TRV_QuoteRequest();
        BLL_TRV_TravelRequest TRequest = new BLL_TRV_TravelRequest();



        int result;

        try
        {
            string qid           = "";
            string QSupplierCode = "";
            try
            {
                qid           = Request.Form["rdQuote"].ToString().Split(',')[0];
                QSupplierCode = Request.Form["rdQuote"].ToString().Split(',')[1];
            }
            catch (Exception)
            {
                string msgmodal = String.Format("alert('Approver not Selected!');");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Approver", msgmodal, true);
                return;
            }


            if (!String.IsNullOrEmpty(qid))
            {
                DataTable dtSuppDate = BLL_PURC_Common.Get_Supplier_ValidDate("'" + QSupplierCode + "'");
                if (dtSuppDate.Rows.Count > 0)
                {
                    if (Convert.ToDateTime(dtSuppDate.Rows[0]["ASL_Status_Valid_till"]) < DateTime.Now)
                    {
                        String msg = String.Format("alert('Selected agent has been expired/blacklisted');");
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg451", msg, true);
                    }
                    else
                    {
                        QR.Insert_Approval_Entry(Convert.ToInt32(Session["USERID"].ToString()),
                                                 Convert.ToInt32(Session["USERID"].ToString()),
                                                 decimal.Parse(hdf_Totalamount.Value.Trim()),
                                                 Convert.ToInt32(Request.QueryString["requestid"].ToString()), "", txtApproverRemark.Text, 1, UDFLib.ConvertIntegerToNull(qid));

                        decimal Approval_limit = QR.Get_Approveal_Limit(Convert.ToInt32(Session["userid"]));
                        //decimal Approval_limit = 1000;
                        if (Approval_limit > 0 && (decimal.Parse(hdf_Totalamount.Value.Trim()) <= Approval_limit))
                        {
                            int Mail_ID;
                            result = QR.ApproveQuotation(requestID, Convert.ToInt32(qid),
                                                         Convert.ToInt32(Session["USERID"].ToString()), txtApproverRemark.Text, out Mail_ID);
                            if (result > -1)
                            {
                                //add PO as attachment to mail

                                DataTable dtPO = QR.Get_Generate_PO_PDF(Request.QueryString["requestid"]);
                                if (dtPO.Rows.Count > 0)
                                {
                                    string fileName = Convert.ToString(dtPO.Rows[0]["ORDER_CODE"]).Replace('-', '_') + DateTime.Now.ToString("yyMMddss") + ".pdf";
                                    GeneratePOAsPDF(dtPO, fileName, Mail_ID);
                                }


                                if (result > 0) // SQ Flight has been approved
                                {
                                    UTF8Encoding         utf8     = new UTF8Encoding();
                                    System.Net.WebClient myClient = new System.Net.WebClient();

                                    string currentPageUrl           = ConfigurationManager.AppSettings["INVFolderPath"] + "/travel/Evaluation_view.aspx?requestid=" + Request.QueryString["requestid"];
                                    byte[] requestHTML; requestHTML = myClient.DownloadData(currentPageUrl);
                                    string ReportPageHTML           = utf8.GetString(requestHTML);

                                    BLL_Crew_CrewDetails objMail = new BLL_Crew_CrewDetails();
                                }


                                string msgmodal = String.Format(" alert('Quotation has been approved successfully');self.close();window.opener.location.reload();");
                                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ApprmodalFinalApproved", msgmodal, true);
                            }
                        }
                        else
                        {
                            lstUserList.DataSource = QR.Get_Qtn_Approver();
                            lstUserList.DataBind();
                            lstUserList.Items.Insert(0, new ListItem("SELECT", "0"));
                            lstUserList.SelectedIndex = 0;
                            ListItem itemrmv = lstUserList.Items.FindByValue(Session["userid"].ToString());
                            lstUserList.Items.Remove(itemrmv);

                            string msgmodal = String.Format("showModal('divSendForApproval');");
                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Apprmodal", msgmodal, true);
                        }
                    }
                }
            }
            else
            {
                string msgmodal = String.Format(" alert('Please select option to approve'); ");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "optiotoapprove", msgmodal, true);
            }
        }
        catch (Exception ex)
        {
            string msgmodal = "alert('" + ex.Message + "');";
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "errorex", msgmodal, true);
        }
        finally { QR = null; TRequest = null; }
    }
    protected void rptParent_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            if ("SENDTICKET" == e.CommandName)
            {
                string             UploadFilePath = ConfigurationManager.AppSettings["TRV_UPLOAD_PATH"];
                BLL_TRV_Attachment objatt         = new BLL_TRV_Attachment();
                int    MailID = objatt.Send_Ticket(int.Parse(e.CommandArgument.ToString()), int.Parse(Session["userid"].ToString()));
                string URL    = String.Format("window.open('../crew/EmailEditor.aspx?ID=+" + MailID.ToString() + @"&FILEPATH=" + UploadFilePath.Remove(UploadFilePath.Length - 1, 1).Replace(@"\", @"\\") + "');");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "k" + MailID.ToString(), URL, true);
            }

            if (e.CommandName == "delete")
            {
                BLL_TRV_TravelRequest TRequest = new BLL_TRV_TravelRequest();
                TRequest.CancelRequest(Convert.ToInt32(e.CommandArgument), Convert.ToInt32(Session["USERID"].ToString()));
                TRequest            = null;
                ViewState["Status"] = "";

                string jsc = @"__doPostBack('ctl00$MainContent$lnkMenu' + currentlink, '')";

                //  string msgmodal = String.Format("asyncGet_Quote_Count_Approval(" + e.CommandArgument.ToString() + ",'divSendForApproval');");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "jsc", jsc, true);
            }
            if (e.CommandName == "refund")
            {
                hdnRequestID.Value      = e.CommandArgument.ToString();
                lblRequestIDRefund.Text = "Request ID : " + e.CommandArgument.ToString();
                string js = "showModal('dvPopup_Refund');";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "jsPopup_Refund", js, true);
            }
            if (e.CommandName == "RequestApproval")
            {
                BLL_TRV_QuoteRequest QR = new BLL_TRV_QuoteRequest();

                ViewState["RequestID_App"] = e.CommandArgument.ToString();
                hdnRequestID_App.Value     = e.CommandArgument.ToString();


                DataTable dt = QR.Get_Qtn_Approver_DeptMgr(0, 0);

                lstUserList.DataSource = dt;
                lstUserList.DataBind();
                lstUserList.Items.Insert(0, new ListItem("SELECT", "0"));
                lstUserList.SelectedIndex = 0;
                ListItem itemrmv = lstUserList.Items.FindByValue(Session["userid"].ToString());
                lstUserList.Items.Remove(itemrmv);


                ListBoxPOApprover.DataSource = QR.Get_Qtn_Approver();
                ListBoxPOApprover.DataBind();
                ListBoxPOApprover.Items.Insert(0, new ListItem("SELECT", "0"));
                ListBoxPOApprover.SelectedIndex = 0;

                lstUserList.Items.Remove(itemrmv);

                string msgmodal = String.Format("asyncGet_Quote_Count_Approval(" + e.CommandArgument.ToString() + ",'divSendForApproval');");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Apprmodal", msgmodal, true);
            }
        }
        catch { }
    }