protected void GeneratePOAsPDF(DataTable dt, string FileName, int EmailID) { string repFilePath = Server.MapPath("TRVPOReport.rpt"); ReportDocument repDoc = new ReportDocument(); repDoc.Load(repFilePath); repDoc.SetDataSource(dt); ExportOptions exp = new ExportOptions(); DiskFileDestinationOptions dk = new DiskFileDestinationOptions(); PdfRtfWordFormatOptions pd = new PdfRtfWordFormatOptions(); string destFile = Server.MapPath("../Uploads/Travel") + "\\" + FileName; dk.DiskFileName = destFile; //string Network_Path = System.Configuration.ConfigurationManager.AppSettings["APP_URL"].ToString()+@"Uploads\Travel\"; string Network_Path = @"Uploads\Travel\"; exp.ExportDestinationType = ExportDestinationType.DiskFile; exp.ExportFormatType = ExportFormatType.PortableDocFormat; exp.DestinationOptions = dk; exp.FormatOptions = pd; repDoc.Export(exp); BLL_Infra_Common.Insert_EmailAttachedFile(EmailID, FileName, Network_Path + FileName); }
protected void BtnSendEmail_Click(object sender, EventArgs e) { try { int rowcount = ucCustomPagerItems.isCountRecord; DataSet ds = objJobStatus.TecJobDoneNotDoneSummarySearch(UDFLib.ConvertIntegerToNull(DDLFleet.SelectedValue), UDFLib.ConvertIntegerToNull(DDLVessel.SelectedValue), null, null, null, null, ucCustomPagerItems.CurrentPageIndex, ucCustomPagerItems.PageSize, ref rowcount); ExcelDataPMSJob objExpJob = new ExcelDataPMSJob(); StringBuilder sbEmailbody = new StringBuilder(); string Attachfilename = ""; string CaptainName = "", ChiefEnggName = ""; objExpJob.WriteExcell(ds, ref Attachfilename); string sToEmailAddress = ds.Tables[2].Rows[0]["Vessel_email"].ToString(), strEmailAddCc = ds.Tables[2].Rows[0]["Fleet_email"].ToString() + ";" + ds.Tables[2].Rows[0]["Fleet_Suprintendent"].ToString(), strFormatSubject = "PMS Jobs updating status"; DataTable dtRequesterDetails = ojbInfra.Get_UserDetails(Convert.ToInt32(Session["userid"].ToString())); if (ds.Tables[1].Rows.Count > 0) { CaptainName = ds.Tables[1].Rows[0]["Staff_Name"].ToString(); } else { CaptainName = ""; } if (ds.Tables[3].Rows.Count > 0) { ChiefEnggName = ds.Tables[3].Rows[0]["Staff_Name"].ToString(); } else { ChiefEnggName = ""; } sbEmailbody.Append("Dear Capt. " + CaptainName + " & C/E " + ChiefEnggName + ","); sbEmailbody.AppendLine("<br><br>"); sbEmailbody.AppendLine("<br><br>"); sbEmailbody.AppendLine("<br><br>"); sbEmailbody.AppendLine("<br><br>"); sbEmailbody.AppendLine("<br>"); sbEmailbody.AppendLine("<br>"); sbEmailbody.AppendLine("Best Regards,"); sbEmailbody.AppendLine("<br>"); sbEmailbody.AppendLine(dtRequesterDetails.Rows[0]["User_name"].ToString().ToUpper() + " " + dtRequesterDetails.Rows[0]["Last_Name"].ToString().ToUpper()); sbEmailbody.AppendLine("<br>"); sbEmailbody.AppendLine(dtRequesterDetails.Rows[0]["Designation"].ToString()); sbEmailbody.AppendLine("<br>"); sbEmailbody.AppendLine(Convert.ToString(Session["Company_Address_GL"])); sbEmailbody.AppendLine("<br>"); /* Make Entry for email nofification */ int MailID = objBLLCrew.Send_CrewNotification(0, 0, 0, 0, sToEmailAddress, strEmailAddCc, "", strFormatSubject, sbEmailbody.ToString(), "", "MAIL", "", UDFLib.ConvertToInteger(Session["USERID"].ToString()), "DRAFT"); //string uploadpath = @"\\server01\uploads\PmsJobs"; //string uploadpath = @"\\" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "" + @"\uploads\PmsJobs"; string uploadpath = @"uploads\PmsJobs"; /* Make Entry for email attachment */ BLL_Infra_Common.Insert_EmailAttachedFile(MailID, Attachfilename, uploadpath + @"\" + Attachfilename); string URL = String.Format("window.open('/" + System.Configuration.ConfigurationManager.AppSettings["APP_NAME"].ToString() + "/crew/EmailEditor.aspx?ID=+" + MailID.ToString() + "');"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "k" + MailID.ToString(), URL, true); } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); string js = "alert('" + UDFLib.GetException("SystemError/ GeneralMessage") + "');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "error", js, true); } }
public void SendEmailToSupplier(DataSet dsEmailInfo, string strSuppCode, string strServerIPAdd, string Attachment, bool bIsListed, string RFQType, bool IsInsert_Mail) { try { DataTable dtSuppDetails = new DataTable(); string strFormatSubject = "", strFormatBody = "", sToEmailAddress = ""; BLL_Infra_UserCredentials objUser = new BLL_Infra_UserCredentials(); DataTable dtUser = objUser.Get_UserDetails(Convert.ToInt32(Session["USERID"])); string strEmailAddCc = dtUser.Rows[0]["MailID"].ToString(); int value = Int32.Parse(RFQType); BLL_Crew_CrewDetails objMail = new BLL_Crew_CrewDetails(); int MailID = 0; String URL = ""; string UploadFilePath = ConfigurationManager.AppSettings["PURC_UPLOAD_PATH"]; switch (value) { case 1: // Excel Based RFQ FormateEmail(dsEmailInfo, true, strServerIPAdd, out sToEmailAddress, out strFormatSubject, out strFormatBody, bIsListed, Attachment); MailID = objMail.Send_CrewNotification(0, 0, 0, 0, sToEmailAddress, strEmailAddCc, "", strFormatSubject, strFormatBody, "", "MAIL", "", UDFLib.ConvertToInteger(Session["USERID"].ToString()), "DRAFT"); //string uploadpath = @"\\server01\uploads\Purchase"; string uploadpath = @"uploads\Purchase"; BLL_Infra_Common.Insert_EmailAttachedFile(MailID, FileName, uploadpath + @"\" + FileName); URL = String.Format("window.open('../crew/EmailEditor.aspx?ID=+" + MailID.ToString() + @"&FILEPATH=" + UploadFilePath + "');"); ScriptManager.RegisterStartupScript(thispage, thispage.GetType(), "k" + MailID.ToString(), URL, true); break; case 2: // Web Based RFQ FormateEmail(dsEmailInfo, false, strServerIPAdd, out sToEmailAddress, out strFormatSubject, out strFormatBody, bIsListed, ""); MailID = objMail.Send_CrewNotification(0, 0, 0, 0, sToEmailAddress, strEmailAddCc, "", strFormatSubject, strFormatBody, "", "MAIL", "", UDFLib.ConvertToInteger(Session["USERID"].ToString()), "DRAFT"); //URL = String.Format("alert('web');"); URL = String.Format("window.open('../crew/EmailEditor.aspx?ID=+" + MailID.ToString() + @"&FILEPATH=" + UploadFilePath + "');"); ScriptManager.RegisterStartupScript(thispage, thispage.GetType(), "k" + MailID.ToString(), URL, true); break; case 3: FormateEmailOnRework(dsEmailInfo, false, strServerIPAdd, out sToEmailAddress, out strFormatSubject, out strFormatBody, bIsListed, ""); MailID = objMail.Send_CrewNotification(0, 0, 0, 0, sToEmailAddress, strEmailAddCc, "", strFormatSubject, strFormatBody, "", "MAIL", "", UDFLib.ConvertToInteger(Session["USERID"].ToString()), "READY"); URL = String.Format("window.open('../crew/EmailEditor.aspx?ID=+" + MailID.ToString() + @"&FILEPATH=" + UploadFilePath + "');"); ScriptManager.RegisterStartupScript(thispage, thispage.GetType(), "k" + MailID.ToString(), URL, true); break; } } catch (Exception ex) { } }
protected void SendPurchaseOrder() { // string[] Attchment = new string[10]; lblError.Text = ""; string strPath = Server.MapPath(".") + "\\SendPO\\"; DataTable DsPO = new DataTable(); DataSet dsSendMailInfo = new DataSet(); BLL_Infra_UserCredentials objUser = new BLL_Infra_UserCredentials(); DataTable dtUser = objUser.Get_UserDetails(Convert.ToInt32(Session["USERID"])); string emailIDcc = dtUser.Rows[0]["MailID"].ToString(); bool IsPO = false; int i = 0; string sDlvIns = txtdlvins.Text != "" ? txtdlvins.Text : DBNull.Value.ToString(); string strDeliveryPort = DDLPort.SelectedItem.ToString() != "--Select--" ? DDLPort.SelectedValue.ToString() : DBNull.Value.ToString(); string sEta = txteta.Text != "" ? txteta.Text + " " + txtETAAPPM.Text.ToString().Trim() + ":00" : Convert.ToString("01/01/1900"); string sRemark = txtremark.Text != "" ? txtremark.Text : DBNull.Value.ToString(); string sAgent = txtagent.Text != "" ? txtagent.Text : DBNull.Value.ToString(); string sEtd = txtetd.Text != "" ? txtetd.Text + " " + txtETDAMPM.Text.ToString().Trim() + ":00" : Convert.ToString("01/01/1900"); foreach (GridViewRow gvRow in gvLPOList.Rows) { CheckBox chk = (CheckBox)(gvRow.FindControl("chkSelectLPO") as CheckBox); string order_code = gvLPOList.DataKeys[gvRow.RowIndex].Value.ToString(); if ((chk.Checked)) { string OrderCode = gvLPOList.DataKeys[gvRow.RowIndex].Value.ToString(); int sts = BLL_PURC_LOG.Upd_Log_Order_Details(sDlvIns, strDeliveryPort, DateTime.Parse(sEta), sRemark, DateTime.Parse(sEtd), sAgent, Request.QueryString["LOG_ID"], order_code, Convert.ToInt32(Session["USERID"])); DsPO = BLL_PURC_LOG.Get_Log_Raise_PO(order_code, Request.QueryString["LOG_ID"]); dsSendMailInfo = BLL_PURC_LOG.Get_RaisePO_EmailInfo(order_code, Request.QueryString["LOG_ID"], Convert.ToInt32(Session["USERID"])); string FileName = "PO_" + OrderCode + "_" + ReplaceSpecialCharacterinFileName(DsPO.Rows[0]["SHORT_NAME"].ToString()) + DateTime.Now.ToString("yyMMddss") + ".pdf"; string sToEmailAddress = "", strSubject = "", strEmailBody = ""; //Generate the PDF file and check the include amount status DataTable dtPO = DsPO; if (rbtnIncludeAmount.Checked == false) { int ipo = 0; foreach (DataRow dr in dtPO.Rows) { dtPO.Rows[ipo]["currency"] = ""; dtPO.Rows[ipo]["exchange_rate"] = 0; dtPO.Rows[ipo]["quoted_rate"] = 0; dtPO.AcceptChanges(); ipo++; } } GeneratePOAsPDF(dtPO, strPath, FileName); FormateEmail(dsSendMailInfo, out sToEmailAddress, out strSubject, out strEmailBody, false, OrderCode); BLL_Crew_CrewDetails objMail = new BLL_Crew_CrewDetails(); int MailID = 0; MailID = objMail.Send_CrewNotification(0, 0, 0, 0, sToEmailAddress, emailIDcc, "", strSubject, strEmailBody, "", "MAIL", "", UDFLib.ConvertToInteger(Session["USERID"].ToString()), "DRAFT"); string UploadFilePath = ConfigurationManager.AppSettings["PURC_UPLOAD_PATH"]; //string uploadpath = @"\\server01\uploads\Purchase"; string uploadpath = @"uploads\Purchase"; BLL_Infra_Common.Insert_EmailAttachedFile(MailID, FileName, uploadpath + @"\" + FileName); string URL = String.Format("window.open('../crew/EmailEditor.aspx?ID=+" + MailID.ToString() + @"&FILEPATH=" + UploadFilePath + "');"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "k" + MailID.ToString(), URL, true); // ResponseHelper.Redirect("../crew/EmailEditor.aspx?ID=" + MailID.ToString(), "blank", ""); } } String msg1 = String.Format("window.open('','_self') ;window.close() ;"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", msg1, true); dvRaiselPo.Visible = false; btnSendOrder.Enabled = true; }
protected void SendPurchaseOrder() { // string[] Attchment = new string[10]; lblError.Text = ""; string strPath = Server.MapPath(".") + "\\SendPO\\"; DataSet DsPO = new DataSet(); DataSet dsSendMailInfo = new DataSet(); BLL_Infra_UserCredentials objUser = new BLL_Infra_UserCredentials(); DataTable dtUser = objUser.Get_UserDetails(Convert.ToInt32(Session["USERID"])); string emailIDcc = dtUser.Rows[0]["MailID"].ToString(); bool IsPO = false; if (rgdSuppliers.MasterTableView.Items.Count > 0) { foreach (GridDataItem dataItem in rgdSuppliers.MasterTableView.Items) { CheckBox chk = (CheckBox)(dataItem.FindControl("chkSendOrder") as CheckBox); if ((chk.Checked)) { IsPO = true; } } } if (rgdSuppliers.MasterTableView.Items.Count > 0) { int i = 0; if (IsPO) { DataTable dtQuotationList = new DataTable(); dtQuotationList.Columns.Add("Qtncode"); dtQuotationList.Columns.Add("amount"); string sDlvIns = txtdlvins.Text != "" ? txtdlvins.Text : DBNull.Value.ToString(); string strDeliveryPort = DDLPort.SelectedItem.ToString() != "--Select--" ? DDLPort.SelectedValue.ToString() : DBNull.Value.ToString(); string sEta = txteta.Text != "" ? txteta.Text + " " + txtETAAPPM.Text.ToString().Trim() + ":00" : Convert.ToString("01/01/1900"); string sRemark = txtremark.Text != "" ? txtremark.Text : DBNull.Value.ToString(); string sAgent = txtagent.Text != "" ? txtagent.Text : DBNull.Value.ToString(); string sEtd = txtetd.Text != "" ? txtetd.Text + " " + txtETDAMPM.Text.ToString().Trim() + ":00" : Convert.ToString("01/01/1900"); foreach (GridDataItem dataItem in rgdSuppliers.MasterTableView.Items) { CheckBox chk = (CheckBox)(dataItem.FindControl("chkSendOrder") as CheckBox); string chkAppStatus = dataItem["APPROVED_Status"].Text; if ((chk.Checked) && dataItem["APPROVED_Status"].Text == "YES") { i++; using (BLL_PURC_Purchase objTechService = new BLL_PURC_Purchase()) { DataRow drQTN = dtQuotationList.NewRow(); drQTN["Qtncode"] = dataItem["QUOTATION_CODE"].Text.ToString(); drQTN["amount"] = "0"; dtQuotationList.Rows.Add(drQTN); string OrderCode = dataItem["ORDER_CODE"].Text; int sts = objTechService.PMSUpdOtherPODetails(sDlvIns, strDeliveryPort, sEta, sRemark, sEtd, sAgent, Request.QueryString["Document_Code"].ToString(), Request.QueryString["Requisitioncode"].ToString(), Convert.ToInt32(Request.QueryString["Vessel_Code"].ToString()), dataItem["QUOTATION_CODE"].Text.ToString(), dataItem["SUPPLIER"].Text.ToString(), Convert.ToInt32(Session["USERID"].ToString())); DsPO = objTechService.GetDataToGeneratPO(Request.QueryString["Requisitioncode"].ToString(), Request.QueryString["Vessel_Code"].ToString(), dataItem["SUPPLIER"].Text.ToString(), dataItem["QUOTATION_CODE"].Text, Request.QueryString["Document_Code"].ToString()); dsSendMailInfo = objTechService.GetRFQsuppInfoSendEmail(dataItem["SUPPLIER"].Text.ToString(), dataItem["QUOTATION_CODE"].Text, Request.QueryString["Vessel_Code"].ToString(), Request.QueryString["Document_Code"].ToString(), Session["userid"].ToString()); string FileName = "PO_" + Request.QueryString["Vessel_Code"].ToString() + "_" + OrderCode + "_" + dataItem["SUPPLIER"].Text.ToString() + ReplaceSpecialCharacterinFileName(dataItem["SHORT_NAME"].Text) + DateTime.Now.ToString("yyMMddss") + ".pdf"; string sToEmailAddress = "", strSubject = "", strEmailBody = ""; //Generate the PDF file and check the include amount status DataTable dtPO = DsPO.Tables[0]; if (rbtnIncludeAmount.Checked == false) { int ipo = 0; foreach (DataRow dr in dtPO.Rows) { dtPO.Rows[ipo]["currency"] = ""; dtPO.Rows[ipo]["exchange_rate"] = 0; dtPO.Rows[ipo]["quoted_rate"] = 0; dtPO.AcceptChanges(); ipo++; } } GeneratePOAsPDF(dtPO, strPath, FileName); //Attchment.SetValue(strPath + FileName, 0); // objTechService.ChangeSupplierPOStatus(Request.QueryString["Requisitioncode"].ToString(), Request.QueryString["Document_Code"].ToString(), Request.QueryString["Vessel_Code"].ToString()); //Format Email body. FormateEmail(dsSendMailInfo, out sToEmailAddress, out strSubject, out strEmailBody, false, OrderCode); //Send Email to selected supplier. // // Email.SendEMailForPO("*****@*****.**", sToEmailAddress, "", "", strSubject, strEmailBody, Attchment); BLL_Crew_CrewDetails objMail = new BLL_Crew_CrewDetails(); int MailID = 0; MailID = objMail.Send_CrewNotification(0, 0, 0, 0, sToEmailAddress, emailIDcc, "", strSubject, strEmailBody, "", "MAIL", "", UDFLib.ConvertToInteger(Session["USERID"].ToString()), "DRAFT"); string UploadFilePath = ConfigurationManager.AppSettings["PURC_UPLOAD_PATH"]; //string uploadpath = @"\\server01\uploads\Purchase"; string uploadpath = @"uploads\Purchase"; BLL_Infra_Common.Insert_EmailAttachedFile(MailID, FileName, uploadpath + @"\" + FileName); string URL = String.Format("window.open('../crew/EmailEditor.aspx?ID=+" + MailID.ToString() + @"&FILEPATH=" + UploadFilePath + "');"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "k" + MailID.ToString(), URL, true); // ResponseHelper.Redirect("../crew/EmailEditor.aspx?ID=" + MailID.ToString(), "blank", ""); } } else if ((chk.Checked) && dataItem["APPROVED_Status"].Text == "NO") { String msg = String.Format("alert('Purchase order can not be raise because PO has not been approved.');"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", msg, true); } } using (BLL_PURC_Purchase objTechService = new BLL_PURC_Purchase()) { //Update the requistion Stage Status objTechService.InsertRequisitionStageStatus(Request.QueryString["Requisitioncode"].ToString(), Request.QueryString["Vessel_Code"].ToString(), Request.QueryString["Document_Code"].ToString(), "SCN", sRemark, Convert.ToInt32(Session["userid"]), dtQuotationList); } if (i == rgdSuppliers.MasterTableView.Items.Count) { String msg1 = String.Format("window.close();"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", msg1, true); } else { String msg1 = String.Format("alert('Purchase order has been raised successfully.'); "); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", msg1, true); } BindRequisitionInfo(); //AddToSyncronizer.AddToSyncroNizerData("PURC_Dtl_Supply_Items"); //AddToSyncronizer.AddToSyncroNizerData("PURC_Dtl_Reqsn"); //AddToSyncronizer.AddToSyncroNizerData("PURC_Dtl_Reqsn_Status"); BindGrid(); divpurcomment.Visible = false; btnSendOrder.Enabled = true; } else { String msg2 = String.Format("alert('Select alteast one quotation to raise the PO.')"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", msg2, true); //lblError.Text = "Select alteast one check box to raise the PO."; } } else { String msg3 = String.Format("alert('There is no quotation selected to Send the PO.')"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", msg3, true); //lblError.Text = "There is No data to Send the Purchase Order"; } }
protected void ImgbtnReSendPO_Click(object s, CommandEventArgs e) { try { string[] strIds = e.CommandArgument.ToString().Split(','); string Requisitioncode = strIds[0].ToString(); string Document_Code = strIds[1].ToString(); string Vessel_Code = strIds[2].ToString(); string SUPPLIER = strIds[3].ToString(); string OrderCode = strIds[4].ToString(); string QUOTATION_CODE = strIds[5].ToString(); string strPath = Server.MapPath(".") + "\\SendPO\\"; DataSet DsPO = new DataSet(); DataSet dsSendMailInfo = new DataSet(); BLL_Infra_UserCredentials objUser = new BLL_Infra_UserCredentials(); DataTable dtUser = objUser.Get_UserDetails(Convert.ToInt32(Session["USERID"])); string emailIDcc = dtUser.Rows[0]["MailID"].ToString(); using (BLL_PURC_Purchase objTechService = new BLL_PURC_Purchase()) { DsPO = objTechService.GetDataToGeneratPO(Requisitioncode, Vessel_Code, SUPPLIER, QUOTATION_CODE, Document_Code); dsSendMailInfo = objTechService.GetRFQsuppInfoSendEmail(SUPPLIER, QUOTATION_CODE, Vessel_Code, Document_Code, Session["userid"].ToString()); string FileName = "PO_" + Vessel_Code + "_" + OrderCode + "_" + SUPPLIER + DateTime.Now.ToString("yyMMddss") + ".pdf"; string sToEmailAddress = "", strSubject = "", strEmailBody = ""; //Generate the PDF file and check the include amount status DataTable dtPO = DsPO.Tables[0]; GeneratePOAsPDF(dtPO, strPath, FileName); FormateEmail(dsSendMailInfo, out sToEmailAddress, out strSubject, out strEmailBody, false, OrderCode); BLL_Crew_CrewDetails objMail = new BLL_Crew_CrewDetails(); int MailID = 0; MailID = objMail.Send_CrewNotification(0, 0, 0, 0, sToEmailAddress, emailIDcc, "", strSubject, strEmailBody, "", "MAIL", "", UDFLib.ConvertToInteger(Session["USERID"].ToString()), "DRAFT"); string UploadFilePath = ConfigurationManager.AppSettings["PURC_UPLOAD_PATH"]; //string uploadpath = @"\\server01\uploads\Purchase"; string uploadpath = @"uploads\Purchase"; BLL_Infra_Common.Insert_EmailAttachedFile(MailID, FileName, uploadpath + @"\" + FileName); string URL = String.Format("window.open('../crew/EmailEditor.aspx?ID=+" + MailID.ToString() + @"&FILEPATH=" + UploadFilePath + "');"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "k" + MailID.ToString(), URL, true); } } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }