using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Drawing;
using System.Net.Mail;
using System.Text;

public partial class FundRequestService : System.Web.UI.Page
{
    string ipaddress;
    float balance;
    int balanceavailable;
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            lblsucess.Text = "Comming Soon";
            //userdetails();
            //Label1.Text = Session["USERNAME"].ToString();
            //ipaddress = System.Web.HttpContext.Current.Request.UserHostAddress.ToString();
        }
        catch (Exception ex)
        {
            throw (ex);
        }    
    }
    //public void userdetails()
    //{
    //    try
    //    {
    //        SqlParameter[] get_user_details = new SqlParameter[]
    //        {
    //            new SqlParameter("@LOGINID",Session["LOGINID"].ToString())
    //        };

    //        SqlDataReader dr = SqlHelper.ExecuteReader(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "udp_getavailablebalance", get_user_details);
    //        if (dr.Read())
    //        {
    //            balance = Convert.ToInt32(dr["balance"]);
    //        }
    //    }
    //    catch (Exception ex)
    //    {
    //        Server.Transfer("Error.aspx?id=" + ex + "");
    //        //string st = ex.Message;
    //    }
    //}
    
    //protected void btnSubmit_Click(object sender, EventArgs e)
    //{
    //    insertservicerequest();
    //}
    //private void insertservicerequest()
    //{
    //    if (ddl_trnsfr_from.SelectedItem.Text == "eGen" && lblTransferTo.Text == "Air")
    //    {

    //        string Amount = txt_transammount.Text;

    //        balanceavailable = Convert.ToInt32(Amount);
    //        if (balanceavailable > balance)
    //        {
    //            lblsucess.Text = "You don’t have sufficient balance to do this transaction. Please take fund into your login for using services";
    //            lblsucess.ForeColor = Color.Red;
    //        }
    //        else if (balanceavailable < 1000)
    //        {
    //            lblsucess.Text = "Minimum Limit of Transferring the amount is Rs. 1000";
    //            lblsucess.ForeColor = Color.Red;
    //        }
    //        else
    //        {
    //            SqlParameter[] param_egen_to_air = new SqlParameter[]
    //            {
    //                new SqlParameter("@transferfrom",ddl_trnsfr_from.SelectedItem.Text.Trim()),
    //                new SqlParameter("@transferto",lblTransferTo.Text.Trim()),
    //                new SqlParameter("@transferamount",txt_transammount.Text.Trim()),
    //                new SqlParameter("@remark",txt_remark.Text.Trim()),
    //                new SqlParameter("@ipaddress",ipaddress),
    //                new SqlParameter("@loginid",Session["LOGINID"].ToString()),
    //                new SqlParameter ("@Refnumber",SqlDbType.BigInt),
    //            };
    //            param_egen_to_air[6].Direction = ParameterDirection.Output;
                
    //            SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "udp_transfer_amount_between_services", param_egen_to_air);

    //            string Refnumber = Convert.ToString((param_egen_to_air[6].Value));
                
    //            lblsucess.Text = "Your Request from eGen to Air has been submitted successfully. Reference No. is "+ Refnumber+"";
    //            lblsucess.ForeColor = Color.Blue;
    //            //sendmail();
    //            ddl_trnsfr_from.SelectedIndex = 0;
    //            lblTransferTo.Text = null;
    //            txt_transammount.Text = "";
    //            txt_remark.Text = "";
    //        }
    //    }

    //    else if (ddl_trnsfr_from.SelectedItem.Text == "Air" && lblTransferTo.Text == "eGen")
    //    {
    //        string Amount = txt_transammount.Text;

    //        balanceavailable = Convert.ToInt32(Amount);
    //        if (balanceavailable < 500)
    //        {
    //            lblsucess.Text = "Minimum Limit of Transferring the amount is Rs. 500";
    //            lblsucess.ForeColor = Color.Red;
    //        }
    //        else
    //        {
    //            SqlParameter[] param_air_to_egen = new SqlParameter[]
    //            {
    //                new SqlParameter("@transferfrom",ddl_trnsfr_from.SelectedItem.Text.Trim()),
    //                new SqlParameter("@transferto",lblTransferTo.Text.Trim()),
    //                new SqlParameter("@transferamount",txt_transammount.Text.Trim()),
    //                new SqlParameter("@remark",txt_remark.Text.Trim()),
    //                new SqlParameter("@ipaddress",ipaddress),
    //                new SqlParameter("@usertype",Session["USERTYPE"].ToString()),
    //                new SqlParameter("@loginid",Session["LOGINID"].ToString()),
    //            };
    //            SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "udp_air_to_egen_transfer", param_air_to_egen);
    //            sendmail();
    //            lblsucess.Text = "Request is in Process";
    //            lblsucess.ForeColor = Color.Blue;
    //            CommonFunction.ClearControlValues(tblFundRequestServices);
    //        }
    //    }
    //}
    //private void sendmail()
    //{
    //    try
    //    {
    //        MailMessage message = new MailMessage();
    //        if (ddl_trnsfr_from.SelectedItem.Text == "eGen" && lblTransferTo.Text == "Air")
    //        {
    //            //message.Body = mailmsg();
    //        }
    //        else
    //        {
    //            //message.Body = mailmsgmobilerecharge();
    //        }
    //        message.IsBodyHtml = true;
    //        message.To.Add("egenrecharge@gmail.com");//egenrecharge@gmail.com
    //        message.From = new System.Net.Mail.MailAddress(Session["EMAILID"].ToString());
    //        message.Subject = "EGen Transfer to Service Request Air";
    //        message.Priority = MailPriority.High;
    //        SmtpClient SmtpMail = new SmtpClient();
    //        {
    //            SmtpMail.Host = "smtp.gmail.com";
    //            SmtpMail.Port = 587;
    //            SmtpMail.EnableSsl = true;
    //            SmtpMail.UseDefaultCredentials = true;
    //            SmtpMail.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
    //            SmtpMail.Credentials = new System.Net.NetworkCredential("mail.egenservices@gmail.com", "egenservices@123456");
    //            SmtpMail.Send(message);
    //            lblsucess.Text = "Your request is under process we will get back to you with in 12 working hours";
    //            lblsucess.ForeColor = Color.Blue;
    //        }
    //        message = null;
    //        //Response.Redirect("Thanks.aspx");

    //    }
    //    catch (Exception ex)
    //    {
    //        lblsucess.Text = "Send Email Failed.<br>" + ex.Message;
    //        lblsucess.ForeColor = Color.Red;
    //    }
    //}

    //protected void ddl_trnsfr_from_SelectedIndexChanged(object sender, EventArgs e)
    //{
    //    if (ddl_trnsfr_from.SelectedItem.Text == "eGen")
    //    {
    //        lblTransferTo.Text = "Air";
    //    }
    //    if (ddl_trnsfr_from.SelectedItem.Text == "Air")
    //    {
    //        lblTransferTo.Text = "eGen";
    //    }
    //}
}
