Example #1
0
        private void Delete_click(object sender, RoutedEventArgs e)
        {
            ///
            if (DD.Visibility == Visibility.Visible)
            {
                #region DataGrid #1
                DD.BeginSelection();
                string index    = "";
                var    acc      = new Assest.OrcDataAcess();
                int    counting = 0;

                foreach (int handle in DD.GetSelectedRowHandles())
                {
                    if (counting == 0)
                    {
                        MessageBoxResult a = DXMessageBox.Show("سيتم حذف جميع الفواتير المحدد عليها, هل ترغب بمواصلة العملية؟", "تنبيه", MessageBoxButton.YesNo, MessageBoxImage.Information);
                        switch (a)
                        {
                        case MessageBoxResult.None:
                            break;

                        case MessageBoxResult.OK:
                        {
                            break;
                        }

                        case MessageBoxResult.Cancel:
                            break;

                        case MessageBoxResult.Yes:
                        {
                            index = (string)DD.GetCellValue(handle, "id");
                            acc.Delete3(index);

                            break;
                        }

                        case MessageBoxResult.No:
                            break;

                        default:
                            break;
                        }
                    }
                    else if (counting >= 1)
                    {
                        index = (string)DD.GetCellValue(handle, "id");
                        acc.Delete3(index);
                    }



                    counting++;
                }
                if (counting == 0)
                {
                    MessageBoxResult a = DXMessageBox.Show("سيتم حذف جميع الفواتير, هل ترغب بمواصلة العملية؟", "تنبيه", MessageBoxButton.YesNo, MessageBoxImage.Information);
                    switch (a)
                    {
                    case MessageBoxResult.None:
                        break;

                    case MessageBoxResult.OK:
                    {
                        break;
                    }

                    case MessageBoxResult.Cancel:
                        break;

                    case MessageBoxResult.Yes:
                    {
                        acc.Delete3();
                        break;
                    }

                    case MessageBoxResult.No:
                        break;

                    default:
                        break;
                    }
                }
                DD.EndSelection();
                var datatablee = new DataTable();
                show.show3(datatablee);

                System.Windows.Forms.BindingSource BindS = new System.Windows.Forms.BindingSource();
                BindS.DataSource = datatablee;
                DD.ItemsSource   = BindS;

                Resultpri.Text   = Fos.sumPrice();
                Resultpri_a.Text = Fos.sumPrice_a();
                #endregion
            }
            else if (DDR.Visibility == Visibility.Visible)
            {
                #region Datagrid #2
                DDR.BeginSelection();
                var listU = new List <string>();
                listU = SaveDelete();

                string iindex    = "";
                int    countingg = 0;
                var    megav     = new ModelMega();

                foreach (int handle in DDR.GetSelectedRowHandles())
                {
                    if (countingg == 0)
                    {
                        MessageBoxResult a = DXMessageBox.Show("سيتم حذف جميع البيانات المحدد عليها, هل ترغب بمواصلة العملية؟", "تنبيه", MessageBoxButton.YesNo, MessageBoxImage.Information);
                        switch (a)
                        {
                        case MessageBoxResult.None:
                            break;

                        case MessageBoxResult.OK:
                        {
                            break;
                        }

                        case MessageBoxResult.Cancel:
                            break;

                        case MessageBoxResult.Yes:
                        {
                            iindex = (string)DDR.GetCellValue(handle, "رمز المنتج");
                            megav.Delete(iindex);

                            break;
                        }

                        case MessageBoxResult.No:
                            break;

                        default:
                            break;
                        }
                    }
                    else if (countingg >= 1)
                    {
                        iindex = (string)DDR.GetCellValue(handle, "رمز المنتج");
                        megav.Delete(iindex);
                    }



                    countingg++;
                }
                if (countingg == 0)
                {
                    MessageBoxResult a = DXMessageBox.Show("سيتم حذف جميع البيانات, هل ترغب بمواصلة العملية؟", "تنبيه", MessageBoxButton.YesNo, MessageBoxImage.Information);
                    switch (a)
                    {
                    case MessageBoxResult.None:
                        break;

                    case MessageBoxResult.OK:
                    {
                        break;
                    }

                    case MessageBoxResult.Cancel:
                        break;

                    case MessageBoxResult.Yes:
                    {
                        ///Need To Fix_+_+_+_+__++_+_+__+_+_++_+_+_+__+_+__+_
                        megav.Delete();

                        break;
                    }

                    case MessageBoxResult.No:
                        break;

                    default:
                        break;
                    }
                }
                DDR.EndSelection();
                var obr      = new ObservableCollectionCore <Models.RepairView>();
                var megaView = new MegaView();
                foreach (DataRow item in megaView.GetAllItemsHasSold().Rows)
                {
                    obr.Add(new Models.RepairView()
                    {
                        ID        = item.Field <string>("ID"),
                        conprou   = item.Field <string>("conprou"),
                        PRICE     = item.Field <string>("PRICE"),
                        DAT       = item.Field <string>("DAT"),
                        NAME      = item.Field <string>("NAME"),
                        datrec    = item.Field <string>("datrec"),
                        discounts = item.Field <string>("discounts"),
                        typeprou  = item.Field <string>("typeprou"),
                        isdone    = (item.Field <Int64>("isdone") == -1?true:false)
                    });
                }
                DDR.ItemsSource = obr; Resultpri_a.Text = Fos.sumPrice_a();

                #endregion
            }
        }