Esempio n. 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (TextBox1.Text == "" || TextBox2.Text == "" || TextBox3.Text == "")
                {
                    Admin_Label.ForeColor = System.Drawing.Color.Red;
                    Admin_Label.Text      = "Fill All TextBoxs";
                    return;
                }
                double rate = Convert.ToDouble(TextBox3.Text);
                if (rate > 10 || rate < 0)
                {
                    Admin_Label.ForeColor = System.Drawing.Color.Red;
                    Admin_Label.Text      = "CPI Must Be Between [ 0, 10 ]";
                    return;
                }
                StudentSystemServiceReferece.Student Student = new StudentSystemServiceReferece.Student();
                Student.Student_Name   = TextBox2.Text.ToUpper();
                Student.Student_Branch = TextBox1.Text.ToUpper();
                Student.Student_CPI    = rate;

                IEnumerable <string> list_Student = client.getStudent_Name();
                foreach (string s in list_Student)
                {
                    if (s.Equals(TextBox2.Text.ToUpper()))
                    {
                        Admin_Label.ForeColor = System.Drawing.Color.Red;
                        Admin_Label.Text      = "Student Already Available";
                        return;
                    }
                }

                Admin_Label.ForeColor = System.Drawing.Color.Green;
                Admin_Label.Text      = client.AddStudent(Student);
                GridView1.DataSource  = client.ShowStudent();
                GridView1.DataBind();
            }
            catch (Exception e_) {
                Admin_Label.ForeColor = System.Drawing.Color.Red;
                Admin_Label.Text      = "Rating Must be Number";
            }
        }
Esempio n. 2
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string id  = GridView1.Rows[e.RowIndex].Cells[4].Text;
            int    id_ = Convert.ToInt32(id);

            if (TextBox1.Text == "" || TextBox2.Text == "" || TextBox3.Text == "")
            {
                Admin_Label.ForeColor = System.Drawing.Color.Red;
                Admin_Label.Text      = "Fill All TextBoxs With New Values To Update Row";
                return;
            }
            StudentSystemServiceReferece.Student Student = new StudentSystemServiceReferece.Student();
            try
            {
                double rate = Convert.ToDouble(TextBox3.Text);
                if (rate > 10 || rate < 0)
                {
                    Admin_Label.ForeColor = System.Drawing.Color.Red;
                    Admin_Label.Text      = "Rating Must Be Between [ 0, 10 ]";
                    return;
                }
                Student.Student_Name   = TextBox2.Text.ToUpper();
                Student.Student_Branch = TextBox1.Text.ToUpper();
                Student.Student_CPI    = rate;
            }
            catch (Exception e_)
            {
                Admin_Label.ForeColor = System.Drawing.Color.Red;
                Admin_Label.Text      = "Rating Must be Number";
            }
            string result = client.UpdateStudent(id_, Student);

            Admin_Label.ForeColor = System.Drawing.Color.Green;
            Admin_Label.Text      = result;
            GridView1.DataSource  = client.ShowStudent();
            GridView1.DataBind();
        }