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 ReportAll_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 Le_NoBooks,Le_NoArticle,Le_NoNews,Le_NoMedia,Le_NoVideo,Le_Month,Le_Year,Le_User,Le_Flash,Le_Card,Le_LeMatwyia,Le_Dalil,Le_Image,Le_Program,Le_Banner From tbl_ReportAll where Code=" + Code, con); if (con.State == ConnectionState.Closed) con.Open(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); if (dr.HasRows) { if (!dr.IsDBNull(0)) { txtNoBooks.Text = dr["Le_NoBooks"].ToString(); } if (!dr.IsDBNull(1)) { txtNoArticle.Text = dr["Le_NoArticle"].ToString(); } if (!dr.IsDBNull(2)) { txtNoNews.Text = dr["Le_NoNews"].ToString(); } if (!dr.IsDBNull(3)) { txtNoMedia.Text = dr["Le_NoMedia"].ToString(); } if (!dr.IsDBNull(4)) { txtNoVideo.Text = dr["Le_NoVideo"].ToString(); } if (!dr.IsDBNull(5)) DrpMonth.SelectedValue = dr["Le_Month"].ToString(); if (!dr.IsDBNull(6)) txtYear.Text = dr["Le_Year"].ToString(); if (!dr.IsDBNull(7)) DrpwhoName.SelectedValue = dr["Le_User"].ToString(); //,,,,,, if (!dr.IsDBNull(8)) { txtNoFalsh.Text = dr["Le_Flash"].ToString(); } if (!dr.IsDBNull(9)) { txtNoCard.Text = dr["Le_Card"].ToString(); } if (!dr.IsDBNull(10)) { txtNoMatwyia.Text = dr["Le_LeMatwyia"].ToString(); } if (!dr.IsDBNull(11)) { txtNoDalil.Text = dr["Le_Dalil"].ToString(); } if (!dr.IsDBNull(12)) { txtNoImage.Text = dr["Le_Image"].ToString(); } if (!dr.IsDBNull(13)) { txtNoProgram.Text = dr["Le_Program"].ToString(); } if (!dr.IsDBNull(14)) { txtNoBanner.Text = dr["Le_Banner"].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 ((txtNoBooks.Text == "") && (txtNoNews.Text == "") && (txtNoMedia.Text == "") && (txtNoArticle.Text == "") && (txtNoVideo.Text == "") && (txtNoBanner.Text == "") && (txtNoCard.Text == "") && (txtNoImage.Text == "") && (txtNoFalsh.Text == "") && (txtNoMatwyia.Text == "") && (txtNoProgram.Text == "") && (txtNoDalil.Text == "")) { return; } SqlCommand cmdInsert = new SqlCommand("Update tbl_ReportAll set Le_NoBooks=" + txtNoBooks.Text + ",Le_NoArticle=" + txtNoArticle.Text + ""+ ",Le_NoNews=" + txtNoNews.Text + ",Le_NoMedia=" + txtNoMedia.Text + ",Le_NoVideo=" + txtNoVideo.Text + ","+ "Le_Month=N'" + DrpMonth.SelectedValue + "' ,Le_Year=N'" + txtYear.Text + "',Le_User=" + Session["User"].ToString() + " " + " ,Le_Flash=" + txtNoFalsh.Text + ", Le_Card=" + txtNoCard.Text + ",Le_LeMatwyia=" + txtNoMatwyia.Text + ", Le_Dalil=" + txtNoDalil.Text + "," + " Le_Image="+ txtNoImage.Text + ",Le_Program= "+ txtNoProgram.Text + ", Le_Banner=" + txtNoBanner.Text + " " + " where Code=" + Code, con); if (con.State == ConnectionState.Closed) con.Open(); cmdInsert.ExecuteNonQuery(); con.Close(); LoadData(Code); 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("ReportAll.aspx"); } protected void btnDelete_Click(object sender, EventArgs e) { try { muslim = Convert.ToInt16(Request.QueryString["id"].ToString()); SqlCommand cmdInsert = new SqlCommand("Delete From tbl_ReportAll " + " where Code=" + muslim, con); if (con.State == ConnectionState.Closed) con.Open(); cmdInsert.ExecuteNonQuery(); con.Close(); lblerror2.Text = "تم حذف البيانات"; txtNoArticle.Text = ""; txtNoBooks.Text = ""; txtNoNews.Text = ""; txtNoVideo.Text = ""; txtNoMedia.Text = ""; txtYear.Text = ""; txtNoFalsh.Text = ""; txtNoImage.Text = ""; txtNoBanner.Text = ""; txtNoMatwyia.Text = ""; txtNoDalil.Text = ""; txtNoProgram.Text = ""; txtNoCard.Text = ""; DrpMonth.ClearSelection(); } catch (Exception ex) { lblerror2.Text = "حدث خطأ كالتالي " + ex.ToString(); return; } } }