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; using System.Text; public partial class Arabic_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 Code,Le_No_Sec,Le_No_User,Le_No,Le_Names,Le_Day,Le_Month,Le_Year,Le_User,ta,Le_Way From tbl_Arabic where Code=" + Code, con); if (con.State == ConnectionState.Closed) con.Open(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); if (dr.HasRows) { if (!dr.IsDBNull(0)) { LBLSHOW.Text = "بيانات دورات اللغة العربية"; Page.Title = "بيانات دورات اللغة العربية" ; } if (!dr.IsDBNull(1)) txtLe_No_Sec.Text = dr["Le_No_Sec"].ToString(); if (!dr.IsDBNull(2)) txtLe_No_User.Text = dr["Le_No_User"].ToString(); if (!dr.IsDBNull(3)) txtNo.Text = dr["Le_No"].ToString(); if (!dr.IsDBNull(4)) { StringBuilder Doc_Par_Name = new StringBuilder(Server.HtmlDecode(dr["Le_Names"].ToString().Trim().Replace("''", "'"))); FTBDoc_Par_Name.Text = Doc_Par_Name.ToString(); } //txtYear.Text = dr["Le_Names"].ToString(); if (!dr.IsDBNull(5)) DrpDate.SelectedValue = dr["Le_Day"].ToString(); if (!dr.IsDBNull(6)) DrpDate.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(9)) txtta.Text = dr["ta"].ToString(); if (!dr.IsDBNull(10)) DrpWay.SelectedValue = dr["Le_Way"].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 (txtNo.Text == "") { return; } StringBuilder Doc_Par_NameFTP = new StringBuilder(Server.HtmlEncode(FTBDoc_Par_Name.Text.Trim().Replace("'", "''"))); string Doc_Par_Name = Doc_Par_NameFTP.ToString(); SqlCommand cmdInsert = new SqlCommand("Update tbl_Arabic set Le_No_Sec=N'" + txtLe_No_Sec.Text + "',Le_No_User=" + txtLe_No_User.Text + ""+ ",Le_No=" + txtNo.Text + ",Le_Names=N'" + Doc_Par_Name + "',Le_Day=N'" + DrpDate.SelectedValue + "',Le_Month=N'" + DrpMonth.SelectedValue + "',"+ "Le_Year=N'" + txtYear.Text + "',Le_User=" + Session["User"].ToString() + ",ta=" + txtta.Text + ",Le_Way=N'" + DrpWay.SelectedValue + "' 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 btnreturn_Click(object sender, EventArgs e) { Response.Redirect("Arabic.aspx"); } protected void btnDelete_Click(object sender, EventArgs e) { try { muslim = Convert.ToInt16(Request.QueryString["id"].ToString()); SqlCommand cmdInsert = new SqlCommand("Delete From tbl_Arabic " + " where Code=" + muslim, con); if (con.State == ConnectionState.Closed) con.Open(); cmdInsert.ExecuteNonQuery(); con.Close(); lblerror2.Text = "تم حذف دورات اللغة العربية "; txtLe_No_Sec.Text = ""; txtYear.Text = ""; DrpMonth.ClearSelection(); DrpDate.ClearSelection(); DrpWay.ClearSelection(); txtLe_No_User.Text = ""; txtNo.Text = ""; FTBDoc_Par_Name.Text = ""; } catch (Exception ex) { lblerror2.Text = "حدث خطأ كالتالي " + ex.ToString(); return; } } }