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; } }