Ejemplo n.º 1
0
        private async Task SendMailNew(int paymentID)
        {
            this.objCompanyMasterDT = this.objCompanyMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
            string displayName = this.objCompanyMasterDT.Rows[0]["CompanyName"].ToString().ToUpper();
            string addresses   = this.objCompanyMasterDT.Rows[0]["CompanyEmail"].ToString();

            this.objPaymentMasterDT = this.objPaymentMasterBll.GetDataByPaymentID(paymentID);
            string s1 = this.objPaymentMasterDT.Rows[0]["InvoiceID"].ToString();

            this.objInvoiceMasterDT = this.objInvoiceMasterBll.GetDataByInvoiceID(int.Parse(s1));
            string str1 = this.objInvoiceMasterDT.Rows[0]["InvoiceNumber"].ToString();
            string s2   = this.objInvoiceMasterDT.Rows[0]["InvoiceTotal"].ToString();
            //string s3 = this.objInvoiceMasterDT.Rows[0]["PaidToDate"].ToString();
            //Decimal num = Decimal.Parse(s2) - Decimal.Parse(s3);
            Decimal num      = Decimal.Parse(s2);
            string  s4       = this.objInvoiceMasterDT.Rows[0]["ClientID"].ToString();
            string  str2     = string.Empty;
            string  address1 = string.Empty;
            string  str3     = string.Empty;
            string  str4     = string.Empty;
            string  str5     = string.Empty;

            this.objCompanyClientMasterDT = this.objCompanyClientMasterBll.GetDataByCompanyClientID(int.Parse(s4));
            if (this.objCompanyClientMasterDT.Rows.Count > 0)
            {
                string username = this.objCompanyClientMasterDT.Rows[0]["UserName"].ToString();
                str3     = this.objCompanyClientMasterDT.Rows[0]["OrganizationName"].ToString();
                str4     = this.objCompanyClientMasterDT.Rows[0]["FirstName"].ToString();
                str5     = this.objCompanyClientMasterDT.Rows[0]["LastName"].ToString();
                address1 = this.objCompanyClientMasterDT.Rows[0]["Email"].ToString();
                MembershipUser user = Membership.GetUser(username);
                if (user != null)
                {
                    string key1     = PaymentMaster.GenerateCode();
                    string str6     = HttpUtility.UrlEncode(this.Encrypt(user.UserName, key1));
                    string password = user.GetPassword();
                    string key2     = PaymentMaster.GenerateCode();
                    string str7     = HttpUtility.UrlEncode(this.Encrypt(password, key2));
                    str2 = string.Format("{5}/CheckClient.aspx?page=invoice&anyId={0}&name={1}&tech={2}&keyname={3}&keytech={4}", (object)s1, (object)str6, (object)str7, (object)key1, (object)key2, Common.CommonHandler.WebsiteBaseURL);
                }
            }
            string str8     = string.Empty;
            string str9     = string.Empty;
            string address2 = "*****@*****.**";

            this.objSMTPSettingsDT = this.objSMTPSettingsBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
            if (this.objSMTPSettingsDT.Rows.Count > 0)
            {
                str9     = this.objSMTPSettingsDT.Rows[0]["EmailSignature"].ToString();
                address2 = this.objSMTPSettingsDT.Rows[0]["SMTPFrom"].ToString();
            }
            this.objNewPaymentEmailTemplateDT = this.objNewPaymentEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), "other");
            if (this.objNewPaymentEmailTemplateDT.Rows.Count > 0)
            {
                str8 = this.objNewPaymentEmailTemplateDT.Rows[0]["EmailBody"].ToString();
            }
            Hashtable Variables = new Hashtable()
            {
                {
                    (object)"company",
                    (object)displayName
                },
                {
                    (object)"companyName",
                    (object)displayName
                },
                {
                    (object)"invoiceNum",
                    (object)str1
                },
                {
                    (object)"invoiceNumber",
                    (object)str1
                },
                {
                    (object)"someLink",
                    (object)str2
                },
                {
                    (object)"emailTemplate",
                    (object)str8
                },
                {
                    (object)"companyEmail",
                    (object)("<a href=\"mailto:" + addresses + "\">" + addresses + "</a>")
                },
                {
                    (object)"amountOwned",
                    (object)num
                },
                {
                    (object)"clientOrgName",
                    (object)str3
                },
                {
                    (object)"firstName",
                    (object)str4
                },
                {
                    (object)"lastName",
                    (object)str5
                },
                {
                    (object)"invoiceAmt",
                    (object)s2
                },
                {
                    (object)"directLink",
                    (object)this.directLink
                },
                {
                    (object)"branding",
                    (object)this.branding
                },
                {
                    (object)"emailSign",
                    (object)str9
                },
                {
                    (object)"loginLink",
                    (object)"<a target=\"_blank\" href=\"http://www.billtransact.com/MemberArea.aspx\">https://www.billtransact.com/MemberArea.aspx</a>"
                }
            };
            Parser parser1 = new Parser(this.Server.MapPath("~/MailTemplate/PaymentInformationNew.html"), Variables);
            string path1   = this.Server.MapPath("~\\TempHTMLFiles\\");

            File.WriteAllText(Path.Combine(path1, "Payment.html"), parser1.Parse());
            Parser parser2 = new Parser(path1 + "Payment.html", Variables);

            try
            {
                //MailMessage message = new MailMessage()
                //{
                //  From = new MailAddress(address2, displayName)
                //};
                //message.To.Add(new MailAddress(address1));
                //message.ReplyToList.Add(addresses);
                //message.Subject = displayName + " has received your payment for invoice " + str1 + " in Bill Transact";
                //message.BodyEncoding = Encoding.UTF8;
                //message.Body = parser2.Parse();
                //message.IsBodyHtml = true;

                //Common.CommonHandler.SendSMTPEmail(hfCompanyID.Value, address1, displayName + " has received your payment for invoice " + str1 + " in Bill Transact", parser2.Parse(), true);
                await Common.CommonHandler.SendMail(hfCompanyID.Value, address1, displayName + " has received your payment for invoice " + str1 + " in Bill Transact", parser2.Parse(), true);

                //SmtpClientForCompany.smtpClient(this.hfCompanyID.Value).Send(message);
            }
            catch (Exception ex)
            {
                this.DisplayAlert("Error in sending mail." + (object)ex);
            }
        }
