Exemple #1
0
        private async void BtnAdd_Click(object sender, RoutedEventArgs e)

        {
            if (!CheckEmpty())
            {
                return;
            }
            var havalehId = 0;

            #region AddHavaleh

            try
            {
                var addHavaleh = new DHavaleh
                {
                    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)
                };
                havalehId = Convert.ToInt32(await addHavaleh.Add());
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ثبت اطلاعات\n" + exception.Message);
            }

            foreach (var t in _createProduct)
            {
                try
                {
                    var addSelectProduct = new DSelectProduct
                    {
                        DHavalehId      = havalehId,
                        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");

            #endregion
        }
Exemple #2
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");
        }
Exemple #3
0
        private async void DgdDoctor_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (DgdHavaleh.SelectedIndex == -1)
            {
                return;
            }

            BtnAdd.IsEnabled = false;

            DgdProduct.ItemsSource = null;
            _createProduct         = null;
            _s1            = null;
            _s2            = null;
            _s3            = null;
            _s4            = null;
            _s5            = null;
            _createProduct = new List <CreateProduct>();
            _s1            = new List <byte>();
            _s2            = new List <byte>();
            _s3            = new List <byte>();
            _s4            = new List <string>();
            _s5            = new List <string>();

            var selectItem = _havalehSearchData[DgdHavaleh.SelectedIndex];

            CboFactory.SelectedValue  = selectItem.Factory_Id;
            CboProvince.SelectedValue = selectItem.Province_Id;
            CboCounty.SelectedValue   = selectItem.County_Id;
            CboBuyer.SelectedValue    = selectItem.Buyer_Id;
            CboDriver.SelectedValue   = selectItem.Driver_Id;
            CboVehicle.SelectedValue  = selectItem.VehicleType_Id;

            TxtNumber.Text         = selectItem.Number;
            TxtDate.Text           = selectItem.Date;
            TxtHavlehNumber.Text   = selectItem.HavlehNumber;
            TxtHavlehDate.Text     = selectItem.HavlehDate;
            TxtHavalehEndDate.Text = selectItem.HavalehEndDate;

            LblMobile.Content = selectItem.DriverMobile;
            LblPelak.Content  = selectItem.NumberPlates;

            var selectProductData = await Task.Run(() => DSelectProduct.GetData(selectItem.Id));


            foreach (var t in selectProductData)
            {
                if (t.Product_Id != null)
                {
                    _s1.Add((byte)t.Product_Id);
                }
                if (t.Capacity_Id != null)
                {
                    _s2.Add((byte)t.Capacity_Id);
                }
                if (t.CapacityNumber != null)
                {
                    _s3.Add((byte)t.CapacityNumber);
                }

                _s4.Add(t.ProductName);
                _s5.Add(t.CapacityNumber + " " + t.CapacityName);
            }
            _createProduct = new List <CreateProduct>();
            for (var i = 0; i < _s1.Count; i++)
            {
                _createProduct.Add(new CreateProduct(_s1[i], _s2[i], _s3[i], _s4[i], _s5[i]));
            }
            DgdProduct.ItemsSource = _createProduct;
        }
Exemple #4
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");
        }