Exemple #1
0
 private void Removeforever_IteminDb()
 {
     for (int i = 0; i < RDList.Count(); i++)
     {
         foreach (var item in Model.DataProvider.Ins.DB.NHANVIENs)
         {
             while (item == RDList[i])
             {
                 Model.Nhanvien_Service.Delete(item);
                 break;
             }
         }
     }
     Model.DataProvider.Ins.DB.SaveChanges();
 }
 private void Restone_IteminDb()
 {
     for (int i = 0; i < RDList.Count(); i++)
     {
         foreach (var item in Model.DataProvider.Ins.DB.MATHANGs.ToList())
         {
             while (item == RDList[i])
             {
                 item.IsDeleted = false;
                 Model.DataProvider.Ins.DB.SaveChanges();
                 break;
             }
         }
     }
 }
 private void Removeforever_IteminDb()
 {
     for (int i = 0; i < RDList.Count(); i++)
     {
         foreach (var item in Model.DataProvider.Ins.DB.CHITIETPHIEUXUATs)
         {
             while (item == RDList[i])
             {
                 Model.Xuathang_Service.Delete(item);
                 break;
             }
         }
     }
     Model.DataProvider.Ins.DB.SaveChanges();
 }
Exemple #4
0
        private void Restone_IteminDb()
        {
            for (int i = 0; i < RDList.Count(); i++)
            {
                foreach (var item in Model.DataProvider.Ins.DB.NHANVIENs.ToList())
                {
                    while (item == RDList[i])
                    {
                        Restore_dboTaikhoan(item.ma_nhanvien);

                        item.IsDeleted = false;
                        Model.DataProvider.Ins.DB.SaveChanges();
                        break;
                    }
                }
            }
        }
