Exemplo n.º 1
0
        public string Add_PhongBan(Cls_PhongBan pb)
        {
            string strMessage = string.Empty;
            using (SqlConnection conn = new SqlConnection(strConnection))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("insert into Tb_PhongBan (MaPB,TenPB,DienThoai,Fax) values(@MAPB,@TENPB,@DIENTHOAI,@FAX)", conn);
                cmd.Parameters.AddWithValue("@MAPB", pb.mapb);
                cmd.Parameters.AddWithValue("@TENPB", pb.tenpb);
                cmd.Parameters.AddWithValue("@DIENTHOAI", pb.dienthoai);
                cmd.Parameters.AddWithValue("@FAX", pb.fax);

                int result = cmd.ExecuteNonQuery();
                if (result == 1)
                {
                    strMessage = pb.mapb + " đã thêm thành công!";
                }
                else
                {
                    strMessage = pb.mapb + " đã thêm không thành công!";
                }
                conn.Close();
            }
            return strMessage;
        }
Exemplo n.º 2
0
        public string Delete_PhongBan(Cls_PhongBan pb)
        {
            string strMessage = string.Empty;
            using (SqlConnection conn = new SqlConnection(strConnection))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("delete Tb_PhongBan where MaPB=@MAPB", conn);
                cmd.Parameters.AddWithValue("@MAPB", pb.mapb);

                int result = cmd.ExecuteNonQuery();
                if (result == 1)
                {
                    strMessage = pb.mapb + " đã delete thành công!";
                }
                else
                {
                    strMessage = pb.mapb + " delete không thành công!";
                }
                conn.Close();
            }
            return strMessage;
        }
Exemplo n.º 3
0
        public string Update_PhongBan(Cls_PhongBan pb)
        {
            string strMessage = string.Empty;
            using (SqlConnection conn = new SqlConnection(strConnection))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("update Tb_PhongBan set TenPB=@TENPB,DienThoai=@DIENTHOAI,Fax=@FAX where MaPB=@MAPB", conn);
                cmd.Parameters.AddWithValue("@MAPB", pb.mapb);
                cmd.Parameters.AddWithValue("@TENPB", pb.tenpb);
                cmd.Parameters.AddWithValue("@DIENTHOAI", pb.dienthoai);
                cmd.Parameters.AddWithValue("@FAX", pb.fax);

                int result = cmd.ExecuteNonQuery();
                if (result == 1)
                {
                    strMessage = pb.mapb + " đã update thành công!";
                }
                else
                {
                    strMessage = pb.mapb + " update không thành công!";
                }
                conn.Close();
            }
            return strMessage;
        }