protected void btnSendForApproval_Click(object s, EventArgs e) { BLL_TRV_QuoteRequest QR = new BLL_TRV_QuoteRequest(); BLL_TRV_TravelRequest TRequest = new BLL_TRV_TravelRequest(); BLL_Infra_UserCredentials objuser = new BLL_Infra_UserCredentials(); DataTable dtuser = objuser.Get_UserDetails(Int32.Parse(lstUserList.SelectedValue)); DataTable dtCurrentuser = objuser.Get_UserDetails(Convert.ToInt32(Session["userid"])); QR.Insert_Approval_Entry(Convert.ToInt32(Session["USERID"].ToString()), Int32.Parse(lstUserList.SelectedValue), 0, Convert.ToInt32(Request.QueryString["requestid"].ToString()), txtRemark.Text, ""); string msgmodal = String.Format("alert('Sent successfully to selected approver.');window.close();window.opener.location.reload();"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Apprmodal", msgmodal, true); }
protected void btnSendForApprovalByPIC_Click(object s, EventArgs e) { BLL_TRV_QuoteRequest QR = new BLL_TRV_QuoteRequest(); int ApproverID = 0; int ForApproval; if (lstMngApprList.SelectedItem.Value == "0" && ListBoxPOApprover.SelectedItem.Value != "0") // sending for po approval { ApproverID = int.Parse(ListBoxPOApprover.SelectedItem.Value); ForApproval = 1; } else if (lstMngApprList.SelectedItem.Value != "0" && ListBoxPOApprover.SelectedItem.Value == "0")// sending for Manager approval { ApproverID = int.Parse(lstMngApprList.SelectedItem.Value); ForApproval = 2; } else if (lstMngApprList.SelectedItem.Value == "0" && ListBoxPOApprover.SelectedItem.Value == "0") // atleat one should be selected { lblMessageOnSendApproval.Visible = true; lblMessageOnSendApproval.Text = "Please select Approver !"; return; } else // both can not be selected at a time { lblMessageOnSendApproval.Visible = true; lblMessageOnSendApproval.Text = "PO approver and Managerial approver can not be selected simultaneously !"; return; } if (ApproverID != 0) { QR.Insert_Approval_Entry(UDFLib.ConvertToInteger(Session["USERID"].ToString()), ApproverID, 0, UDFLib.ConvertToInteger(Request.QueryString["requestid"]), txtSendForAppRemark.Text, "", ForApproval); string msgmodal = String.Format("alert('Request sent successfully');hideModal('divSendForApproval');window.close();window.opener.location.reload();"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Apprmodal", msgmodal, true); } }
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; } }