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 NonMuslim_Edit : System.Web.UI.Page { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ToString()); int muslim; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { muslim = Convert.ToInt16(Request.QueryString["id"].ToString()); LoadData(muslim); } } private void LoadData(int Code) { try { SqlCommand cmd = new SqlCommand("Select Le_WName,Le_City,Le_Address,Le_No,Le_Where,Le_Day,Le_Month,Le_Year,Le_User,Le_Country,ta From tbl_NonMuslim where Code=" + Code, con); if (con.State == ConnectionState.Closed) con.Open(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); if (dr.HasRows) { if (!dr.IsDBNull(0)) { txtName.Text = dr["Le_WName"].ToString(); LBLSHOW.Text = "بيانات لقاء غير مسلمين ل " + dr["Le_WName"].ToString(); Page.Title = "بيانات لقاء غير مسلمين ل " + dr["Le_WName"].ToString(); } if (!dr.IsDBNull(9)) { DrpCountry.SelectedValue = dr["Le_Country"].ToString(); DrpWorkPlace.DataBind(); } if (!dr.IsDBNull(1)) { DrpWorkPlace.SelectedValue = dr["Le_City"].ToString(); DrpSaudiDis.DataBind(); } if (!dr.IsDBNull(2)) { DrpSaudiDis.SelectedValue = dr["Le_Address"].ToString(); } if (!dr.IsDBNull(3)) txtEmail.Text = dr["Le_No"].ToString(); if (!dr.IsDBNull(4)) DrpIslamPlace.SelectedValue = dr["Le_Where"].ToString(); //0,1,2,3,4,5,6,7,8,9 if (!dr.IsDBNull(5)) DrpDate.SelectedValue = dr["Le_Day"].ToString(); if (!dr.IsDBNull(6)) DrpMonth.SelectedValue = dr["Le_Month"].ToString(); if (!dr.IsDBNull(7)) txtYear.Text = dr["Le_Year"].ToString(); if (!dr.IsDBNull(8)) DrpwhoName.SelectedValue = dr["Le_User"].ToString(); if (!dr.IsDBNull(10)) txtta.Text = dr["ta"].ToString(); } dr.Close(); con.Close(); } catch (Exception ex) { lblerror2.Text = "حدث خطأ كالتالي " + ex.ToString(); throw; } } private void UpdateData(int Code) { try { if (txtYear.Text == "") { txtYear.Text = "1435"; } if (txtName.Text == "") { return; } SqlCommand cmdInsert = new SqlCommand("Update tbl_NonMuslim set Le_WName=N'" + txtName.Text + "',Le_City=" + DrpWorkPlace.SelectedValue + "" + ",Le_Address=" + DrpSaudiDis.SelectedValue + ",Le_No=" + txtEmail.Text + ",Le_Where=N'" + DrpIslamPlace.SelectedValue + "'" + ",Le_Day=N'" + DrpDate.SelectedValue + "',Le_Month=N'" + DrpMonth.SelectedValue + "',Le_Year=N'" + txtYear.Text + "'" + ",Le_User=" + Session["User"].ToString() + ",Le_Country=" + DrpCountry.SelectedValue + ",ta=" + txtta.Text + " where Code=" + Code, con); if (con.State == ConnectionState.Closed) con.Open(); cmdInsert.ExecuteNonQuery(); con.Close(); lblerror2.Text = "تم تحديث بيانات اللقاء لغير المسلمين"; } catch (Exception ex) { lblerror2.Text = "حدث خطأ كالتالي " + ex.ToString(); return; } } protected void btnAdd2_Click(object sender, EventArgs e) { string xadmin = Session["admin"].ToString(); if (xadmin == "True") { muslim = Convert.ToInt16(Request.QueryString["id"].ToString()); UpdateData(muslim); LoadData(muslim); } } 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("NonMuslim.aspx"); } protected void btnDelete_Click(object sender, EventArgs e) { try { muslim = Convert.ToInt16(Request.QueryString["id"].ToString()); SqlCommand cmdInsert = new SqlCommand("Delete From tbl_NonMuslim " + " where Code=" + muslim, con); if (con.State == ConnectionState.Closed) con.Open(); cmdInsert.ExecuteNonQuery(); con.Close(); lblerror2.Text = "تم حذف بيانات اللقاء لغير المسلمين"; txtName.Text = ""; txtYear.Text = ""; txtEmail.Text = ""; DrpCountry.ClearSelection(); DrpDate.ClearSelection(); DrpIslamPlace.ClearSelection(); DrpMonth.ClearSelection(); DrpSaudiDis.ClearSelection(); DrpWorkPlace.ClearSelection(); } catch (Exception ex) { lblerror2.Text = "حدث خطأ كالتالي " + ex.ToString(); return; } } }