예제 #1
0
        private async void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckSelectDelete())
            {
                return;
            }
            var selectItem = _havalehSearchData[DgdHavaleh.SelectedIndex];

            Utility.MyMessageBox("هشدار", "آیا از حذف اطمینان دارید؟ ", "Warning.png", false);
            if (!Utility.YesNo)
            {
                return;
            }
            try
            {
                var deleteHavaleh = new DHavaleh
                {
                    DId = selectItem.Id
                };
                await Task.Run(() => deleteHavaleh.Delete());
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در حذف اطلاعات\n" + exception.Message);
                return;
            }

            try
            {
                var deleteSelectProduct = new DSelectProduct
                {
                    DHavalehId = selectItem.Id
                };
                await Task.Run(() => deleteSelectProduct.Delete());
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در حذف اطلاعات\n" + exception.Message);
                return;
            }

            Window_Loaded(null, null);
            Utility.Message("پیام", "اطلاعات با موفقیت حذف گردید", "Correct.png");
        }
예제 #2
0
        private async void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckSelectEdit() || !CheckEmpty())
            {
                return;
            }
            var selectItem = _havalehSearchData[DgdHavaleh.SelectedIndex];

            try
            {
                var editHavaleh = new DHavaleh
                {
                    DId             = selectItem.Id,
                    DFactoryId      = ((tblFactory)CboFactory.SelectedItem).Id,
                    DCountyId       = ((tblCounty)CboCounty.SelectedItem).Id,
                    DBuyerId        = ((tblBuyer)CboBuyer.SelectedItem).Id,
                    DDriverId       = ((tblDriver)CboDriver.SelectedItem).Id,
                    DVehicleTypeId  = ((tblVehicleType)CboVehicle.SelectedItem).Id,
                    DDate           = TxtDate.Text.Trim() == string.Empty ? null : Utility.CurrectDate(TxtDate.Text),
                    DNumber         = TxtNumber.Text.Trim() == string.Empty ? null : TxtNumber.Text,
                    DHavlehNumber   = TxtHavlehNumber.Text.Trim() == string.Empty ? null : TxtHavlehNumber.Text,
                    DHavlehDate     = TxtHavlehDate.Text.Trim() == string.Empty ? null : Utility.CurrectDate(TxtHavlehDate.Text),
                    DHavalehEndDate = TxtHavalehEndDate.Text.Trim() == string.Empty ? null : Utility.CurrectDate(TxtHavalehEndDate.Text)
                };
                await Task.Run(() => editHavaleh.Edit());
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ویرایش اطلاعات پزشک\n" + exception.Message);
                return;
            }

            try
            {
                var deleteSelectProduct = new DSelectProduct
                {
                    DHavalehId = selectItem.Id
                };
                await Task.Run(() => deleteSelectProduct.Delete());
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در حذف اطلاعات\n" + exception.Message);
                return;
            }

            foreach (var t in _createProduct)
            {
                try
                {
                    var addSelectProduct = new DSelectProduct
                    {
                        DHavalehId      = selectItem.Id,
                        DProductId      = t.ProductId,
                        DCapacityId     = t.CapacityId,
                        DCapacityNumber = t.Num
                    };
                    await Task.Run(() => addSelectProduct.Add());
                }
                catch (Exception exception)
                {
                    Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ثبت اطلاعات\n" + exception.Message);
                }
            }

            Window_Loaded(null, null);
            Utility.Message("پیام", "اطلاعات با موفقیت ویرایش گردید", "Correct.png");
        }