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 Title_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) { LBLSHOW.Text = "تحرير العناوين المترجمة"; Page.Title = "تحرير العناوين المترجمة"; try { SqlCommand cmd = new SqlCommand("Select Tit_Book,Tit_Matwya,Tit_Article,Tit_Card,Tit_Video" + ",Tit_Da,Tit_Dalil,Tit_Flash,Tit_other,Le_Day,Le_Month,Le_Year,Le_User,Le_Title From tbl_Title where Code=" + Code, con); if (con.State == ConnectionState.Closed) con.Open(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); if (dr.HasRows) { if (!dr.IsDBNull(0)) { txtTit_Book.Text=dr["Tit_Book"].ToString(); } if (!dr.IsDBNull(1)) { txtTit_Matwya.Text = dr["Tit_Matwya"].ToString(); } if (!dr.IsDBNull(2)) { txtTit_Article.Text = dr["Tit_Article"].ToString(); } if (!dr.IsDBNull(3)) { txtTit_Card.Text = dr["Tit_Card"].ToString(); } if (!dr.IsDBNull(4)) { txtTit_Video.Text = dr["Tit_Video"].ToString(); } if (!dr.IsDBNull(5)) { txtTit_Da.Text = dr["Tit_Da"].ToString(); } if (!dr.IsDBNull(6)) { txtTit_Dalil.Text = dr["Tit_Dalil"].ToString(); } if (!dr.IsDBNull(7)) { txtTit_Flash.Text = dr["Tit_Flash"].ToString(); } if (!dr.IsDBNull(8)) { txtTit_other.Text = dr["Tit_other"].ToString(); } if (!dr.IsDBNull(9)) { DrpDay.SelectedValue = dr["Le_Day"].ToString(); } if (!dr.IsDBNull(10)) { DrpMonth.SelectedValue = dr["Le_Month"].ToString(); } if (!dr.IsDBNull(11)) { txtYear.Text = dr["Le_Year"].ToString(); } if (!dr.IsDBNull(12)) { DrpwhoName.SelectedValue = dr["Le_User"].ToString(); } if (!dr.IsDBNull(13)) { txtTitle.Text = dr["Le_Title"].ToString(); } } dr.Close(); con.Close(); } catch (Exception ex) { lblerror2.Text = "حدث خطأ كالتالي " + ex.ToString(); throw; } } private void UpdateData(int Code) { string xadmin = Session["Edit"].ToString(); if (xadmin == "True") { try { if (txtYear.Text == "") { txtYear.Text = "1435"; } if (txtTitle.Text == "") { return; txtTitle.Focus(); lblerror2.Text = "يجب ادخال العنوان"; } SqlCommand cmdInsert = new SqlCommand("Update tbl_Title set Tit_Book=" + txtTit_Book.Text + ","+ "Tit_Matwya=" + txtTit_Matwya.Text + ",Tit_Article=" + txtTit_Article.Text + ",Tit_Card=" + txtTit_Card.Text + ""+ ",Tit_Video=" + txtTit_Video.Text + "" + " ,Tit_Da=" + txtTit_Da.Text + ",Tit_Dalil=" + txtTit_Dalil.Text + ",Tit_Flash=" + txtTit_Flash.Text + ""+ ",Tit_other=" + txtTit_other.Text + ",Le_Title=N'" + txtTitle.Text + "',Le_Day=N'" + DrpDay.SelectedValue + "'"+ ",Le_Month=N'" + DrpMonth.SelectedValue + "',Le_Year=N'" + txtYear.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; } } else lblerror2.Text = "ليس لك الصلاحية في هذا الاجراء"; } protected void btnAdd2_Click(object sender, EventArgs e) { string xadmin = Session["Edit"].ToString(); if (xadmin == "True") { muslim = Convert.ToInt16(Request.QueryString["id"].ToString()); UpdateData(muslim); LoadData(muslim); } else lblerror2.Text = "ليس لك الصلاحية في هذا الاجراء"; } protected void btnreturn_Click(object sender, EventArgs e) { Response.Redirect("Title.aspx"); } protected void btnDelete_Click(object sender, EventArgs e) { string xadmin = Session["P_Delete"].ToString(); if (xadmin == "True") { try { muslim = Convert.ToInt16(Request.QueryString["id"].ToString()); SqlCommand cmdInsert = new SqlCommand("Delete From tbl_Title " + " where Code=" + muslim, con); if (con.State == ConnectionState.Closed) con.Open(); cmdInsert.ExecuteNonQuery(); con.Close(); lblerror2.Text = "تم حذف البيانات"; txtYear.Text = ""; DrpMonth.ClearSelection(); } catch (Exception ex) { lblerror2.Text = "حدث خطأ كالتالي " + ex.ToString(); return; } } else lblerror2.Text = "ليس لك الصلاحية في هذا الاجراء"; } }