public bool editKhoa(khoa mk, string makhoa)
        {
            SqlConnection conn = new SqlConnection(connectString);
            string        sql  = "update KHOA set TenKhoa= @tenkhoa, SDT = @sodienthoai, Email = @email  Where MaKhoa= @makhoa";
            SqlCommand    cmd  = new SqlCommand(sql, conn);

            cmd.Parameters.AddWithValue("@makhoa", makhoa);
            cmd.Parameters.AddWithValue("@tenkhoa", mk.TenKhoa);
            cmd.Parameters.AddWithValue("@sodienthoai", mk.SDT);
            cmd.Parameters.AddWithValue("@email", mk.Email);
            conn.Open();
            int count = cmd.ExecuteNonQuery();

            conn.Close();
            return(count >= 1);
        }
Ejemplo n.º 2
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            int  SDT = int.Parse(txtSDT.Text);
            khoa kh  = new khoa(txtTK.Text, SDT, txteml.Text);

            if (khoadao.editKhoa(kh, txtMK.Text))
            {
                lblTB.Text        = "Đã EDIT";
                gvKhoa.DataSource = khoadao.getTable("select * from KHOA");
                gvKhoa.DataBind();
            }
            else
            {
                lblTB.Text = "ERROR";
            }
        }
Ejemplo n.º 3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int  sdt = int.Parse(txtSDT.Text.ToString());
            khoa kh  = new khoa(txtTK.Text, sdt, txteml.Text);

            if (khoadao.addKhoa(kh))
            {
                lblTB.Text        = "Successfully";
                gvKhoa.DataSource = khoadao.getTable("select * from KHOA");
                Page.DataBind();
            }
            else
            {
                lblTB.Text = "Failed ";
            }
        }
        public bool addKhoa(khoa kh)
        {
            SqlConnection conn = new SqlConnection(connectString);
            //  khoa kh = new khoa( txtTK.Text,sdt ,txteml.Text);
            string     sql = @"INSERT INTO KHOA(TenKhoa, SDT, Email) VALUES (@tenkhoa, @sdt, @email)";
            SqlCommand cmd = new SqlCommand(sql, conn);

            cmd.Parameters.AddWithValue("@tenkhoa", kh.TenKhoa);

            cmd.Parameters.AddWithValue("@sdt", kh.SDT);

            cmd.Parameters.AddWithValue("@email", kh.Email);
            conn.Open();
            int dem = cmd.ExecuteNonQuery();

            conn.Close();
            return(dem >= 1);
        }