private void btnSua_Click(object sender, RoutedEventArgs e)
 {
     if (tbTen.Text != "")
     {
         if (elementType == 1)
         {
             DTO.BoPhanDTO bp = new DTO.BoPhanDTO();
             bp.MaBP     = tbMa.Text;
             bp.TenBP    = tbTen.Text;
             bp.TruongBP = cbTruong.SelectedValue.ToString();
             BUS.NguoiDungBUS.SetIsUpdated(Login.Account);
             BUS.BoPhanBUS.UpdateBoPhan(bp);
         }
         if (elementType == 2)
         {
             DTO.PhongBanDTO pb = new DTO.PhongBanDTO();
             pb.MaPB     = tbMa.Text;
             pb.ViTri    = tbViTri.Text;
             pb.TenPB    = tbTen.Text;
             pb.TruongPB = cbTruong.SelectedValue.ToString();
             BUS.NguoiDungBUS.SetIsUpdated(Login.Account);
             BUS.PhongBanBUS.UpdatePhongBan(pb);
         }
         Refresh();
     }
     else
     {
         DialogWarning dgWar = new DialogWarning();
         dgWar.Content = "Không được bỏ trống tên!";
         dgWar.Acc     = "false";
         dialogHostWarning.DataContext = dgWar;
         dialogHostWarning.IsOpen      = true;
     }
 }
 private void dialogHost_DialogClosing(object sender, DialogClosingEventArgs eventArgs)
 {
     if ((bool)eventArgs.Parameter == true)
     {
         if (status == "1")
         {
             if (dt.Rows.Count > 0)
             {
                 BUS.NguoiDungBUS.SetIsUpdated(Login.Account);
                 BUS.NhanVienBUS.LayoffNhanVien(dt);
             }
             if (elementType == 1)
             {
                 DTO.BoPhanDTO bp = new DTO.BoPhanDTO();
                 bp.MaBP     = tbMa.Text;
                 bp.TenBP    = tbTen.Text;
                 bp.TruongBP = cbTruong.SelectedValue.ToString();
                 BUS.NguoiDungBUS.SetIsUpdated(Login.Account);
                 BUS.BoPhanBUS.ShutdownBoPhan(bp);
             }
             if (elementType == 2)
             {
                 DTO.PhongBanDTO pb = new DTO.PhongBanDTO();
                 pb.MaPB     = tbMa.Text;
                 pb.ViTri    = tbViTri.Text;
                 pb.TenPB    = tbTen.Text;
                 pb.TruongPB = cbTruong.SelectedValue.ToString();
                 BUS.NguoiDungBUS.SetIsUpdated(Login.Account);
                 BUS.PhongBanBUS.ShutdownPhongBan(pb);
             }
         }
         if (status == "2")
         {
             if (elementType == 1)
             {
                 DTO.BoPhanDTO bp = new DTO.BoPhanDTO();
                 bp.MaBP     = tbMa.Text;
                 bp.TenBP    = tbTen.Text;
                 bp.TruongBP = cbTruong.SelectedValue.ToString();
                 BUS.NguoiDungBUS.SetIsUpdated(Login.Account);
                 BUS.BoPhanBUS.StartBoPhan(bp);
             }
             if (elementType == 2)
             {
                 DTO.PhongBanDTO pb = new DTO.PhongBanDTO();
                 pb.MaPB     = tbMa.Text;
                 pb.ViTri    = tbViTri.Text;
                 pb.TenPB    = tbTen.Text;
                 pb.TruongPB = cbTruong.SelectedValue.ToString();
                 BUS.NguoiDungBUS.SetIsUpdated(Login.Account);
                 BUS.PhongBanBUS.StartPhongBan(pb);
             }
         }
         Refresh();
     }
 }
        public static void AddPhongBan(DTO.PhongBanDTO pb)
        {
            string       query        = @"INSERT INTO PhongBan (MaPB, TenPB, ViTri, MaBP, MaTT) VALUES( '" + pb.MaPB + "', N'" + pb.TenPB + "', N'" + pb.ViTri + "', '" + pb.MaBP + "', 1); ";
            DataProvider dataProvider = new DataProvider();

            try
            {
                dataProvider.ExecuteUpdateQuery(query);
                MessageBox.Show("Thêm phòng ban thành công!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public static void UpdatePhongBan(DTO.PhongBanDTO pb)
        {
            string       query        = @"UPDATE PhongBan SET  TenPB= N'" + pb.TenPB + "', TruongPB='" + pb.TruongPB + "', ViTri=N'" + pb.ViTri + "' Where MaPB = '" + pb.MaPB + "'";
            DataProvider dataProvider = new DataProvider();

            try
            {
                dataProvider.ExecuteUpdateQuery(query);
                MessageBox.Show("Update phòng ban thành công!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public static void StartPhongBan(DTO.PhongBanDTO pb)
        {
            string       query        = @"UPDATE PhongBan SET MaTT=1 Where MaPB = '" + pb.MaPB + "'";
            DataProvider dataProvider = new DataProvider();

            try
            {
                dataProvider.ExecuteUpdateQuery(query);
                MessageBox.Show("Đã tái hoạt động phòng ban!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private void btnThem_Click(object sender, RoutedEventArgs e)
 {
     if (tbTenNew.Text != "")
     {
         if (elementType == 0)
         {
             DTO.BoPhanDTO bp = new DTO.BoPhanDTO();
             maLast       = BUS.BoPhanBUS.GetLastBoPhan().Rows[0][0].ToString();
             tbMaNew.Text = NextID(maLast, "BP");
             bp.MaBP      = tbMaNew.Text;
             bp.TenBP     = tbTenNew.Text;
             BUS.NguoiDungBUS.SetIsUpdated(Login.Account);
             BUS.BoPhanBUS.AddBoPhan(bp);
         }
         if (elementType == 1)
         {
             DTO.PhongBanDTO pb = new DTO.PhongBanDTO();
             maLast       = BUS.PhongBanBUS.GetLastPhongBan().Rows[0][0].ToString();
             tbMaNew.Text = NextID(maLast, "PB");
             pb.MaPB      = tbMaNew.Text;
             pb.TenPB     = tbTenNew.Text;
             pb.ViTri     = tbViTriNew.Text;
             pb.MaBP      = maBP;
             BUS.NguoiDungBUS.SetIsUpdated(Login.Account);
             BUS.PhongBanBUS.AddPhongBan(pb);
         }
         Refresh();
     }
     else
     {
         DialogWarning dgWar = new DialogWarning();
         dgWar.Content = "Không được bỏ trống tên!";
         dgWar.Acc     = "false";
         dialogHostWarning.DataContext = dgWar;
         dialogHostWarning.IsOpen      = true;
     }
 }
Exemple #7
0
 public static void StartPhongBan(DTO.PhongBanDTO pb)
 {
     DAO.PhongBanDAO.StartPhongBan(pb);
 }
Exemple #8
0
 public static void ShutdownPhongBan(DTO.PhongBanDTO pb)
 {
     DAO.PhongBanDAO.ShutdownPhongBan(pb);
 }
Exemple #9
0
 public static void AddPhongBan(DTO.PhongBanDTO pb)
 {
     DAO.PhongBanDAO.AddPhongBan(pb);
 }
Exemple #10
0
 public static void UpdatePhongBan(DTO.PhongBanDTO pb)
 {
     DAO.PhongBanDAO.UpdatePhongBan(pb);
 }