Example #1
0
        public bool DeletePhongBan(PhongBan pb)
        {
            SqlConnection con = new SqlConnection(strQuery);

            con.Open();
            SqlCommand cmd = new SqlCommand("delete from phongban where id=@id", con);

            cmd.Parameters.AddWithValue("@id", pb.PBid);
            cmd.ExecuteNonQuery();
            con.Close();
            return(true);
        }
Example #2
0
        public void UpdatePhongBan(PhongBan pb)
        {
            SqlConnection con = new SqlConnection(strQuery);

            con.Open();
            SqlCommand cmd = new SqlCommand("update phongban set name=@name where id=@id", con);

            cmd.Parameters.AddWithValue("@id", pb.PBid);
            cmd.Parameters.AddWithValue("@name", pb.PBname);
            cmd.ExecuteNonQuery();
            con.Close();
        }
Example #3
0
        public string AddPhongBan(PhongBan pb)
        {
            string        Message;
            SqlConnection con = new SqlConnection(strQuery);

            con.Open();
            SqlCommand cmd = new SqlCommand("insert into phongban(name) values(@name)", con);

            cmd.Parameters.AddWithValue("@name", pb.PBname);
            int result = cmd.ExecuteNonQuery();

            if (result == 1)
            {
                Message = pb.PBname + "them thanh cong";
            }
            else
            {
                Message = pb.PBname + "them khong thanh cong";
            }
            con.Close();
            return(Message);
        }