using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class Admin_AgentRegistration : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//DropDownList1.SelectedIndex = 0;
if (!IsPostBack)
{
txtFirst.Focus();
getCenterID();
}
}
private void getCenterID()
{
AgentBAL bo = new AgentBAL();
DataSet ds = new DataSet();
ds = bo.GetCenterID();
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "CenterID";
DropDownList1.DataValueField = "CenterID";
DropDownList1.DataBind();
DropDownList1.Items.Insert(0, "--Select--");
}
//AdminBAL bo = new AdminBAL();
//bo.FirstName = txtFirst.Text;
//bo.LastName = txtLast.Text;
//bo.CenterID = DropDownList1.SelectedItem.Text;
//bo.UserName = txtUserName.Text;
//bo.Password = txtPwd.Text;
//bo.EmailID = txtEmail.Text;
//bo.PhoneNo = txtPhn.Text;
//bo.Address = txtAddrss.Text;
//int i = bo.InsertAgentDetails();
//if (i > 0)
//{
// Page.RegisterStartupScript("kk", "");
//}
//else
//{
// Page.RegisterStartupScript("ku", "");
//}
protected void Button2_Click(object sender, EventArgs e)
{
txtAddrss.Text = "";
txtEmail.Text = "";
txtFirst.Text = "";
txtLast.Text = "";
txtPhn.Text = "";
txtPwd.Text = "";
txtUserName.Text = "";
DropDownList1.SelectedIndex = 0;
}
private void DataClear()
{
foreach (Control ctrl in ((ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1")).Controls)
{
if (ctrl.GetType() == typeof(TextBox))
{
((TextBox)ctrl).Text = string.Empty;
}
if (ctrl.GetType() == typeof(DropDownList))
{
((DropDownList)ctrl).SelectedIndex = 0;
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
//SqlConnection con = new SqlConnection("Data Source=VICTORY2;database=Binary;User ID=sa;Password=p@ssword");
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ToString());
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
con.Open();
cmd.CommandText = "insert into Registration(FirstName,LastName,CenterID,UserName,Password,EmailID,PhoneNo,Address,Role) values('" + txtFirst.Text + "','" + txtLast.Text + "','" + DropDownList1.SelectedItem.Text + "','" + txtUserName.Text + "','" + txtPwd.Text + "','" + txtEmail.Text + "','" + txtPhn.Text + "','" + txtAddrss.Text + "','" + txtroleagent.Text + "')";
int i = cmd.ExecuteNonQuery();
if (i > 0)
{
Page.RegisterStartupScript("kk", "");
txtAddrss.Text = "";
txtEmail.Text = "";
txtFirst.Text = "";
txtLast.Text = "";
txtPhn.Text = "";
txtPwd.Text = "";
txtUserName.Text = "";
}
else
{
Page.RegisterStartupScript("ku", "");
}
con.Close();
}
}