Exemple #5
0
        public Nhanvien_Deleted_ViewModel()
        {
            List   = new ObservableCollection <Model.NHANVIEN>(Model.DataProvider.Ins.DB.NHANVIENs.Where(x => x.IsDeleted == true));
            RDList = new ObservableCollection <Model.NHANVIEN>();

            Opendel     = false;
            Openres     = false;
            Opendelete  = false;
            Openrestore = false;

            Content      = string.Empty;
            SelectedItem = null;

            CloseDialog_Command = new RelayCommand <MaterialDesignThemes.Wpf.DialogHost>(p =>
            {
                return(true);
            }, p =>
            {
                p.IsOpen = false;
            });

            #region Khoi phuc/ Xoa 1 dong
            DeleteShow_Command = new RelayCommand <Button>(p =>
            {
                if (Openrestore == true || Opendelete == true || Openres == true || Opendel == true)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                Opendelete = true;
                Content    = " Xóa vĩnh viễn bản ghi này";

                string id    = p.Uid.ToString();
                SelectedItem = Model.DataProvider.Ins.DB.NHANVIENs.Where(x => x.ma_nhanvien == id).SingleOrDefault();
            });

            RestoreShow_Command = new RelayCommand <Button>(p =>
            {
                if (Openrestore == true || Opendelete == true || Openres == true || Opendel == true)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                Openrestore = true;
                Content     = " Khôi phục bản ghi này";

                string id    = p.Uid.ToString();
                SelectedItem = Model.DataProvider.Ins.DB.NHANVIENs.Where(x => x.ma_nhanvien == id).SingleOrDefault();
            });

            Delete_Command = new RelayCommand <Button>(p =>
            {
                return(true);
            }, p =>
            {
                Model.Nhanvien_Service.Delete(SelectedItem);
                Model.DataProvider.Ins.DB.SaveChanges();

                List.Remove(SelectedItem);
                Opendelete = false;
            });

            Restore_Command = new RelayCommand <Button>(p =>
            {
                return(true);
            }, p =>
            {
                SelectedItem.IsDeleted = false;
                Model.DataProvider.Ins.DB.SaveChanges();
                Restore_dboTaikhoan(SelectedItem.ma_nhanvien);

                List.Remove(SelectedItem);
                Openrestore = false;
            });
            #endregion

            #region Khoi phuc / Xoa nhieu dong

            AddRDList_Command = new RelayCommand <CheckBox>(p =>
            {
                return(true);
            }, p =>
            {
                RDList.Add(List.Where(x => x.ma_nhanvien == p.Uid.ToString()).SingleOrDefault());
            });

            RemoveRDList_Command = new RelayCommand <CheckBox>(p =>
            {
                return(true);
            }, p =>
            {
                RDList.Remove(List.Where(x => x.ma_nhanvien == p.Uid.ToString()).SingleOrDefault());
            });

            ResShow_Command = new RelayCommand <object>(p =>
            {
                if (RDList.Count() == 0)
                {
                    return(false);
                }

                if (Openrestore == true || Opendelete == true || Openres == true || Opendel == true)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                Openres = true;
                Content = " Khôi phục tất cả các bản ghi được chọn";
            });

            Res_Command = new RelayCommand <object>(p =>
            {
                if (RDList.Count() == 0)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                Restone_IteminDb();
                RemoveIteminList();

                RDList  = new ObservableCollection <Model.NHANVIEN>();
                Openres = false;
            });

            DelShow_Command = new RelayCommand <object>(p =>
            {
                if (RDList.Count() == 0)
                {
                    return(false);
                }

                if (Openrestore == true || Opendelete == true || Openres == true || Opendel == true)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                Opendel = true;
                Content = " Xóa vĩnh viễn tất cả các bản ghi được chọn";
            });

            Del_Command = new RelayCommand <object>(p =>
            {
                if (RDList.Count() == 0)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                Removeforever_IteminDb();
                RemoveIteminList();

                RDList  = new ObservableCollection <Model.NHANVIEN>();
                Opendel = false;
            });
            #endregion

            #region Sap xep

            OrderbyTen_Command = new RelayCommand <object>(p =>
            {
                if (List.Count() == 0)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                ObservableCollection <Model.NHANVIEN> chkList = new ObservableCollection <Model.NHANVIEN>(List.OrderByDescending(x => x.ten_nhanvien));

                if (List[0] == chkList[0])
                {
                    List = new ObservableCollection <Model.NHANVIEN>(List.OrderBy(x => x.ten_nhanvien));
                }
                else
                {
                    List = new ObservableCollection <Model.NHANVIEN>(chkList);
                }
            });

            OrderbyDiachi_Command = new RelayCommand <object>(p =>
            {
                if (List.Count() == 0)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                ObservableCollection <Model.NHANVIEN> chkList = new ObservableCollection <Model.NHANVIEN>(List.OrderByDescending(x => x.diachi));

                if (List[0] == chkList[0])
                {
                    List = new ObservableCollection <Model.NHANVIEN>(List.OrderBy(x => x.diachi));
                }
                else
                {
                    List = new ObservableCollection <Model.NHANVIEN>(chkList);
                }
            });

            OrderbyVitri_Command = new RelayCommand <object>(p =>
            {
                if (List.Count() == 0)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                ObservableCollection <Model.NHANVIEN> chkList = new ObservableCollection <Model.NHANVIEN>(List.OrderByDescending(x => x.QUYEN.ma_quyen));

                if (List[0] == chkList[0])
                {
                    List = new ObservableCollection <Model.NHANVIEN>(List.OrderBy(x => x.QUYEN.ma_quyen));
                }
                else
                {
                    List = new ObservableCollection <Model.NHANVIEN>(chkList);
                }
            });

            #endregion
        }
        public Mathang_Deleted_ViewModel()
        {
            List   = new ObservableCollection <Model.MATHANG>(Model.DataProvider.Ins.DB.MATHANGs.Where(x => x.IsDeleted == true));
            RDList = new ObservableCollection <Model.MATHANG>();

            Opendel     = false;
            Openres     = false;
            Opendelete  = false;
            Openrestore = false;

            Content      = string.Empty;
            SelectedItem = null;

            CloseDialog_Command = new RelayCommand <MaterialDesignThemes.Wpf.DialogHost>(p =>
            {
                return(true);
            }, p =>
            {
                p.IsOpen = false;
            });

            #region Khoi phuc/ Xoa 1 dong
            DeleteShow_Command = new RelayCommand <Button>(p =>
            {
                if (Openrestore == true || Opendelete == true || Openres == true || Opendel == true)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                Opendelete = true;
                Content    = " Xóa vĩnh viễn bản ghi này";

                string id    = p.Uid.ToString();
                SelectedItem = Model.DataProvider.Ins.DB.MATHANGs.Where(x => x.ma_mathang == id).SingleOrDefault();
            });

            RestoreShow_Command = new RelayCommand <Button>(p =>
            {
                if (Openrestore == true || Opendelete == true || Openres == true || Opendel == true)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                Openrestore = true;
                Content     = " Khôi phục bản ghi này";

                string id    = p.Uid.ToString();
                SelectedItem = Model.DataProvider.Ins.DB.MATHANGs.Where(x => x.ma_mathang == id).SingleOrDefault();
            });

            Delete_Command = new RelayCommand <Button>(p =>
            {
                return(true);
            }, p =>
            {
                Model.Mathang_Service.Delete(SelectedItem);
                Model.DataProvider.Ins.DB.SaveChanges();

                List.Remove(SelectedItem);
                Opendelete = false;
            });

            Restore_Command = new RelayCommand <Button>(p =>
            {
                return(true);
            }, p =>
            {
                SelectedItem.IsDeleted = false;
                Model.DataProvider.Ins.DB.SaveChanges();

                List.Remove(SelectedItem);
                Openrestore = false;
            });
            #endregion

            #region Khoi phuc / Xoa nhieu dong

            AddRDList_Command = new RelayCommand <CheckBox>(p =>
            {
                return(true);
            }, p =>
            {
                RDList.Add(List.Where(x => x.ma_mathang == p.Uid.ToString()).SingleOrDefault());
            });

            RemoveRDList_Command = new RelayCommand <CheckBox>(p =>
            {
                return(true);
            }, p =>
            {
                RDList.Remove(List.Where(x => x.ma_mathang == p.Uid.ToString()).SingleOrDefault());
            });

            ResShow_Command = new RelayCommand <object>(p =>
            {
                if (RDList.Count() == 0)
                {
                    return(false);
                }

                if (Openrestore == true || Opendelete == true || Openres == true || Opendel == true)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                Openres = true;
                Content = " Khôi phục tất cả các bản ghi được chọn";
            });

            Res_Command = new RelayCommand <object>(p =>
            {
                if (RDList.Count() == 0)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                Restone_IteminDb();
                RemoveIteminList();

                RDList  = new ObservableCollection <Model.MATHANG>();
                Openres = false;
            });

            DelShow_Command = new RelayCommand <object>(p =>
            {
                if (RDList.Count() == 0)
                {
                    return(false);
                }

                if (Openrestore == true || Opendelete == true || Openres == true || Opendel == true)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                Opendel = true;
                Content = " Xóa vĩnh viễn tất cả các bản ghi được chọn";
            });

            Del_Command = new RelayCommand <object>(p =>
            {
                if (RDList.Count() == 0)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                Removeforever_IteminDb();
                RemoveIteminList();

                RDList  = new ObservableCollection <Model.MATHANG>();
                Opendel = false;
            });
            #endregion

            #region Phan sap xep

            OrderbyTenMathang_Command = new RelayCommand <object>(p =>
            {
                if (List.Count() == 0)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                ObservableCollection <Model.MATHANG> chkList = new ObservableCollection <Model.MATHANG>(List.OrderByDescending(x => x.ten_mathang));

                if (List[0] == chkList[0])
                {
                    List = new ObservableCollection <Model.MATHANG>(List.OrderBy(x => x.ten_mathang));
                }
                else
                {
                    List = new ObservableCollection <Model.MATHANG>(chkList);
                }
            });

            OrderbyTennhacungcap_Command = new RelayCommand <object>(p =>
            {
                if (List.Count() == 0)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                ObservableCollection <Model.MATHANG> chkList = new ObservableCollection <Model.MATHANG>(List.OrderByDescending(x => x.NHACUNGCAP.ten_nhacungcap));

                if (List[0] == chkList[0])
                {
                    List = new ObservableCollection <Model.MATHANG>(List.OrderBy(x => x.NHACUNGCAP.ten_nhacungcap));
                }
                else
                {
                    List = new ObservableCollection <Model.MATHANG>(chkList);
                }
            });

            OrderbyTenloai_Command = new RelayCommand <object>(p =>
            {
                if (List.Count() == 0)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                ObservableCollection <Model.MATHANG> chkList = new ObservableCollection <Model.MATHANG>(List.OrderByDescending(x => x.LOAIHANG.ten_loaihang));

                if (List[0] == chkList[0])
                {
                    List = new ObservableCollection <Model.MATHANG>(List.OrderBy(x => x.LOAIHANG.ten_loaihang));
                }
                else
                {
                    List = new ObservableCollection <Model.MATHANG>(chkList);
                }
            });

            OrderbyTendonvi_Command = new RelayCommand <object>(p =>
            {
                if (List.Count() == 0)
                {
                    return(false);
                }

                return(true);
            }, p =>
            {
                ObservableCollection <Model.MATHANG> chkList = new ObservableCollection <Model.MATHANG>(List.OrderByDescending(x => x.DONVITINH.ten_donvi));

                if (List[0] == chkList[0])
                {
                    List = new ObservableCollection <Model.MATHANG>(List.OrderBy(x => x.DONVITINH.ten_donvi));
                }
                else
                {
                    List = new ObservableCollection <Model.MATHANG>(chkList);
                }
            });

            #endregion
        }