Ejemplo n.º 2
0
 protected async void btnSave_Click(object sender, EventArgs e)
 {
     if (this.Page.IsValid)
     {
         string s = this.txtPaymentDate.Text;
         //string s = DateTime.ParseExact(this.txtPaymentDate.Text, new string[6]
         //{
         //  "MM/dd/yy",
         //  "MM/dd/yyyy",
         //  "dd/MM/yy",
         //  "dd/MM/yyyy",
         //  "yy-MM-dd",
         //  "yyyy-MM-dd"
         //}, (IFormatProvider) CultureInfo.InvariantCulture, DateTimeStyles.None).ToString("MM/dd/yyyy");
         Decimal num11 = 0;
         if (this.txtPayment.Text.Trim().Length > 0)
         {
             num11 = Decimal.Parse(this.txtPayment.Text.Trim());
         }
         if (num11 == Decimal.Parse(this.lblBalance.Text))
         {
             num11 = Decimal.Parse(this.lblBalance.Text);
         }
         else if (num11 > Decimal.Parse(this.lblBalance.Text))
         {
             Decimal num2 = num11 - Decimal.Parse(this.lblBalance.Text);
             num11 = Decimal.Parse(this.lblBalance.Text);
             this.objCreditMasterDT = this.objCreditMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
             string sCreditNumber = this.objCreditMasterDT.Rows.Count <= 0 ? ConfigurationManager.AppSettings["InvoiceNoStart"] : PaymentMaster.NextNum(this.objCreditMasterDT.Rows[0]["CreditNumber"].ToString());
             this.objInvoiceMasterDT = this.objInvoiceMasterBll.GetDataByInvoiceID(int.Parse(this.hfInvoiceID.Value));
             this.objCreditMasterBll.AddCredit(int.Parse(this.hfCompanyID.Value), new int?(int.Parse(this.objInvoiceMasterDT.Rows[0]["ClientID"].ToString())), new int?(int.Parse(this.objInvoiceMasterDT.Rows[0]["CurrencyID"].ToString())), sCreditNumber, new DateTime?(DateTime.Parse(s)), "Overpayment from invoice #" + this.objInvoiceMasterDT.Rows[0]["InvoiceNumber"], "", "created", new Decimal?(num2), new Decimal?(num2));
         }
         int      a  = int.Parse(this.hfCompanyID.Value);
         int      b  = int.Parse(this.hfInvoiceID.Value);
         Decimal? c  = new Decimal?(num11);
         string   d  = this.ddlMethod.SelectedItem.Value;
         DateTime?ed = new DateTime?(DateTime.Parse(s));
         string   f  = this.txtPaymentNote.Text.Trim();
         //int paymentID = this.objPaymentMasterBll.AddPayment(int.Parse(this.hfCompanyID.Value), int.Parse(this.hfInvoiceID.Value), new Decimal?(num11), this.ddlMethod.SelectedItem.Value, new DateTime?(DateTime.Parse(s)), this.txtPaymentNote.Text.Trim());
         int paymentID = this.objPaymentMasterBll.AddPayment(int.Parse(this.hfCompanyID.Value), int.Parse(this.hfInvoiceID.Value), Convert.ToDecimal(txtPayment.Text), this.ddlMethod.SelectedItem.Value, Convert.ToDateTime(s), this.txtPaymentNote.Text.Trim());
         if (num11 > new Decimal(0))
         {
             Decimal num2 = Decimal.Round(Decimal.Parse(this.lblTotalPaid.Text) + num11, 2);
             //this.objInvoiceMasterBll.UpdatePaidToDate(new Decimal?(num2), int.Parse(this.hfInvoiceID.Value));
             this.objInvoiceMasterBll.UpdateInvoiceStatus(num2 == Decimal.Parse(this.lblInvoiceAmt.Text) ? "paid" : "partial", int.Parse(this.hfInvoiceID.Value));
         }
         if (paymentID != 0)
         {
             this.Session["savePay"] = (object)1;
             if (true || chkEmail.Checked)
             {
                 this.objInvoiceMasterDT = this.objInvoiceMasterBll.GetDataByInvoiceID(int.Parse(this.hfInvoiceID.Value));
                 if (this.objInvoiceMasterDT.Rows.Count > 0)
                 {
                     this.lblInvoiceAmt.Text = this.objInvoiceMasterDT.Rows[0]["InvoiceTotal"].ToString();
                     this.lblInvoiceAmt.Text = Decimal.Round(Decimal.Parse(this.lblInvoiceAmt.Text), 2).ToString();
                     await this.SendMailNew(paymentID);
                 }
             }
             this.DisplayAlert("Payment Added Successfully");
             this.Response.Redirect("PaymentMaster.aspx");
         }
         else
         {
             this.DisplayAlert("Problem in Insertion Try After Sometime..!");
         }
     }
     else
     {
         this.DisplayAlert("Please Fill Proper Data..!");
     }
 }