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 Attand : System.Web.UI.Page { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ToString()); int muslim; protected void Page_Load(object sender, EventArgs e) { try { muslim = Convert.ToInt16(Request.QueryString["Code"].ToString()); if (!IsPostBack) { lblName.Text = Request.QueryString["Name"].ToString(); string dayarabic = ""; dayarabic=Convert.ToString(DateTime.Now.DayOfWeek.ToString()); if (dayarabic == "Saturday") { LblDateName.Text = "السبت"; } if (dayarabic == "Sunday") { LblDateName.Text = "الاحـــد"; } if (dayarabic == "Monday") { LblDateName.Text = "الأثنين"; } if (dayarabic == "Tuesday") { LblDateName.Text = "الثلاثــاء"; } if (dayarabic == "Wednesday") { LblDateName.Text = "الأربعاء"; } if (dayarabic == "Thursday") { LblDateName.Text = "الخميــس"; } if (dayarabic == "Friday") { LblDateName.Text = "الجمعـــة"; } //LblDateName.Text = LblDate.Text = DateTime.Now.Date.ToString("d"); } } catch { throw; } } protected void BtnAdd_Click(object sender, EventArgs e) { string xadmin = Session["admin"].ToString(); if (xadmin == "True") { SqlCommand cmd = new SqlCommand("Select Code From Attand where Muslim_Code=" + Convert.ToInt16(Request.QueryString["Code"].ToString()) + " and InsertDate=N'" + LblDate.Text + "'", con); if (con.State == ConnectionState.Closed) con.Open(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); if (dr.HasRows) { lblerror.Text = "تم اضافة البيان للمسلم من قبل"; BtnAdd0.Visible = true; dr.Close(); con.Close(); return; } dr.Close(); con.Close(); try { SqlCommand cmdInsert = new SqlCommand("insert into Attand ( Muslim_Code,Day_Name,InsertDate,Status,Users ) " + "Values(" + Convert.ToInt16(Request.QueryString["Code"].ToString()) + " , N'" + LblDateName.Text + "' , N'" + LblDate.Text + "' ," + " N'" + RBLDaily.SelectedItem.Text + "' ," + Session["User"].ToString() + ")", con); if (con.State == ConnectionState.Closed) con.Open(); //Response.Write(cmdInsert.CommandText.ToString()); cmdInsert.ExecuteNonQuery(); con.Close(); lblerror.Text = "تم إضافة البيان بنجاح"; BtnAdd0.Visible = true; } catch (Exception ex) { Response.Write(ex.ToString()); return; } } else Response.Redirect("Home.aspx"); } protected void BtnAdd0_Click(object sender, EventArgs e) { muslim = Convert.ToInt16(Request.QueryString["Code"].ToString()); string tahahaha = Request.QueryString["char"].ToString(); Response.Redirect("Daily.aspx?char=" + tahahaha + "&Code=" + muslim); } }