Пример #1
0
        public static async Task <ReturnedSaveFuncInfo> BargashtAsync(ReceptionCheckBussines cls)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                cls.CheckStatus = EnCheckM.Bargashti;
                cls.Modified    = DateTime.Now;
                res.AddReturnedValue(await cls.SaveAsync());

                var reception = await ReceptionBussines.GetAsync(cls.MasterGuid.Value);

                var pardazande = await TafsilBussines.GetAsync(reception.TafsilGuid);

                var sanad = new SanadBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"برگشت زدن چک دریافتنی * شناره: {cls.CheckNumber} بانک صادرکننده: {cls.BankName} * پردازنده: {pardazande.Name}",
                    DateM       = DateTime.Now,
                    Number      = await SanadBussines.NextNumberAsync(),
                    SanadStatus = EnSanadStatus.Temporary,
                    SanadType   = EnSanadType.Auto,
                    UserGuid    = UserBussines.CurrentUser.Guid
                };
                //بستانکار--اسناد
                sanad.AddToListSanad(new SanadDetailBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"برگشت زدن چک {cls.CheckNumber} {cls.BankName} * پردازنده: {pardazande.Name}",
                    Debit       = 0,
                    Credit      = cls.Price,
                    TafsilGuid  = cls.SandouqTafsilGuid,
                    MasterGuid  = sanad.Guid,
                    MoeinGuid   = cls.SandouqMoeinGuid
                });
                //بدهکار--شخص
                sanad.AddToListSanad(new SanadDetailBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"برگشت زدن چک {cls.CheckNumber} {cls.BankName} * پردازنده: {pardazande.Name}",
                    Debit       = cls.Price,
                    Credit      = 0,
                    TafsilGuid  = pardazande.Guid,
                    MasterGuid  = sanad.Guid,
                    MoeinGuid   = ParentDefaults.MoeinCoding.CLSMoein10304
                });

                res.AddReturnedValue(await sanad.SaveAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
Пример #2
0
        private static async Task <ReturnedSaveFuncInfo> NaqdBargashtAsync(PardakhtCheckShakhsiBussines cls, SanadBussines sanad)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var checkPage = await CheckPageBussines.GetAsync(cls.CheckPageGuid);

                var dasteCheck = await DasteCheckBussines.GetAsync(checkPage.CheckGuid);

                var bank = await TafsilBussines.GetAsync(dasteCheck.BankGuid);

                var pardakht = await PardakhtBussines.GetAsync(cls.MasterGuid);

                var girande = await TafsilBussines.GetAsync(pardakht.TafsilGuid);

                //بستانکار--اسناد
                sanad.AddToListSanad(new SanadDetailBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"استرداد چک پرداختنی * شماره: {checkPage.Number} بانک صادرکننده: {bank.Name} * گیرنده: {girande.Name}",
                    Debit       = 0,
                    Credit      = cls.Price,
                    TafsilGuid  = bank.Guid,
                    MasterGuid  = sanad.Guid,
                    MoeinGuid   = ParentDefaults.MoeinCoding.CLSMoein30101
                });
                //بدهکار--شخص
                sanad.AddToListSanad(new SanadDetailBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"استرداد چک پرداختنی * شماره: {checkPage.Number} بانک صادرکننده: {bank.Name} * گیرنده: {girande.Name}",
                    Debit       = cls.Price,
                    Credit      = 0,
                    TafsilGuid  = pardakht.TafsilGuid,
                    MasterGuid  = sanad.Guid,
                    MoeinGuid   = pardakht.MoeinGuid
                });

                res.AddReturnedValue(await sanad.SaveAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
Пример #3
0
        private static async Task <ReturnedSaveFuncInfo> NaqdBargashtAvalDoreAsync(ReceptionCheckAvalDoreBussines cls, SanadBussines sanad)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                cls.CheckStatus = EnCheckM.Bargashti;
                cls.Modified    = DateTime.Now;
                res.AddReturnedValue(await cls.SaveAsync(false));

                var pardazande = await TafsilBussines.GetAsync(cls.TafsilGuid);

                //بستانکار--شخص
                sanad.AddToListSanad(new SanadDetailBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"استرداد چک {cls.CheckNumber} {cls.BankName} * پردازنده: {pardazande.Name}",
                    Debit       = 0,
                    Credit      = cls.Price,
                    TafsilGuid  = pardazande.Guid,
                    MasterGuid  = sanad.Guid,
                    MoeinGuid   = ParentDefaults.MoeinCoding.CLSMoein10304
                });
                //بدهکار--اسناد
                sanad.AddToListSanad(new SanadDetailBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"استرداد چک {cls.CheckNumber} {cls.BankName} * پردازنده: {pardazande.Name}",
                    Debit       = cls.Price,
                    Credit      = 0,
                    TafsilGuid  = cls.SandouqTafsilGuid,
                    MasterGuid  = sanad.Guid,
                    MoeinGuid   = cls.SandouqMoeinGuid
                });

                res.AddReturnedValue(await sanad.SaveAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
Пример #4
0
        private async void mnuViewPardazande_Click(object sender, EventArgs e)
        {
            try
            {
                if (DGrid.RowCount <= 0 || DGrid.CurrentRow == null)
                {
                    return;
                }
                var guid = (Guid)DGrid[DgPardazandeGuid.Index, DGrid.CurrentRow.Index].Value;

                var tafsil = await TafsilBussines.GetAsync(guid);

                if (tafsil == null)
                {
                    return;
                }

                if (tafsil.HesabType == HesabType.Bank)
                {
                    var frm = new frmBankMain(guid, true);
                    frm.ShowDialog(this);
                    return;
                }

                if (tafsil.HesabType == HesabType.Customer)
                {
                    var frm = new frmPeoples(guid, true);
                    frm.ShowDialog(this);
                    return;
                }

                var _frm = new frmTafsilMain(guid, true);
                _frm.ShowDialog(this);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Пример #5
0
        private async void mnuEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (DGrid.RowCount <= 0)
                {
                    return;
                }
                if (DGrid.CurrentRow == null)
                {
                    return;
                }
                if (!_st)
                {
                    frmNotification.PublicInfo.ShowMessage(
                        "شما مجاز به ویرایش داده حذف شده نمی باشید \r\n برای این منظور، ابتدا فیلد موردنظر را از حالت حذف شده به فعال، تغییر وضعیت دهید");
                    return;
                }
                var guid   = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                var tafsil = await TafsilBussines.GetAsync(guid);

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

                var frm = new frmTafsilMain(guid, false, HesabType.Hazine);
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    await LoadDataAsync(txtSearch.Text);
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Пример #6
0
        private async Task SetTafilAsync(Guid guid)
        {
            try
            {
                if (guid == Guid.Empty)
                {
                    return;
                }
                var tf = await TafsilBussines.GetAsync(guid);

                if (tf == null)
                {
                    return;
                }

                _tafsilGuid        = tf.Guid;
                txtTafsilName.Text = tf.Name;
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Пример #7
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);
                }
            }
        }
Пример #8
0
        public static async Task <ReturnedSaveFuncInfo> NaqdAvalDoreAsync(PardakhtCheckAvalDoreBussines cls)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var checkPage = await CheckPageBussines.GetAsync(cls.CheckPageGuid);

                var dasteCheck = await DasteCheckBussines.GetAsync(checkPage.CheckGuid);

                var bank = await TafsilBussines.GetAsync(dasteCheck.BankGuid);

                var girande = await TafsilBussines.GetAsync(cls.TafsilGuid);

                var sanad = new SanadBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"نقد کردن چک پرداختنی * شماره: {checkPage.Number} بانک صادر کننده: {bank.Name} * گیرنده: {girande.Name}",
                    DateM       = DateTime.Now,
                    Number      = await SanadBussines.NextNumberAsync(),
                    SanadStatus = EnSanadStatus.Temporary,
                    SanadType   = EnSanadType.Auto,
                    UserGuid    = UserBussines.CurrentUser.Guid
                };

                if (checkPage.CheckStatus == EnCheckSh.Bargashti)
                {
                    res.AddReturnedValue(await NaqdBargashtAvalDoreAsync(cls, sanad));
                    if (res.HasError)
                    {
                        return(res);
                    }
                }

                //بستانکار--موجودی
                sanad.AddToListSanad(new SanadDetailBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"نقد کردن چک {checkPage.Number} {bank.Name} * گیرنده: {girande.Name}",
                    Debit       = 0,
                    Credit      = cls.Price,
                    TafsilGuid  = bank.Guid,
                    MasterGuid  = sanad.Guid,
                    MoeinGuid   = ParentDefaults.MoeinCoding.CLSMoein10101
                });
                //بدهکار--اسناد
                sanad.AddToListSanad(new SanadDetailBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"نقد کردن چک {checkPage.Number} {bank.Name} * گیرنده: {girande.Name}",
                    Debit       = cls.Price,
                    Credit      = 0,
                    TafsilGuid  = bank.Guid,
                    MasterGuid  = sanad.Guid,
                    MoeinGuid   = ParentDefaults.MoeinCoding.CLSMoein30101
                });

                res.AddReturnedValue(await sanad.SaveAsync());


                checkPage.CheckStatus = EnCheckSh.Pass;
                checkPage.Modified    = DateTime.Now;
                res.AddReturnedValue(await checkPage.SaveAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
Пример #9
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;
                if (_st)
                {
                    var hazine = await TafsilBussines.GetAsync(guid);

                    if (hazine == null)
                    {
                        return;
                    }
                    if (hazine.Account != 0)
                    {
                        res.AddError("به دلیل داشتن گردش حساب، شما مجاز به حذف هزینه نمی باشید");
                        return;
                    }

                    if (MessageBox.Show(this,
                                        $@"آیا از حذف {DGrid[dgName.Index, DGrid.CurrentRow.Index].Value} اطمینان دارید؟", "حذف",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                    var prd = await TafsilBussines.GetAsync(guid);

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

                    res.AddReturnedValue(await prd.ChangeStatusAsync(true));
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    this.ShowError(res, "خطا در تغییر وضعیت صندوق");
                }
                else
                {
                    await LoadDataAsync(txtSearch.Text);
                }
            }
        }
Пример #10
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);
            }
        }
