예제 #1
0
        private async Task LoadDataAsync(string search = "")
        {
            try
            {
                _token?.Cancel();
                _token = new CancellationTokenSource();
                var list = await FloorCoverBussines.GetAllAsync(search, _token.Token);

                Invoke(new MethodInvoker(() => FloorBindingSource.DataSource =
                                             list.Where(q => q.Status == _st).OrderBy(q => q.Name).ToSortableBindingList()));
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
예제 #2
0
        private async void frmFloorCoverMain_Load(object sender, EventArgs e)
        {
            try
            {
                SetData();
                var myCollection = new AutoCompleteStringCollection();
                _token?.Cancel();
                _token = new CancellationTokenSource();
                var list = await FloorCoverBussines.GetAllAsync(_token.Token);

                foreach (var item in list.ToList())
                {
                    myCollection.Add(item.Name);
                }
                txtName.AutoCompleteCustomSource = myCollection;
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
        private async Task <ReturnedSaveFuncInfo> SetObjectAsync()
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                cls.Code               = txtCode.Text;
                cls.Modified           = DateTime.Now;
                cls.OwnerGuid          = owner.Guid;
                cls.UserGuid           = (Guid)cmbUser.SelectedValue;
                cls.Priority           = EnBuildingPriority.Medium;
                cls.IsArchive          = false;
                cls.SellPrice          = txtSellPrice.TextDecimal;
                cls.QestPrice          = txtQestPrice.TextDecimal;
                cls.VamPrice           = txtVamPrice.TextDecimal;
                cls.Dang               = txtDong.Text.ParseToInt();
                cls.DocumentType       = (Guid)cmbSellSanadType.SelectedValue;
                cls.Tarakom            = (EnTarakom)cmbSellTarakom.SelectedIndex;
                cls.RahnPrice1         = txtRahnPrice1.TextDecimal;
                cls.RahnPrice2         = 0;
                cls.EjarePrice1        = txtEjarePrice1.TextDecimal;
                cls.EjarePrice2        = 0;
                cls.RentalAutorityGuid = (Guid)cmbRentalAuthority.SelectedValue;
                cls.IsShortTime        = false;
                cls.IsOwnerHere        = false;
                cls.PishTotalPrice     = 0;
                cls.PishPrice          = 0;
                cls.DeliveryDate       = null;

                if (cmbMasahat.SelectedIndex == 0)
                {
                    cls.Masahat = txtMasahat.Text.ParseToInt();
                }
                if (cmbMasahat.SelectedIndex == 1)
                {
                    cls.Masahat = txtMasahat.Text.ParseToInt() * 10000;
                }

                if (cmbZirBana.SelectedIndex == 0)
                {
                    cls.ZirBana = txtZirBana.Text.ParseToInt();
                }
                if (cmbZirBana.SelectedIndex == 1)
                {
                    cls.ZirBana = txtZirBana.Text.ParseToInt() * 10000;
                }

                cls.CityGuid              = (Guid)cmbCity.SelectedValue;
                cls.RegionGuid            = (Guid)cmbRegion.SelectedValue;
                cls.Address               = txtAddress.Text;
                cls.BuildingConditionGuid = (Guid)cmbBuildingCondition.SelectedValue;
                cls.Side                    = EnBuildingSide.One;
                cls.BuildingTypeGuid        = (Guid)cmbBuildingType.SelectedValue;
                cls.ShortDesc               = txtShortDesc.Text;
                cls.BuildingAccountTypeGuid = (Guid)cmbBAccountType.SelectedValue;
                cls.MetrazhTejari           = 0;
                _token?.Cancel();
                _token = new CancellationTokenSource();
                var views = await BuildingViewBussines.GetAllAsync(_token.Token);

                if (views.Count > 0)
                {
                    cls.BuildingViewGuid = views[0].Guid;
                }
                _token?.Cancel();
                _token = new CancellationTokenSource();
                var fCover = await FloorCoverBussines.GetAllAsync(_token.Token);

                if (fCover.Count > 0)
                {
                    cls.FloorCoverGuid = fCover[0].Guid;
                }
                _token?.Cancel();
                _token = new CancellationTokenSource();
                var kService = await KitchenServiceBussines.GetAllAsync(_token.Token);

                if (kService.Count > 0)
                {
                    cls.KitchenServiceGuid = kService[0].Guid;
                }
                cls.Water          = EnKhadamati.Mostaqel;
                cls.Barq           = EnKhadamati.Mostaqel;
                cls.Gas            = EnKhadamati.Mostaqel;
                cls.Tell           = EnKhadamati.Mostaqel;
                cls.TedadTabaqe    = 0;
                cls.TabaqeNo       = 0;
                cls.VahedPerTabaqe = 0;
                cls.MetrazhKouche  = 0;
                cls.Hashie         = 0;
                cls.ErtefaSaqf     = 3;
                cls.SaleSakht      = txtSaleSakht.Text;
                cls.BonBast        = false;
                cls.MamarJoda      = true;
                cls.RoomCount      = txtTedadOtaq.Text.ParseToInt();
                cls.Image          = "";
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
예제 #4
0
        public static async Task InsertDefaultDataAsync()
        {
            var            res = new ReturnedSaveFuncInfo();
            SqlTransaction tr  = null;
            SqlConnection  cn  = null;

            try
            {
                cn = new SqlConnection(Cache.ConnectionString);
                await cn.OpenAsync();

                tr = cn.BeginTransaction();

                #region Kol
                var allKol = await KolBussines.GetAllAsync(new CancellationToken());

                if (allKol == null || allKol.Count <= 0)
                {
                    var kol = DefaultKol.SetDef();
                    res.AddReturnedValue(await KolBussines.SaveRangeAsync(kol, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region Moein
                var allMoein = await MoeinBussines.GetAllAsync(new CancellationToken());

                if (allMoein == null || allMoein.Count <= 0)
                {
                    var moein = DefaultMoein.SetDef();
                    res.AddReturnedValue(await MoeinBussines.SaveRangeAsync(moein, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region Tafsil
                var allTafsil = await TafsilBussines.GetAllAsync(new CancellationToken());

                if (allTafsil == null || allTafsil.Count <= 0)
                {
                    var tafsil = DefaultTafsil.SetDef();
                    res.AddReturnedValue(await TafsilBussines.SaveRangeAsync(tafsil, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region Bank
                var allBank = await BankBussines.GetAllAsync(new CancellationToken());

                if (allBank == null || allBank.Count <= 0)
                {
                    var user = new BankBussines()
                    {
                        Guid = ParentDefaults.TafsilCoding.CLSTafsil1010101,
                        Name = "حساب بانکی مرکزی",
                        Code = "1010101",
                    };
                    res.AddReturnedValue(await user.SaveAsync(tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region Bank Segest
                var allbs = await BankSegestBussines.GetAllAsync();

                if (allbs == null || allbs.Count <= 0)
                {
                    var bs = DefaultBankSegest.SetDef();
                    res.AddReturnedValue(await BankSegestBussines.SaveRangeAsync(bs, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region Users
                var allusers = await UserBussines.GetAllAsync(new CancellationToken());

                var access = new AccessLevel();
                if (allusers == null || allusers.Count <= 0)
                {
                    var user = new UserBussines()
                    {
                        Guid             = ParentDefaults.TafsilCoding.CLSTafsil1030401,
                        Name             = "کاربر پیش فرض",
                        UserName         = "******",
                        SecurityQuestion = 0,
                        Access           = Json.ToStringJson(access)
                    };
                    var ue        = new UTF8Encoding();
                    var bytes     = ue.GetBytes("2211");
                    var md5       = new MD5CryptoServiceProvider();
                    var hashBytes = md5.ComputeHash(bytes);
                    user.Password = System.Text.RegularExpressions.Regex.Replace(BitConverter.ToString(hashBytes), "-", "")
                                    .ToLower();
                    res.AddReturnedValue(await user.SaveAsync(tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region States
                var allStates = await StatesBussines.GetAllAsync(new CancellationToken());

                if (allStates == null || allStates.Count <= 0)
                {
                    var states = DefaultStates.SetDef();
                    res.AddReturnedValue(await StatesBussines.SaveRangeAsync(states, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region Cities
                var allCities = await CitiesBussines.GetAllAsync(new CancellationToken());

                if (allCities == null || allCities.Count <= 0)
                {
                    var city = DefaultCities.SetDef();
                    res.AddReturnedValue(await CitiesBussines.SaveRangeAsync(city, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region Regions
                var allRegions = await RegionsBussines.GetAllAsync(new CancellationToken());

                if (allRegions == null || allRegions.Count <= 0)
                {
                    var reg = DefaultRegions.SetDef();
                    res.AddReturnedValue(await RegionsBussines.SaveRangeAsync(reg, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region Naqz
                var allNaqz = await NaqzBussines.GetAllAsync();

                if (allNaqz == null || allNaqz.Count <= 0)
                {
                    var naqz = DefaultNaqz.SetDef();
                    res.AddReturnedValue(await NaqzBussines.SaveRangeAsync(naqz, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region BuildingOption
                var allbo = await BuildingOptionsBussines.GetAllAsync(new CancellationToken());

                if (allbo == null || allbo.Count <= 0)
                {
                    var bo = DefaultBuildingOptions.SetDef();
                    res.AddReturnedValue(await BuildingOptionsBussines.SaveRangeAsync(bo, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region BuildingAccountType
                var allbat = await BuildingAccountTypeBussines.GetAllAsync(new CancellationToken());

                if (allbat == null || allbat.Count <= 0)
                {
                    var bat = DefaultBuildingAccountType.SetDef();
                    res.AddReturnedValue(await BuildingAccountTypeBussines.SaveRangeAsync(bat, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region FloorCover
                var allfc = await FloorCoverBussines.GetAllAsync(new CancellationToken());

                if (allfc == null || allfc.Count <= 0)
                {
                    var fc = DefaultFloorCover.SetDef();
                    res.AddReturnedValue(await FloorCoverBussines.SaveRangeAsync(fc, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region KitchenService
                var allks = await KitchenServiceBussines.GetAllAsync(new CancellationToken());

                if (allks == null || allks.Count <= 0)
                {
                    var ks = DefaultKitchenService.SetDef();
                    res.AddReturnedValue(await KitchenServiceBussines.SaveRangeAsync(ks, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region DocumentType
                var alldt = await DocumentTypeBussines.GetAllAsync(new CancellationToken());

                if (alldt == null || alldt.Count <= 0)
                {
                    var dt = DefaultDocumentType.SetDef();
                    res.AddReturnedValue(await DocumentTypeBussines.SaveRangeAsync(dt, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region RentalAuthority
                var allra = await RentalAuthorityBussines.GetAllAsync(new CancellationToken());

                if (allra == null || allra.Count <= 0)
                {
                    var ra = DefaultRentalAuthority.SetDef();
                    res.AddReturnedValue(await RentalAuthorityBussines.SaveRangeAsync(ra, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region BuildingView
                var allbv = await BuildingViewBussines.GetAllAsync(new CancellationToken());

                if (allbv == null || allbv.Count <= 0)
                {
                    var bv = DefaultBuildingView.SetDef();
                    res.AddReturnedValue(await BuildingViewBussines.SaveRangeAsync(bv, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region BuildingCondition
                var allbc = await BuildingConditionBussines.GetAllAsync(new CancellationToken());

                if (allbc == null || allbc.Count <= 0)
                {
                    var bc = DefaultBuildingCondition.SetDef();
                    res.AddReturnedValue(await BuildingConditionBussines.SaveRangeAsync(bc, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region BuildingType
                var allbt = await BuildingTypeBussines.GetAllAsync(new CancellationToken());

                if (allbt == null || allbt.Count <= 0)
                {
                    var bo = DefaultBuildingType.SetDef();
                    res.AddReturnedValue(await BuildingTypeBussines.SaveRangeAsync(bo, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region PeopleGroup
                var allpg = await PeopleGroupBussines.GetAllAsync();

                if (allpg == null || allpg.Count <= 0)
                {
                    var reg = DefaultPeopleGroup.SetDef();
                    res.AddReturnedValue(await PeopleGroupBussines.SaveRangeAsync(reg, tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion

                #region Setting
                var allSetting = await SettingsBussines.GetAllAsync();

                if (allSetting == null || allSetting.Count <= 0)
                {
                    res.AddReturnedValue(SettingsBussines.Save("ArzeshAfzoude", "9", tr));
                    res.AddReturnedValue(SettingsBussines.Save("Tabdil", "2", tr));
                    if (res.HasError)
                    {
                        return;
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                res.AddReturnedValue(tr.TransactionDestiny(res.HasError));
                res.AddReturnedValue(cn.CloseConnection());
            }
        }
예제 #5
0
        private async Task ResendDataToHost()
        {
            try
            {
                if (chbState.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebStates.SaveAsync(await StatesBussines.GetAllAsync(_token.Token));
                }
                if (chbCity.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebCity.SaveAsync(await CitiesBussines.GetAllAsync(_token.Token));
                }
                if (chbRegion.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebRegion.SaveAsync(await RegionsBussines.GetAllAsync(_token.Token));
                }
                if (chbUsers.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebUser.SaveAsync(await UserBussines.GetAllAsync(_token.Token));
                }
                if (chbPeopleGroup.Checked)
                {
                    await WebPeopleGroup.SaveAsync(await PeopleGroupBussines.GetAllAsync());
                }
                if (chbPeople.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebPeople.SaveAsync(await PeoplesBussines.GetAllAsync(_token.Token));
                }
                if (chbAccountType.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebBuildingAccountType.SaveAsync(await BuildingAccountTypeBussines.GetAllAsync(_token.Token));
                }
                if (chbCondition.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebBuildingCondition.SaveAsync(await BuildingConditionBussines.GetAllAsync(_token.Token));
                }
                if (chbType.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebBuildingType.SaveAsync(await BuildingTypeBussines.GetAllAsync(_token.Token));
                }
                if (chbView.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebBuildingView.SaveAsync(await BuildingViewBussines.GetAllAsync(_token.Token));
                }
                if (chbDocType.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebDocumentType.SaveAsync(await DocumentTypeBussines.GetAllAsync(_token.Token));
                }

                if (chbFloor.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebFloorCover.SaveAsync(await FloorCoverBussines.GetAllAsync(_token.Token));
                }

                if (chbKitchen.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebKitchenService.SaveAsync(await KitchenServiceBussines.GetAllAsync(_token.Token));
                }

                if (chbRental.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebRental.SaveAsync(await RentalAuthorityBussines.GetAllAsync(_token.Token));
                }

                if (chbOptions.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebBuildingOptions.SaveAsync(await BuildingOptionsBussines.GetAllAsync(_token.Token));
                }

                if (chbBuilding.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebBuilding.SaveAsync(await BuildingBussines.GetAllAsync(_token.Token), Application.StartupPath);
                }


                if (chbRequest.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebBuildingRequest.SaveAsync(await BuildingRequestBussines.GetAllAsync(_token.Token));
                }

                if (chbContract.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebContract.SaveAsync(await ContractBussines.GetAllAsync(_token.Token));
                }
                if (chbReception.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebReception.SaveAsync(await ReceptionBussines.GetAllAsync(_token.Token));
                }

                if (chbPardakht.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebPardakht.SaveAsync(await PardakhtBussines.GetAllAsync(_token.Token));
                }

                if (chbAdvisor.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebAdvisor.SaveAsync(await AdvisorBussines.GetAllAsync(_token.Token));
                }

                if (chbBank.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebBank.SaveAsync(await BankBussines.GetAllAsync(_token.Token));
                }

                if (chbKol.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebKol.SaveAsync(await KolBussines.GetAllAsync(_token.Token));
                }

                if (chbMoein.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebMoein.SaveAsync(await MoeinBussines.GetAllAsync(_token.Token));
                }

                if (chbTafsil.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebTafsil.SaveAsync(await TafsilBussines.GetAllAsync(_token.Token));
                }

                if (chbSanad.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    await WebSanad.SaveAsync(await SanadBussines.GetAllAsync(_token.Token));
                }


                Invoke(new MethodInvoker(() => MessageBox.Show("انتقال داده ها به سرور با موفقیت انجام شد")));
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
            finally
            {
                Invoke(new MethodInvoker(() =>
                {
                    btnSend.Enabled = true;
                    Cursor          = Cursors.Default;
                }));
            }
        }