Exemple #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            SqlCommand cmd = new SqlCommand("select UserCode,LoginPassword,address,Email,MobileNo from tblMemberMaster where UserCode =@usercode or Loginname = @usercode", con);

            cmd.Parameters.AddWithValue("@usercode", TextBox1.Text);
            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            if (!dr.HasRows)
            {
                msgbox("Invalid Userid");
            }
            while (dr.Read())
            {
                if (dr["Email"].ToString() != "")
                {
                    System.Net.Mail.MailMessage n      = new System.Net.Mail.MailMessage();
                    System.Net.Mail.SmtpClient  client = new System.Net.Mail.SmtpClient();
                    string Msg = "Your Login Password for Memeber ID : " + dr["UserCode"].ToString() + " <br>" + "<span style='font-size:large'><p> " + dr["LoginPassword"].ToString() + "</span></p>";
                    n.To.Add(dr["Email"].ToString());
                    n.From           = new MailAddress("*****@*****.**");
                    n.Body           = Msg;
                    n.IsBodyHtml     = true;
                    client.EnableSsl = false;
                    n.Subject        = "Your Login Password";
                    client.Send(n);
                    msgbox("Login Password Sent on Your Email,Kindly Check Your Email");
                    return;
                }
                String Msgs = "";
                if (dr["MobileNo"].ToString() != "")
                {
                    Msgs   = "Your Login Password for Memeber ID : " + dr["UserCode"].ToString() + " <br>" + "<span style='font-size:large'><p> " + dr["LoginPassword"].ToString() + "</span></p>";
                    status = S1.SendNormalSMS(dr["MobileNo"].ToString(), Msgs);
                    msgbox("Login Password Sent on Your Mobile,Kindly Check Your Mobile.");
                }
                TextBox1.Text = "";
            }
            dr.Close();
            dr.Dispose();
            con.Close();
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //if (ddlBranchtype.SelectedItem.Text == "Franchise" && txtparent.Text=="")
            //{

            //    MsgBox("Please Fill Parent");
            //    return;

            //}
            if (ddlBranchtype.SelectedItem.Text == "District Franchise")
            {
                //if (ddldist.SelectedItem.Text == "Select")
                //{

                //    MsgBox("Please Select Percentage");
                //    return;
                //}
                SuccessPanel.Visible = false;
                string       FrenchiseID = "";
                SqlParameter sOut        = new SqlParameter("@Result", SqlDbType.VarChar, 100);
                sOut.Direction = ParameterDirection.Output;

                cmd.CommandText = "[dbo].[SP_InsertFrenchise]";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
                cmd.Parameters.AddWithValue("@Name", ddlBranchtype.SelectedItem.Text);
                cmd.Parameters.AddWithValue("@Address", txtAddress.Text);
                cmd.Parameters.AddWithValue("@City", txtCity.Text);
                cmd.Parameters.AddWithValue("@State", txtState.Text);
                cmd.Parameters.AddWithValue("@Country", txtCountry.Text);
                cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
                cmd.Parameters.AddWithValue("@MobileNo", txtMobileNo.Text);
                cmd.Parameters.AddWithValue("@Parent", "");
                cmd.Parameters.AddWithValue("@FranchiseName", txtfname.Text);
                cmd.Parameters.AddWithValue("@ContactName", txtcname.Text);
                cmd.Parameters.AddWithValue("@PinAmount", "");

                cmd.Parameters.Add(sOut);
                con.Open();
                FrenchiseID = cmd.ExecuteScalar().ToString();
                con.Close();



                if (FrenchiseID != "" || FrenchiseID != null)
                {
                    SuccessPanel.Visible     = true;
                    InformationPanel.Visible = false;
                    PlaceHolder1.Controls.Add(new LiteralControl("<br><br>Your Franchise ID : <b>" + FrenchiseID + "</b><br><br>Password : <b>" + txtPassword.Text + "</b>"));
                }
                else
                {
                    SuccessPanel.Visible     = true;
                    InformationPanel.Visible = false;
                    PlaceHolder1.Controls.Add(new LiteralControl("<br><br>Sorry! Try again later."));
                }
            }


            else if (ddlBranchtype.SelectedItem.Text == "Master Franchise" && txtparent.Text != null)
            {
                //if (ddlmaster.SelectedItem.Text == "Select")
                //{

                //    MsgBox("Please Select Percentage");
                //    return;
                //}
                SuccessPanel.Visible = false;
                string       FrenchiseID = "";
                SqlParameter sOut        = new SqlParameter("@Result", SqlDbType.VarChar, 100);
                sOut.Direction = ParameterDirection.Output;

                cmd.CommandText = "[dbo].[SP_InsertFrenchise]";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
                cmd.Parameters.AddWithValue("@Name", ddlBranchtype.SelectedItem.Text);
                cmd.Parameters.AddWithValue("@Address", txtAddress.Text);
                cmd.Parameters.AddWithValue("@City", txtCity.Text);
                cmd.Parameters.AddWithValue("@State", txtState.Text);
                cmd.Parameters.AddWithValue("@Country", txtCountry.Text);
                cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
                cmd.Parameters.AddWithValue("@MobileNo", txtMobileNo.Text);
                cmd.Parameters.AddWithValue("@Parent", txtparent.Text);
                cmd.Parameters.AddWithValue("@FranchiseName", txtfname.Text);
                cmd.Parameters.AddWithValue("@ContactName", txtcname.Text);
                cmd.Parameters.AddWithValue("@PinAmount", "");

                cmd.Parameters.Add(sOut);
                con.Open();
                FrenchiseID = cmd.ExecuteScalar().ToString();
                con.Close();



                if (FrenchiseID != "" || FrenchiseID != null)
                {
                    SuccessPanel.Visible     = true;
                    InformationPanel.Visible = false;
                    PlaceHolder1.Controls.Add(new LiteralControl("<br><br>Your Franchise ID : <b>" + FrenchiseID + "</b><br><br>Password : <b>" + txtPassword.Text + "</b>"));
                }
                else
                {
                    SuccessPanel.Visible     = true;
                    InformationPanel.Visible = false;
                    PlaceHolder1.Controls.Add(new LiteralControl("<br><br>Sorry! Try again later."));
                }
            }


            else if (ddlBranchtype.SelectedItem.Text == "Mini Franchise" && txtparent.Text != null)
            {
                //if (ddlmini.SelectedItem.Text == "Select")
                //{

                //    MsgBox("Please Select Percentage");
                //    return;
                //}
                SuccessPanel.Visible = false;
                string       FrenchiseID = "";
                SqlParameter sOut        = new SqlParameter("@Result", SqlDbType.VarChar, 100);
                sOut.Direction = ParameterDirection.Output;

                cmd.CommandText = "[dbo].[SP_InsertFrenchise]";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
                cmd.Parameters.AddWithValue("@Name", ddlBranchtype.SelectedItem.Text);
                cmd.Parameters.AddWithValue("@Address", txtAddress.Text);
                cmd.Parameters.AddWithValue("@City", txtCity.Text);
                cmd.Parameters.AddWithValue("@State", txtState.Text);
                cmd.Parameters.AddWithValue("@Country", txtCountry.Text);
                cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
                cmd.Parameters.AddWithValue("@MobileNo", txtMobileNo.Text);
                cmd.Parameters.AddWithValue("@Parent", txtparent.Text);
                cmd.Parameters.AddWithValue("@FranchiseName", txtfname.Text);
                cmd.Parameters.AddWithValue("@ContactName", txtcname.Text);
                cmd.Parameters.AddWithValue("@PinAmount", "");

                cmd.Parameters.Add(sOut);
                con.Open();
                FrenchiseID = cmd.ExecuteScalar().ToString();
                con.Close();



                if (FrenchiseID != "" || FrenchiseID != null)
                {
                    SuccessPanel.Visible     = true;
                    InformationPanel.Visible = false;
                    PlaceHolder1.Controls.Add(new LiteralControl("<br><br>Your Franchise ID : <b>" + FrenchiseID + "</b><br><br>Password : <b>" + txtPassword.Text + "</b>"));
                }
                else
                {
                    SuccessPanel.Visible     = true;
                    InformationPanel.Visible = false;
                    PlaceHolder1.Controls.Add(new LiteralControl("<br><br>Sorry! Try again later."));
                }
            }



            else
            {
                //if (ddlLeader.SelectedItem.Text == "Select")
                //{
                //    MsgBox("Please Select Percentage");
                //     return;

                //}
                SuccessPanel.Visible = false;
                string       FrenchiseID = "";
                SqlParameter sOut        = new SqlParameter("@Result", SqlDbType.VarChar, 100);
                sOut.Direction = ParameterDirection.Output;

                cmd.CommandText = "[dbo].[SP_InsertFrenchise]";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
                cmd.Parameters.AddWithValue("@Name", ddlBranchtype.SelectedItem.Text);
                cmd.Parameters.AddWithValue("@Address", txtAddress.Text);
                cmd.Parameters.AddWithValue("@City", txtCity.Text);
                cmd.Parameters.AddWithValue("@State", txtState.Text);
                cmd.Parameters.AddWithValue("@Country", txtCountry.Text);
                cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
                cmd.Parameters.AddWithValue("@MobileNo", txtMobileNo.Text);
                cmd.Parameters.AddWithValue("@Parent", txtparent.Text);
                cmd.Parameters.AddWithValue("@FranchiseName", txtfname.Text);
                cmd.Parameters.AddWithValue("@ContactName", txtcname.Text);
                cmd.Parameters.AddWithValue("@PinAmount", "");
                cmd.Parameters.Add(sOut);
                con.Open();
                FrenchiseID = cmd.ExecuteScalar().ToString();
                con.Close();


                if (FrenchiseID != "" || FrenchiseID != null)
                {
                    SuccessPanel.Visible     = true;
                    InformationPanel.Visible = false;
                    PlaceHolder1.Controls.Add(new LiteralControl("<br><br>Your Franchise ID : <b>" + FrenchiseID + "</b><br><br>Password : <b>" + txtPassword.Text + "</b>"));
                    string Msg = "";
                    Msg = "Congratulation your Franchise ID is: " + FrenchiseID + " Password is: " + txtPassword.Text + " Please logon to " + System.Configuration.ConfigurationManager.AppSettings["URL"].ToString() + "";
                    if (txtMobileNo.Text != "" && txtMobileNo.Text.Length == 10)
                    {
                        String status = S1.SendNormalSMS(txtMobileNo.Text, Msg);
                    }
                }
                else
                {
                    SuccessPanel.Visible     = true;
                    InformationPanel.Visible = false;
                    PlaceHolder1.Controls.Add(new LiteralControl("<br><br>Sorry! Try again later."));
                }
            }
        }