using System; using System.Collections; using System.Configuration; using System.Data; 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.Data.SqlClient; public partial class Visit_Add : System.Web.UI.Page { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ToString()); protected void Page_Load(object sender, EventArgs e) { } protected void btnAdd2_Click(object sender, EventArgs e) { AddRecord(); Cleartxt(); } private void AddRecord() { string xadmin = Session["admin"].ToString(); if (xadmin == "True") { try { if (txtYear.Text == "") { txtYear.Text = "1435"; } if (txtName.Text == "") { return; } SqlCommand cmdInsert = new SqlCommand("insert into tbl_Visit(Le_WName,Le_City,Le_Address,Le_No,Le_Where,Le_Day,Le_Month,Le_Year,Le_User,Le_Country,ta)" + " Values(N'" + txtName.Text + "'," + DrpWorkPlace.SelectedValue + "," + " " + DrpSaudiDis.SelectedValue + "," + txtEmail.Text + ",N'" + DrpIslamPlace.SelectedValue + "' ," + " N'" + DrpDate.SelectedValue + "',N'" + DrpMonth.SelectedValue + "',N'" + txtYear.Text + "'," + " " + Session["User"].ToString() + "," + DrpCountry.SelectedValue + "," + txtta.Text + ")", con); if (con.State == ConnectionState.Closed) con.Open(); cmdInsert.ExecuteNonQuery(); con.Close(); } catch (Exception ex) { lblerror2.Text = "حدث خطأ كالتالي " + ex.ToString(); return; } } else Response.Redirect("Home.aspx"); } private void Cleartxt() { lblerror2.Text = "تم إضافة الزيارة الدعوية الجديدة"; txtName.Text = ""; txtYear.Text = ""; txtta.Text = "1"; DrpSaudiDis.ClearSelection(); DrpMonth.ClearSelection(); DrpDate.ClearSelection(); DrpWorkPlace.ClearSelection(); DrpCountry.ClearSelection(); DrpIslamPlace.ClearSelection(); txtEmail.Text = ""; } protected void btnShowCity_Click(object sender, EventArgs e) { DrpWorkPlace.DataBind(); } protected void btnShowDis_Click(object sender, EventArgs e) { DrpSaudiDis.Enabled = true; DrpSaudiDis.DataBind(); } protected void btnreturn_Click(object sender, EventArgs e) { Response.Redirect("Visit.aspx"); } }