예제 #1
0
        private static async Task StartSendToServerAsync()
        {
            try
            {
                var list = await TempBussines.GetAllAsync();

                while (true)
                {
                    if (list == null || list.Count <= 0)
                    {
                        await Task.Delay(2000);

                        continue;
                    }
                    foreach (var item in list)
                    {
                        switch (item.Type)
                        {
                        case EnTemp.States:
                            var states = await StatesBussines.GetAsync(item.ObjectGuid);

                            if (states != null)
                            {
                                await WebStates.SaveAsync(states);
                            }
                            break;

                        case EnTemp.Cities:
                            var city = await CitiesBussines.GetAsync(item.ObjectGuid);

                            if (city != null)
                            {
                                await WebCity.SaveAsync(city);
                            }
                            break;

                        case EnTemp.Region:
                            var region = await RegionsBussines.GetAsync(item.ObjectGuid);

                            if (region != null)
                            {
                                await WebRegion.SaveAsync(region);
                            }
                            break;

                        case EnTemp.Users:
                            var user = await UserBussines.GetAsync(item.ObjectGuid);

                            if (user != null)
                            {
                                await WebUser.SaveAsync(user);
                            }
                            break;

                        case EnTemp.PeopleGroups:
                            var pg = await PeopleGroupBussines.GetAsync(item.ObjectGuid);

                            if (pg != null)
                            {
                                await WebPeopleGroup.SaveAsync(pg);
                            }
                            break;

                        case EnTemp.Peoples:
                            var p = await PeoplesBussines.GetAsync(item.ObjectGuid);

                            if (p != null)
                            {
                                await WebPeople.SaveAsync(p);
                            }
                            break;

                        case EnTemp.BuildingAccountType:
                            var acc = await BuildingAccountTypeBussines.GetAsync(item.ObjectGuid);

                            if (acc != null)
                            {
                                await WebBuildingAccountType.SaveAsync(acc);
                            }
                            break;

                        case EnTemp.BuildingCondition:
                            var co = await BuildingConditionBussines.GetAsync(item.ObjectGuid);

                            if (co != null)
                            {
                                await WebBuildingCondition.SaveAsync(co);
                            }
                            break;

                        case EnTemp.BuildingType:
                            var type = await BuildingTypeBussines.GetAsync(item.ObjectGuid);

                            if (type != null)
                            {
                                await WebBuildingType.SaveAsync(type);
                            }
                            break;

                        case EnTemp.BuildingView:
                            var view = await BuildingViewBussines.GetAsync(item.ObjectGuid);

                            if (view != null)
                            {
                                await WebBuildingView.SaveAsync(view);
                            }
                            break;

                        case EnTemp.DocumentType:
                            var doc = await DocumentTypeBussines.GetAsync(item.ObjectGuid);

                            if (doc != null)
                            {
                                await WebDocumentType.SaveAsync(doc);
                            }
                            break;

                        case EnTemp.FloorCover:
                            var fc = await FloorCoverBussines.GetAsync(item.ObjectGuid);

                            if (fc != null)
                            {
                                await WebFloorCover.SaveAsync(fc);
                            }
                            break;

                        case EnTemp.KitchenService:
                            var ks = await KitchenServiceBussines.GetAsync(item.ObjectGuid);

                            if (ks != null)
                            {
                                await WebKitchenService.SaveAsync(ks);
                            }
                            break;

                        case EnTemp.RentalAuthority:
                            var ra = await RentalAuthorityBussines.GetAsync(item.ObjectGuid);

                            if (ra != null)
                            {
                                await WebRental.SaveAsync(ra);
                            }
                            break;

                        case EnTemp.BuildingOptions:
                            var o = await BuildingOptionsBussines.GetAsync(item.ObjectGuid);

                            if (o != null)
                            {
                                await WebBuildingOptions.SaveAsync(o);
                            }
                            break;

                        case EnTemp.Building:
                            var bu = await BuildingBussines.GetAsync(item.ObjectGuid);

                            if (bu != null)
                            {
                                await WebBuilding.SaveAsync(bu, Application.StartupPath);
                            }
                            break;

                        case EnTemp.Contract:
                            var con = await ContractBussines.GetAsync(item.ObjectGuid);

                            if (con != null)
                            {
                                await WebContract.SaveAsync(con);
                            }
                            break;

                        case EnTemp.Requests:
                            var req = await BuildingRequestBussines.GetAsync(item.ObjectGuid);

                            if (req != null)
                            {
                                await WebBuildingRequest.SaveAsync(req);
                            }
                            break;

                        case EnTemp.Reception:
                            var rec = await ReceptionBussines.GetAsync(item.ObjectGuid);

                            if (rec != null)
                            {
                                await WebReception.SaveAsync(rec);
                            }
                            break;

                        case EnTemp.Pardakht:
                            var pa = await PardakhtBussines.GetAsync(item.ObjectGuid);

                            if (pa != null)
                            {
                                await WebPardakht.SaveAsync(pa);
                            }
                            break;

                        case EnTemp.BuildingRelatedOptions:
                            var re = await BuildingRelatedOptionsBussines.GetAsync(item.ObjectGuid);

                            if (re != null)
                            {
                                await WebBuildingRelatedOptions.SaveAsync(re);
                            }
                            break;

                        case EnTemp.RequestRegions:
                            var rr = await BuildingRequestRegionBussines.GetAsync(item.ObjectGuid);

                            if (rr != null)
                            {
                                await WebBuildingRequestRegion.SaveAsync(rr);
                            }
                            break;

                        case EnTemp.PhoneBook:
                            var ph = await PhoneBookBussines.GetAsync(item.ObjectGuid);

                            if (ph != null)
                            {
                                await WebPhoneBook.SaveAsync(ph);
                            }
                            break;

                        case EnTemp.Advisor:
                            var ad = await AdvisorBussines.GetAsync(item.ObjectGuid);

                            if (ad != null)
                            {
                                await WebAdvisor.SaveAsync(ad);
                            }
                            break;

                        case EnTemp.Bank:
                            var ba = await BankBussines.GetAsync(item.ObjectGuid);

                            if (ba != null)
                            {
                                await WebBank.SaveAsync(ba);
                            }
                            break;

                        case EnTemp.Kol:
                            var kol = await KolBussines.GetAsync(item.ObjectGuid);

                            if (kol != null)
                            {
                                await WebKol.SaveAsync(kol);
                            }
                            break;

                        case EnTemp.Moein:
                            var moein = await MoeinBussines.GetAsync(item.ObjectGuid);

                            if (moein != null)
                            {
                                await WebMoein.SaveAsync(moein);
                            }
                            break;

                        case EnTemp.Tafsil:
                            var tafsil = await TafsilBussines.GetAsync(item.ObjectGuid);

                            if (tafsil != null)
                            {
                                await WebTafsil.SaveAsync(tafsil);
                            }
                            break;

                        case EnTemp.Sanad:
                            var sa = await SanadBussines.GetAsync(item.ObjectGuid);

                            if (sa != null)
                            {
                                await WebSanad.SaveAsync(sa);
                            }
                            break;

                        case EnTemp.SanadDetail:
                            var saD = await SanadDetailBussines.GetAsync(item.ObjectGuid);

                            if (saD != null)
                            {
                                await WebSanadDetail.SaveAsync(saD);
                            }
                            break;
                        }

                        await item.RemoveAsync();
                    }

                    await Task.Delay(2000);

                    list = await TempBussines.GetAllAsync();
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
예제 #2
0
        private async void mnuDelete_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (DGrid.RowCount <= 0)
                {
                    return;
                }
                if (DGrid.CurrentRow == null)
                {
                    return;
                }
                var guid   = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                var tafsil = await TafsilBussines.GetAsync(guid);

                if (tafsil == null)
                {
                    res.AddError("حساب انتخاب شده معتبر نمی باشد");
                    return;
                }

                if (_st)
                {
                    if (tafsil.isSystem)
                    {
                        res.AddError("شما مجاز به حذف حساب های پیش فرض نمی باشید");
                        return;
                    }
                    if (tafsil.Account != 0)
                    {
                        res.AddError(
                            $"حساب {DGrid[dgName.Index, DGrid.CurrentRow.Index].Value} به علت داشتن گردش، قادر به حذف نمی باشد");
                        return;
                    }
                    if (MessageBox.Show(this,
                                        $@"آیا از حذف {DGrid[dgName.Index, DGrid.CurrentRow.Index].Value} اطمینان دارید؟", "حذف",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                    if (tafsil.HesabType == HesabType.Customer)
                    {
                        var cus = await PeoplesBussines.GetAsync(tafsil.Guid);

                        if (cus == null)
                        {
                            return;
                        }
                        res.AddReturnedValue(await cus.ChangeStatusAsync(false));
                        return;
                    }
                    if (tafsil.HesabType == HesabType.Bank)
                    {
                        var bank = await BankBussines.GetAsync(tafsil.Guid);

                        res.AddReturnedValue(await bank.ChangeStatusAsync(false));
                        return;
                    }

                    res.AddReturnedValue(await tafsil.ChangeStatusAsync(false));
                }
                else
                {
                    if (MessageBox.Show(this,
                                        $@"آیا از فعال کردن {DGrid[dgName.Index, DGrid.CurrentRow.Index].Value} اطمینان دارید؟",
                                        "حذف",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                    if (tafsil.HesabType == HesabType.Customer)
                    {
                        var cus = await PeoplesBussines.GetAsync(tafsil.Guid);

                        if (cus.GroupGuid == Guid.Empty)
                        {
                            var frm = new frmChangeGroup(cus);
                            if (frm.ShowDialog(this) != DialogResult.OK)
                            {
                                return;
                            }
                        }
                        res.AddReturnedValue(await cus.ChangeStatusAsync(true));
                        return;
                    }
                    if (tafsil.HesabType == HesabType.Bank)
                    {
                        var bank = await BankBussines.GetAsync(tafsil.Guid);

                        res.AddReturnedValue(await bank.ChangeStatusAsync(true));
                        return;
                    }

                    res.AddReturnedValue(await tafsil.ChangeStatusAsync(true));
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    this.ShowError(res, "خطا در تغییر وضعیت حساب تفصیلی");
                }
                else
                {
                    await LoadDataAsync(txtSearch.Text);
                }
            }
        }
예제 #3
0
        private async void mnuShowStandard_Click(object sender, EventArgs e)
        {
            try
            {
                if (DGrid.RowCount <= 0)
                {
                    return;
                }
                if (DGrid.CurrentRow == null)
                {
                    return;
                }
                var guid     = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                var contract = await ContractBussines.GetAsync(guid);

                if (contract == null)
                {
                    return;
                }
                var building = await BuildingBussines.GetAsync(contract.BuildingGuid);

                var buildingAccountType = await BuildingAccountTypeBussines.GetAsync(building.BuildingAccountTypeGuid);

                var fSide = await PeoplesBussines.GetAsync(contract.FirstSideGuid);

                var sSide = await PeoplesBussines.GetAsync(contract.SecondSideGuid);

                var unitCity = await CitiesBussines.GetAsync(Guid.Parse(Settings.Classes.clsEconomyUnit.EconomyCity));

                if (contract.Type == EnRequestType.Rahn)
                {
                    var view = new RahnViewModel
                    {
                        fName               = fSide?.Name,
                        fFatherName         = fSide?.FatherName,
                        fIdCode             = fSide?.IdCode,
                        fIssuedFrom         = fSide?.IssuedFrom,
                        fDateBirth          = fSide?.DateBirth,
                        fNationalCode       = fSide?.NationalCode,
                        fAddress            = fSide?.Address,
                        sName               = sSide?.Name,
                        sFatherName         = sSide?.FatherName,
                        sIdCode             = sSide?.IdCode,
                        sIssuedFrom         = sSide?.IssuedFrom,
                        sDateBirth          = sSide?.DateBirth,
                        sNationalCode       = sSide?.NationalCode,
                        sAddress            = sSide?.Address,
                        ContractDesc        = contract?.Description,
                        DongCount           = 6,
                        BuildingAddress     = building?.Address,
                        Masahat             = building?.Masahat ?? 0,
                        RoomCount           = building?.RoomCount ?? 0,
                        ContractTerm        = contract?.Term ?? 0,
                        ContractfDate       = Calendar.MiladiToShamsi(contract?.FromDate),
                        ContractsDate       = Calendar.MiladiToShamsi((contract?.FromDate ?? DateTime.Now).AddMonths((int)contract?.Term)),
                        UnitAddress         = Settings.Classes.clsEconomyUnit.ManagerAddress,
                        TotalEjare          = (contract?.MinorPrice * contract?.Term) ?? 0,
                        MinorEjare          = contract?.MinorPrice ?? 0,
                        Rahn                = contract?.TotalPrice ?? 0,
                        CheckNo             = contract?.CheckNo,
                        BankName            = contract?.BankName,
                        Shobe               = contract?.Shobe,
                        Sarresid            = contract?.SarResid,
                        UnitName            = Settings.Classes.clsEconomyUnit.EconomyName,
                        DischargeDate       = Calendar.MiladiToShamsi(contract?.DischargeDate),
                        BuildingAccountType = buildingAccountType?.Name,
                        Sarqofli            = contract?.SarQofli ?? 0,
                        Delay               = contract?.Delay ?? 0,
                        UnitCity            = unitCity?.Name,
                        Commition           = contract?.FirstTotalPrice ?? 0,
                        ContractDate        = contract?.DateSh,
                        ContractTime        = contract?.DateM.ToShortTimeString()
                    };
                    var lst = new List <object>()
                    {
                        view
                    };
                    var cls = new ReportGenerator(StiType.Contract_One, EnPrintType.Pdf_A4)
                    {
                        Lst = lst, SanadId = (int)contract?.Code
                    };
                    cls.PrintNew();
                }
                else if (contract.Type == EnRequestType.Forush)
                {
                    var view = new ForoshViewModel()
                    {
                        fName               = fSide?.Name,
                        fFatherName         = fSide?.FatherName,
                        fIdCode             = fSide?.IdCode,
                        fIssuedFrom         = fSide?.IssuedFrom,
                        fDateBirth          = fSide?.DateBirth,
                        fNationalCode       = fSide?.NationalCode,
                        fAddress            = fSide?.Address,
                        sName               = sSide?.Name,
                        sFatherName         = sSide?.FatherName,
                        sIdCode             = sSide?.IdCode,
                        sIssuedFrom         = sSide?.IssuedFrom,
                        sDateBirth          = sSide?.DateBirth,
                        sNationalCode       = sSide?.NationalCode,
                        sAddress            = sSide?.Address,
                        ContractDesc        = contract?.Description,
                        DongCount           = building?.Dang ?? 0,
                        BuildingAddress     = building?.Address,
                        Masahat             = building?.Masahat ?? 0,
                        UnitAddress         = Settings.Classes.clsEconomyUnit.ManagerAddress,
                        TotalPrice          = contract?.TotalPrice ?? 0,
                        MinorPrice          = (contract?.TotalPrice - contract?.MinorPrice) ?? 0,
                        Beyane              = contract?.MinorPrice ?? 0,
                        CheckNo             = contract?.CheckNo,
                        BankName            = contract?.BankName,
                        Shobe               = contract?.Shobe,
                        Sarresid            = contract?.SarResid,
                        UnitName            = Settings.Classes.clsEconomyUnit.EconomyName,
                        DischargeDate       = Calendar.MiladiToShamsi(contract?.DischargeDate),
                        BuildingAccountType = buildingAccountType?.Name,
                        Delay               = contract?.Delay ?? 0,
                        UnitCity            = unitCity?.Name,
                        Commition           = contract?.FirstTotalPrice ?? 0,
                        ContractDate        = contract?.DateSh,
                        ContractTime        = contract?.DateM.ToShortTimeString()
                    };
                    var lst = new List <object>()
                    {
                        view
                    };
                    var cls = new ReportGenerator(StiType.Contract_One, EnPrintType.Pdf_A5)
                    {
                        Lst = lst, SanadId = (int)contract?.Code
                    };
                    cls.PrintNew();
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }