예제 #1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (KiemTraThongTinTrong())
            {
                MessageBox.Show("Làm ơn điền đầy đủ thông tin báo");
            }
            else
            {
                if (KiemTraThongTinHopLe())
                {
                    BaoDTO baoDTO = new BaoDTO(txtTenBao.Text, txtMoTa.Text);

                    try
                    {
                        if (baoBLL.ThemBao(baoDTO))
                        {
                            MessageBox.Show("Thêm báo thành công");
                            dgvBao.DataSource = baoBLL.LayDanhSachBao();
                        }
                        else
                        {
                            MessageBox.Show("Thêm báo thất bại");
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }
예제 #2
0
 public bool ThemBao(BaoDTO baoDTO)
 {
     try
     {
         OpenConnect();
         string store = "sp_Bao_Them";
         sqlCommand             = new SqlCommand(store, connect);
         sqlCommand.CommandType = CommandType.StoredProcedure;
         sqlCommand.Parameters.Add(new SqlParameter("@ten", baoDTO.TenBao));
         sqlCommand.Parameters.Add(new SqlParameter("@mota", baoDTO.MoTaBao));
         sqlCommand.ExecuteNonQuery();
         return(true);
     }
     catch
     {
         return(false);
     }
     finally
     {
         CloseConnect();
     }
 }
예제 #3
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (id == "")
            {
                MessageBox.Show("Làm ơn chọn báo muốn sửa");
            }
            else
            {
                if (KiemTraThongTinTrong())
                {
                    MessageBox.Show("Làm ơn điền đầy đủ thông tin báo");
                }
                else
                {
                    if (KiemTraThongTinHopLe())
                    {
                        BaoDTO baoDTO = new BaoDTO(Int32.Parse(txtMaBao.Text), txtTenBao.Text, txtMoTa.Text);

                        try
                        {
                            if (baoBLL.SuaBao(baoDTO))
                            {
                                MessageBox.Show("Sửa báo thành công");
                                dgvBao.DataSource = baoBLL.LayDanhSachBao();
                                LamMoiThongTin();
                            }
                            else
                            {
                                MessageBox.Show("Sửa báo thất bại");
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
        }
예제 #4
0
 public bool SuaBao(BaoDTO baoDTO)
 {
     return(baoDAL.SuaBao(baoDTO));
 }
예제 #5
0
 public bool ThemBao(BaoDTO baoDTO)
 {
     return(baoDAL.ThemBao(baoDTO));
 }