Ejemplo n.º 1
0
 public bool ThemBaiViet(BaiVietDTO baiVietDTO)
 {
     try
     {
         OpenConnect();
         string store = "sp_BaiViet_Them";
         sqlCommand             = new SqlCommand(store, connect);
         sqlCommand.CommandType = CommandType.StoredProcedure;
         sqlCommand.Parameters.Add(new SqlParameter("@machitietquangcao", baiVietDTO.MaChiTietQuangCao));
         sqlCommand.Parameters.Add(new SqlParameter("@manhanvien", baiVietDTO.MaNhanVien));
         sqlCommand.Parameters.Add(new SqlParameter("@noidungbaiviet", baiVietDTO.NoiDungBaiViet));
         sqlCommand.Parameters.Add(new SqlParameter("@trangthaikiemduyet", baiVietDTO.TrangThaiKiemDuyet));
         sqlCommand.Parameters.Add(new SqlParameter("@lydokhongduyet", baiVietDTO.LyDoKhongDuyet));
         sqlCommand.ExecuteNonQuery();
         return(true);
     }
     catch
     {
         return(false);
     }
     finally
     {
         CloseConnect();
     }
 }
Ejemplo n.º 2
0
        public bool SuaKiemDuyetBaiViet(BaiVietDTO baiVietDTO)
        {
            try
            {
                OpenConnect();
                string store = "sp_BaiViet_SuaKiemDuyet";
                sqlCommand             = new SqlCommand(store, connect);
                sqlCommand.CommandType = CommandType.StoredProcedure;

                sqlCommand.Parameters.Add(new SqlParameter("@mabaiviet", baiVietDTO.MaBaiViet));
                sqlCommand.Parameters.Add(new SqlParameter("@trangthaikiemduyet", baiVietDTO.TrangThaiKiemDuyet));
                sqlCommand.Parameters.Add(new SqlParameter("@lydokhongduyet", baiVietDTO.LyDoKhongDuyet));

                sqlCommand.ExecuteNonQuery();
                return(true);
            }
            catch
            {
                return(false);
            }
            finally
            {
                CloseConnect();
            }
        }
