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 AddMuslim : 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) { try { string xadmin = Session["admin"].ToString(); if (txtName.Text == "") { lblerror2.Text = "أدخل الاســم من فضلك"; return; } if (xadmin == "True") { SqlCommand cmd = new SqlCommand("Select Code From tblMuslim where Name=N'" + txtName.Text + "'", con); if (con.State == ConnectionState.Closed) con.Open(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); if (dr.HasRows) { lblerror0.Text = "الإسم موجود من قبل"; ; dr.Close(); con.Close(); return; } dr.Close(); con.Close(); if (txtPhoneChina.Text=="") { txtPhoneChina.Text = "0"; } SqlCommand cmdInsert = new SqlCommand("insert into tblMuslim (Name_en,Name,Iqama_No,Mobil,QQ,PhoneChina,ChinaDis,ChinaCity,BirthDate,Status," + "Cerificate,ChildNo,IslamDate,SaudiDis,IslamPlace,WorkPlace,Email,WhatInIslam,whoName,ReturnDate,ConnectChina,Info,Country,Users)" + " Values(N'" + txtName.Text + "' , N'" + txtName_en.Text + "',N'" + txtIqama_No.Text + "'," + txtMobil.Text + ",N'" + txtQQ.Text + "'," + txtPhoneChina.Text + "," + DrpDis.Text + "," + DrpChinaCity.Text + ",N'" + txtBirthDate.Text + "',N'" + drpStatus.SelectedValue + "'" + " ," + drpCerificate.Text + " ,N'" + txtChildNo.Text + "',N'" + txtIslamDate.Text + "'," + DrpSaudiDis.SelectedValue + "," + " N'" + DrpIslamPlace.SelectedValue + "'," + DrpWorkPlace.SelectedValue + ",N'" + txtEmail.Text + "',N'" + DrpWhatinIslam.SelectedValue + "'," + " " + DrpwhoName.SelectedValue + ",N'" + txtReturnDate.Text + "',N'" + txtConnectChina.Text + "',N'" + txtNote2.Text + "'," + DrpCountry.SelectedValue + "," + Session["User"].ToString() + " " + " )", con); if (con.State == ConnectionState.Closed) con.Open(); // Response.Write(cmdInsert.CommandText.ToString()); cmdInsert.ExecuteNonQuery(); con.Close(); lblerror2.Text = "تم إضافة المسلم"; txtName.Text = ""; txtName_en.Text = ""; //txtIqama_No.Text = ""; //txtMobil.Text = ""; //txtQQ.Text = ""; //txtPhoneChina.Text = ""; //drpCerificate.ClearSelection(); //DrpChinaCity.ClearSelection(); //DrpDis.ClearSelection(); //DrpSaudiDis.ClearSelection(); //drpStatus.ClearSelection(); //DrpwhoName.ClearSelection(); //DrpWorkPlace.ClearSelection(); //txtBirthDate.Text = ""; //txtChildNo.Text = ""; //txtIslamDate.Text = ""; //DrpIslamPlace.ClearSelection(); //txtEmail.Text = ""; //DrpWhatinIslam.ClearSelection(); //txtReturnDate.Text = ""; //txtConnectChina.Text = ""; //txtNote2.Text = ""; } else Response.Redirect("Home.aspx"); } catch (Exception ex) { Response.Write(ex.ToString()); return; } } protected void Button1_Click(object sender, EventArgs e) { DrpChinaCity.Enabled = true; DrpChinaCity.DataBind(); } protected void btnShowCity_Click(object sender, EventArgs e) { DrpWorkPlace.DataBind(); } protected void btnShowDis_Click(object sender, EventArgs e) { DrpSaudiDis.Enabled = true; DrpSaudiDis.DataBind(); } }