Пример #11
0
        private async Task <PeoplesBussines> GetItemsAsync(int index)
        {
            var pe = new PeoplesBussines();

            try
            {
                if (ColName == 0)
                {
                    return(null);
                }
                var name = GetValue(ColName, index);

                //بدون نام درج نشود
                if (cmbDuplicateName.SelectedIndex == 0)
                {
                    if (string.IsNullOrEmpty(name))
                    {
                        return(null);
                    }
                }


                //نام تکراری درج نشه
                if (cmbDuplicateName.SelectedIndex == 1)
                {
                    if (!string.IsNullOrEmpty(name))
                    {
                        var checkName = await TafsilBussines.CheckNameAsync(name);

                        if (!checkName)
                        {
                            return(null);
                        }
                        pe.Name = name;
                    }
                }



                pe.Guid = Guid.NewGuid();
                if (string.IsNullOrEmpty(pe.Name))
                {
                    pe.Name = GetValue(ColName, index);
                }

                var code = GetValue(ColCode, index);

                //بدون کد درج نشه
                if (cmbDuplicateCode.SelectedIndex == 0)
                {
                    if (string.IsNullOrEmpty(code))
                    {
                        return(null);
                    }
                }

                //کد تکراری درج نشه
                if (cmbDuplicateCode.SelectedIndex == 1)
                {
                    if (!string.IsNullOrEmpty(code))
                    {
                        var tf = await TafsilBussines.GetAsync(pe.Guid);

                        var checkCode = await tf.CheckCodeAsync(pe.Guid, code);

                        if (!checkCode)
                        {
                            return(null);
                        }
                        pe.Code = code;
                    }
                }

                //پیشنهاد کد جدید در صورت خالی بودن یا تکراری بودن
                if (cmbDuplicateCode.SelectedIndex == 2)
                {
                    var newCode = await TafsilBussines.NextCodeAsync(HesabType.Customer);

                    var tf = await TafsilBussines.GetAsync(pe.Guid);

                    if (string.IsNullOrEmpty(code) || !await tf.CheckCodeAsync(pe.Guid, code))
                    {
                        pe.Code = newCode;
                    }
                    else
                    {
                        pe.Code = code;
                    }
                }


                var grp = GetValue(ColGroup, index);
                if (string.IsNullOrEmpty(grp))
                {
                    pe.GroupGuid = (Guid)cmbWithoutGroup.SelectedValue;
                }
                else
                {
                    var group = PeopleGroupBussines.Get(grp);
                    if (group == null)
                    {
                        var g = new PeopleGroupBussines()
                        {
                            Guid       = Guid.NewGuid(),
                            Name       = grp,
                            ParentGuid = Guid.Empty
                        };
                        await g.SaveAsync();

                        pe.GroupGuid = g.Guid;
                    }
                    else
                    {
                        pe.GroupGuid = group.Guid;
                    }
                }

                var acc = (decimal)0;
                var x   = GetValue(ColAccount, index);
                acc = x.RemoveNoNumbers("").ParseToDecimal();
                if (x.Contains("??") | x.Contains("-"))
                {
                    acc = -acc;
                }
                pe.Account      = acc;
                pe.AccountFirst = acc;

                pe.NationalCode = GetValue(ColNationalCode, index);
                pe.IdCode       = GetValue(ColIdCode, index);
                pe.FatherName   = GetValue(ColFatherName, index);
                pe.PlaceBirth   = GetValue(ColPlaceB, index);
                pe.DateBirth    = GetValue(ColDateB, index);
                pe.IssuedFrom   = GetValue(ColIssued, index);
                pe.Address      = GetValue(ColAddress, index);
                pe.PostalCode   = GetValue(ColPostalCode, index);

                pe.TellList = new List <PhoneBookBussines>();
                if (!string.IsNullOrEmpty(GetValue(ColTell1, index)))
                {
                    pe.TellList.Add(new PhoneBookBussines()
                    {
                        Guid       = Guid.NewGuid(),
                        Name       = pe.Name,
                        ParentGuid = pe.Guid,
                        Group      = EnPhoneBookGroup.Peoples,
                        Tell       = GetValue(ColTell1, index)
                    });
                }
                if (!string.IsNullOrEmpty(GetValue(ColTell3, index)))
                {
                    pe.TellList.Add(new PhoneBookBussines()
                    {
                        Guid       = Guid.NewGuid(),
                        Name       = pe.Name,
                        ParentGuid = pe.Guid,
                        Group      = EnPhoneBookGroup.Peoples,
                        Tell       = GetValue(ColTell3, index)
                    });
                }
                if (!string.IsNullOrEmpty(GetValue(ColTell4, index)))
                {
                    pe.TellList.Add(new PhoneBookBussines()
                    {
                        Guid       = Guid.NewGuid(),
                        Name       = pe.Name,
                        ParentGuid = pe.Guid,
                        Group      = EnPhoneBookGroup.Peoples,
                        Tell       = GetValue(ColTell4, index)
                    });
                }
                if (!string.IsNullOrEmpty(GetValue(ColTell2, index)))
                {
                    pe.TellList.Add(new PhoneBookBussines()
                    {
                        Guid       = Guid.NewGuid(),
                        Name       = pe.Name,
                        ParentGuid = pe.Guid,
                        Group      = EnPhoneBookGroup.Peoples,
                        Tell       = GetValue(ColTell2, index)
                    });
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

            return(pe);
        }
Пример #12
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (tafsilBundingSource.Count <= 0)
                {
                    res.AddError("لطفا محل واگذاری جدید را انتخاب نمایید");
                    return;
                }
                if (_oldTafsil.Guid == (Guid)cmbGroup.SelectedValue)
                {
                    res.AddError("محل واگذاری قدیم و جدید نمی توانند یکسان باشند");
                    return;
                }

                _newTafsil = await TafsilBussines.GetAsync((Guid)cmbGroup.SelectedValue);

                if (_newTafsil == null)
                {
                    res.AddError("محل واگذاری جدید چک معتبر نمی باشد");
                    return;
                }

                if (_newHesabType == HesabType.Bank)
                {
                    if (_isAvalDore)
                    {
                        res.AddReturnedValue(await clsCheckM.VagozarBankAvalDore(recAvalDore, _newTafsil));
                    }
                    else
                    {
                        res.AddReturnedValue(await clsCheckM.VagozarBank(rec, _newTafsil));
                    }
                }
                else if (_newHesabType == HesabType.Sandouq)
                {
                    if (_isAvalDore)
                    {
                        res.AddReturnedValue(await clsCheckM.VagozarSandouqAvalDore(recAvalDore, _newTafsil));
                    }
                    else
                    {
                        res.AddReturnedValue(await clsCheckM.VagozarSandouq(rec, _newTafsil));
                    }
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    this.ShowError(res, "خطا در واگذارکردن چک دریافتی");
                }
                else
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }
Пример #13
0
        public static async Task <ReturnedSaveFuncInfo> NaqdAvalDoreAsync(ReceptionCheckAvalDoreBussines cls)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var tafsil = await TafsilBussines.GetAsync(cls.SandouqTafsilGuid);

                var moeinGuid = tafsil.HesabType == HesabType.Bank
                    ? ParentDefaults.MoeinCoding.CLSMoein10101
                    : ParentDefaults.MoeinCoding.CLSMoein10102;



                var pardazande = await TafsilBussines.GetAsync(cls.TafsilGuid);

                var sanad = new SanadBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"نقد کردن چک دریافتنی * شماره: {cls.CheckNumber} بانک صادرکننده: {cls.BankName} * پردازنده: {pardazande.Name}",
                    DateM       = DateTime.Now,
                    Number      = await SanadBussines.NextNumberAsync(),
                    SanadStatus = EnSanadStatus.Temporary,
                    SanadType   = EnSanadType.Auto,
                    UserGuid    = UserBussines.CurrentUser.Guid
                };

                if (cls.CheckStatus == EnCheckM.Bargashti)
                {
                    res.AddReturnedValue(await NaqdBargashtAvalDoreAsync(cls, sanad));
                    if (res.HasError)
                    {
                        return(res);
                    }
                }

                //بستانکار--اسناد
                sanad.AddToListSanad(new SanadDetailBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"نقد کردن چک {cls.CheckNumber} {cls.BankName} * پردازنده: {pardazande.Name}",
                    Debit       = 0,
                    Credit      = cls.Price,
                    TafsilGuid  = cls.SandouqTafsilGuid,
                    MasterGuid  = sanad.Guid,
                    MoeinGuid   = cls.SandouqMoeinGuid
                });
                //بدهکار--موجودی
                sanad.AddToListSanad(new SanadDetailBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"نقد کردن چک {cls.CheckNumber} {cls.BankName} * پردازنده: {pardazande.Name}",
                    Debit       = cls.Price,
                    Credit      = 0,
                    TafsilGuid  = tafsil.Guid,
                    MasterGuid  = sanad.Guid,
                    MoeinGuid   = moeinGuid
                });

                res.AddReturnedValue(await sanad.SaveAsync());


                cls.CheckStatus = EnCheckM.Naqd;
                cls.Modified    = DateTime.Now;
                res.AddReturnedValue(await cls.SaveAsync(false));
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
Пример #14
0
        public static async Task <ReturnedSaveFuncInfo> VagozarBankAvalDore(ReceptionCheckAvalDoreBussines cls, TafsilBussines newBank)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var pardazande = await TafsilBussines.GetAsync(cls.TafsilGuid);

                var sanad = new SanadBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"واگذار کردن چک دریافتنی * شماره: {cls.CheckNumber} بانک صادرکننده: {cls.BankName} * پردازنده: {pardazande.Name}",
                    DateM       = DateTime.Now,
                    Number      = await SanadBussines.NextNumberAsync(),
                    SanadStatus = EnSanadStatus.Temporary,
                    SanadType   = EnSanadType.Auto,
                    UserGuid    = UserBussines.CurrentUser.Guid
                };
                //بستانکار--اسناد قبلی
                sanad.AddToListSanad(new SanadDetailBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"واگذار کردن چک {cls.CheckNumber} {cls.BankName} * پردازنده: {pardazande.Name}",
                    Debit       = 0,
                    Credit      = cls.Price,
                    TafsilGuid  = cls.SandouqTafsilGuid,
                    MasterGuid  = sanad.Guid,
                    MoeinGuid   = cls.SandouqMoeinGuid
                });
                //بدهکار--اسناد جدید
                sanad.AddToListSanad(new SanadDetailBussines()
                {
                    Guid        = Guid.NewGuid(),
                    Modified    = DateTime.Now,
                    Description = $"واگذار کردن چک {cls.CheckNumber} {cls.BankName} * پردازنده: {pardazande.Name}",
                    Debit       = cls.Price,
                    Credit      = 0,
                    TafsilGuid  = newBank.Guid,
                    MasterGuid  = sanad.Guid,
                    MoeinGuid   = ParentDefaults.MoeinCoding.CLSMoein10105
                });

                res.AddReturnedValue(await sanad.SaveAsync());


                cls.CheckStatus       = EnCheckM.Vagozar;
                cls.Modified          = DateTime.Now;
                cls.SandouqTafsilGuid = newBank.Guid;
                cls.SandouqMoeinGuid  = ParentDefaults.MoeinCoding.CLSMoein10105;
                res.AddReturnedValue(await cls.SaveAsync(false));
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }