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_Add : 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) { AddRecord(); Cleartxt(); } private void AddRecord() { string xadmin = Session["admin"].ToString(); if (xadmin == "True") { try { if (txtYear.Text == "") { txtYear.Text = "1435"; } if ((txtNoBooks.Text == "") && (txtNoNews.Text == "") && (txtNoMedia.Text == "") && (txtNoArticle.Text == "") && (txtNoVideo.Text == "") && (txtNoBanner.Text == "") && (txtNoCard.Text == "") && (txtNoImage.Text == "") && (txtNoFlash.Text == "") && (txtNoMatwyia.Text == "") && (txtNoProgram.Text == "") && (txtNoDalil.Text == "")) { return; } SqlCommand cmdInsert = new SqlCommand("insert into tbl_ReportAll(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)" + " Values(" + txtNoBooks.Text + "," + txtNoArticle.Text + "," + txtNoNews.Text + "," + txtNoMedia.Text + "," + txtNoVideo.Text + "," + "N'" + DrpMonth.SelectedValue + "',N'" + txtYear.Text + "'," + Session["User"].ToString() + ","+ " " + txtNoFlash.Text + ", " + txtNoCard.Text + "," + txtNoMatwyia.Text + ", " + txtNoDalil.Text + "," + " "+ txtNoImage.Text + ", " + txtNoProgram.Text + ", " + txtNoBanner.Text + " )", con); if (con.State == ConnectionState.Closed) con.Open(); cmdInsert.ExecuteNonQuery(); con.Close(); } catch (Exception ex) { lblerror2.Text = "حدث خطأ كالتالي " + ex.ToString(); return; } } else Response.Redirect("Home.aspx"); } private void Cleartxt() { lblerror2.Text = "تم إضافة البيان الجديد"; txtNoArticle.Text = ""; txtNoBooks.Text = ""; txtNoNews.Text = ""; txtNoVideo.Text = ""; txtNoMedia.Text = ""; txtYear.Text = ""; txtNoFlash.Text = ""; txtNoImage.Text = ""; txtNoBanner.Text = ""; txtNoMatwyia.Text = ""; txtNoDalil.Text = ""; txtNoProgram.Text = ""; txtNoCard.Text = ""; DrpMonth.ClearSelection(); } protected void btnreturn_Click(object sender, EventArgs e) { Response.Redirect("ReportAll.aspx"); } }