Ejemplo n.º 3
0
        //private void dgvChiTietQuangCao_CellContentClick(object sender, DataGridViewCellEventArgs e)
        //{
        //    if (e.RowIndex >= 0)
        //    {
        //        try
        //        {
        //            DataGridViewRow row = dgvChiTietQuangCao.Rows[e.RowIndex];
        //            int columnIndex = dgvChiTietQuangCao.CurrentCell.ColumnIndex;
        //            string columnName = dgvChiTietQuangCao.Columns[columnIndex].Name;
        //            int maCTQC = Int32.Parse(row.Cells["MaChiTietQuangCao"].Value.ToString());

        //            if (columnName.Equals("ChiTietCT"))
        //            {
        //                DialogChiTietQuangCao dialogChiTietQuangCao = new DialogChiTietQuangCao(maCTQC);
        //                dialogChiTietQuangCao.StartPosition = FormStartPosition.CenterScreen;
        //                dialogChiTietQuangCao.ShowDialog(this);
        //            }

        //            if (columnName.Equals("XacNhanCT"))
        //            {
        //                int trangThai = 0;
        //                if (row.Cells["TrangThaiKiemDuyetCT"].Value.ToString().Equals("1"))
        //                    trangThai = 1;
        //                string lyDo = "";
        //                if (trangThai == 0)
        //                    lyDo = row.Cells["LyDoKhongDuyetCT"].Value.ToString();
        //                ChiTietQuangCaoDTO chiTietQuangCaoDTO = new ChiTietQuangCaoDTO(maCTQC, trangThai, lyDo);
        //                try
        //                {
        //                    if (chiTietQuangCaoBLL.SuaKiemDuyetChiTietQuangCao(chiTietQuangCaoDTO))
        //                    {
        //                        MessageBox.Show("Sửa trạng thái chi tiết quảng cáo thành công");
        //                        LoadChiTietQuangCao();
        //                    }
        //                    else
        //                    {
        //                        MessageBox.Show("Sửa trạng thái chi tiết quảng cáo thất bại");
        //                    }
        //                }
        //                catch
        //                {
        //                }
        //            }

        //        }
        //        catch { }
        //    }
        //}

        private void dgvBaiViet_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                try
                {
                    DataGridViewRow row         = dgvBaiViet.Rows[e.RowIndex];
                    int             columnIndex = dgvBaiViet.CurrentCell.ColumnIndex;
                    string          columnName  = dgvBaiViet.Columns[columnIndex].Name;
                    int             maBV        = Int32.Parse(row.Cells["MaBaiViet"].Value.ToString());

                    if (columnName.Equals("ChiTietBV"))
                    {
                        DialogBaiViet dialogBaiViet = new DialogBaiViet(maBV);
                        dialogBaiViet.StartPosition = FormStartPosition.CenterScreen;
                        dialogBaiViet.ShowDialog(this);
                    }

                    if (columnName.Equals("XacNhanBV"))
                    {
                        int trangThai = 0;
                        if (row.Cells["TrangThaiKiemDuyetBV"].Value.ToString().Equals("1"))
                        {
                            trangThai = 1;
                        }
                        string lyDo = "";
                        if (trangThai == 0)
                        {
                            lyDo = row.Cells["LyDoKhongDuyetBV"].Value.ToString();
                        }
                        BaiVietDTO baiVietDTO = new BaiVietDTO(maBV, trangThai, lyDo);
                        try
                        {
                            if (baiVietBLL.SuaKiemDuyetBaiViet(baiVietDTO))
                            {
                                MessageBox.Show("Sửa trạng thái bài viết thành công");
                                LoadBaiViet();
                            }
                            else
                            {
                                MessageBox.Show("Sửa trạng thái bài viết thất bại");
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                catch { }
            }
        }
Ejemplo n.º 4
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (KiemTraThongTinTrong())
            {
                MessageBox.Show("Làm ơn điền đầy đủ thông tin bài viết");
            }
            else
            {
                if (KiemTraThongTinHopLe())
                {
                    int trangThaiKiemDuyet = 0;
                    if (rbDaKiemDuyet.Checked)
                    {
                        trangThaiKiemDuyet = 1;
                    }

                    BaiVietDTO baiVietDTO = new BaiVietDTO(
                        Int32.Parse(txtMaBaiViet.Text.ToString()),
                        Int32.Parse(cbChiTietQuangCao.SelectedValue.ToString()),
                        Int32.Parse(cbNhanVien.SelectedValue.ToString()),
                        txtNoiDungBaiViet.Text.ToString(),
                        trangThaiKiemDuyet, "");

                    try
                    {
                        if (baiVietBLL.SuaBaiViet(baiVietDTO))
                        {
                            MessageBox.Show("Sửa bài viết thành công");
                            if (MaChiTietQuangCaoPoup == 0)
                            {
                                dgvBaiViet.DataSource = baiVietBLL.LayDanhSachBaiVietTheoTenNhanVien();
                            }
                            else
                            {
                                dgvBaiViet.DataSource = baiVietBLL.LayDanhSachBaiVietTheoMaChiTietQuangCao(MaChiTietQuangCaoPoup);
                            }
                            LamMoiThongTin();
                        }
                        else
                        {
                            MessageBox.Show("Sửa bài viết thất bại");
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public bool SuaKiemDuyetBaiViet(BaiVietDTO baiVietDTO)
 {
     return(baiVietDAL.SuaKiemDuyetBaiViet(baiVietDTO));
 }
Ejemplo n.º 6
0
 public bool SuaBaiViet(BaiVietDTO baiVietDTO)
 {
     return(baiVietDAL.SuaBaiViet(baiVietDTO));
 }
Ejemplo n.º 7
0
 public bool ThemBaiViet(BaiVietDTO baiVietDTO)
 {
     return(baiVietDAL.ThemBaiViet(baiVietDTO));
 }