Пример #1
0
 public frmMoein(Guid moeinGuid, bool Is_Show)
 {
     InitializeComponent();
     moein = MoeinBussines.Get(moeinGuid);
     grpAccount.Enabled = Is_Show;
     btnFinish.Enabled  = Is_Show;
 }
Пример #2
0
        private void FrmMoein_Load(object sender, EventArgs e)
        {
            try
            {
                Set_Data();
                var moeins = MoeinBussines.GetAll().ToList();
                AutoCompleteStringCollection _source = new AutoCompleteStringCollection();

                foreach (var item in moeins)
                {
                    _source.Add(item.Name);
                }

                txtName.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
                txtName.AutoCompleteSource       = AutoCompleteSource.CustomSource;
                txtName.AutoCompleteCustomSource = _source;
                ToolTip tt = new ToolTip();
                tt.SetToolTip(btnSearchKol, "انتخاب حساب کل");
            }
            catch (Exception exception)
            {
                frmMessage f = new frmMessage(EnumMessageFlag.ShowFlag, Color.Red, exception.Message);
                f.ShowDialog();
            }
        }
Пример #3
0
 private SanadDetailBussines GenerateDet()
 {
     try
     {
         var tafsil = TafsilBussines.Get(_tafsilGuid);
         var moein  = MoeinBussines.Get(_moeinGuid);
         var res    = new SanadDetailBussines
         {
             Guid        = Guid.NewGuid(),
             Modified    = DateTime.Now,
             Description = txtRowDesc.Text,
             Debit       = txtDebit.TextDecimal,
             Credit      = txtCredit.TextDecimal,
             TafsilGuid  = (tafsil?.Guid ?? Guid.Empty),
             MoeinGuid   = (moein?.Guid ?? Guid.Empty),
             MoeinCode   = moein?.Code,
             MoeinName   = moein?.Name,
             TafsilCode  = tafsil?.Code,
             TafsilName  = tafsil?.Name
         };
         return(res);
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
         return(null);
     }
 }
 private void MnuDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (DGrid.RowCount == 0)
         {
             return;
         }
         Guid       moeinGuid = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
         var        moein     = MoeinBussines.Get(moeinGuid);
         string     message   = "آیا از حذف حساب " + moein.Name + " " + "اطمینان دارید؟";
         frmMessage frm       = new frmMessage(EnumMessageFlag.DeleteFlag, Color.PapayaWhip, message);
         if (frm.ShowDialog() == DialogResult.OK)
         {
             moein = MoeinBussines.Change_Status(moeinGuid, false);
             if (moein.Save())
             {
                 frmMessage f = new frmMessage(EnumMessageFlag.ShowFlag, Color.Green, "عملیات با موفقیت انجام شد");
                 f.ShowDialog();
                 LoadData();
             }
         }
     }
     catch (Exception exception)
     {
         frmMessage frm = new frmMessage(EnumMessageFlag.ShowFlag, Color.Red, exception.Message);
         frm.ShowDialog();
     }
 }
Пример #5
0
 private void Set_Data()
 {
     LoadMahiat();
     lblCode.Text        = AccountGroupBussines.Get((int)HesabType.Sandouq).Aouth_Code;
     txtDescription.Text = safe.Description;
     txtName.Text        = safe.Name;
     txtCode.Text        = safe.HalfCode;
     _moein            = MoeinBussines.Get(safe.MoeinAmountAvalDore);
     txtMoeinName.Text = _moein?.Name ?? "";
     txtMoeinCode.Text = _moein?.Code ?? "";
     txtAmount.Text    = (Math.Abs(safe.AmountAvalDore)).ToString();
     if (safe.AmountAvalDore < 0)
     {
         cmbAmountMahiat.SelectedIndex = 1;
     }
     if (safe.AmountAvalDore == 0)
     {
         cmbAmountMahiat.SelectedIndex = 0;
     }
     if (safe.AmountAvalDore > 0)
     {
         cmbAmountMahiat.SelectedIndex = 2;
     }
     if (safe.Guid == Guid.Empty)
     {
         NewCode();
     }
 }
        public async Task <ReturnedSaveFuncInfo> SaveAsync(MoeinBussines item, SqlTransaction tr)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var cmd = new SqlCommand("sp_Moein_Save", tr.Connection, tr)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.AddWithValue("@guid", item.Guid);
                cmd.Parameters.AddWithValue("@modif", item.Modified);
                cmd.Parameters.AddWithValue("@name", item.Name ?? "");
                cmd.Parameters.AddWithValue("@code", item.Code ?? "");
                cmd.Parameters.AddWithValue("@account", item.Account);
                cmd.Parameters.AddWithValue("@kolGuid", item.KolGuid);
                cmd.Parameters.AddWithValue("@serverSt", (short)item.ServerStatus);
                cmd.Parameters.AddWithValue("@serverDate", item.ServerDeliveryDate);

                await cmd.ExecuteNonQueryAsync();
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
        public async Task <MoeinBussines> GetAsync(string _connectionString, string code)
        {
            MoeinBussines res = null;

            try
            {
                using (var cn = new SqlConnection(_connectionString))
                {
                    var cmd = new SqlCommand("sp_Moein_GetByCode", cn)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    cmd.Parameters.AddWithValue("@code", code);

                    await cn.OpenAsync();

                    var dr = await cmd.ExecuteReaderAsync();

                    if (dr.Read())
                    {
                        res = LoadData(dr);
                    }
                    cn.Close();
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

            return(res);
        }
Пример #8
0
 private void Set_Data()
 {
     LoadType();
     LoadMahiat();
     lblCode.Text        = AccountGroupBussines.Get((int)HesabType.Bank).Aouth_Code;
     txtDescription.Text = bank.Description;
     txtName.Text        = bank.Name;
     chbPoss.Checked     = bank.Poss;
     txtCode.Text        = bank.HalfCode;
     txtDateEftetah.Value.FarsiSelectedDate = bank.DateEftetah;
     cmbType.SelectedIndex = (int)bank.Type;
     txtCodeShobe.Text     = bank.ShobeCode;
     txtNameShobe.Text     = bank.ShobeName;
     txtSahebHesab.Text    = bank.DarandeName;
     _moein            = MoeinBussines.Get(bank.MoeinAmountAvalDore);
     txtMoeinName.Text = _moein?.Name ?? "";
     txtMoeinCode.Text = _moein?.Code ?? "";
     txtAmount.Text    = (Math.Abs(bank.AmountAvalDore)).ToString();
     if (bank.AmountAvalDore < 0)
     {
         cmbAmountMahiat.SelectedIndex = 1;
     }
     if (bank.AmountAvalDore == 0)
     {
         cmbAmountMahiat.SelectedIndex = 0;
     }
     if (bank.AmountAvalDore > 0)
     {
         cmbAmountMahiat.SelectedIndex = 2;
     }
     if (bank.Guid == Guid.Empty)
     {
         NewCode();
     }
 }
Пример #9
0
        public static async Task <ReturnedSaveFuncInfo> SaveAsync(MoeinBussines cls)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var obj = new WebMoein()
                {
                    Guid               = cls.Guid,
                    Name               = cls.Name,
                    Modified           = cls.Modified,
                    HardSerial         = cls.HardSerial,
                    ServerStatus       = cls.ServerStatus,
                    ServerDeliveryDate = cls.ServerDeliveryDate,
                    Code               = cls.Code,
                    Account            = cls.Account,
                    DateM              = cls.DateM,
                    KolGuid            = cls.KolGuid
                };
                await obj.SaveAsync();
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
        public void FillData(CustomersBussines _cus)
        {
            try
            {
                cmbType.Items.Clear();
                cmbType.Items.Add(SellerType.A_Haqiqi.GetDisplay());
                cmbType.Items.Add(SellerType.A_Hoqouqi.GetDisplay());
                cmbType.SelectedIndex = 0;
                lblCode.Text          = AccountGroupBussines.Get((int)HesabType.A_Haqiqi).Aouth_Code;
                LoadGroups();
                LoadMahiat();
                txtCode.Text   = _cus.Half_Code;
                txtName.Text   = _cus.Name;
                txtAmount.Text = (Math.Abs(_cus.Amount_AvalDore)).ToString();
                txtDateBirth.Value.FarsiSelectedDate = _cus.DateBirth;
                txtDescription.Text = _cus.Description;
                moein                 = MoeinBussines.Get(_cus.MoeinAmountAvalDore);
                txtMoeinName.Text     = moein?.Name ?? "";
                txtMoeinCode.Text     = moein?.Code ?? "";
                cmbType.SelectedIndex = _cus.Type == SellerType.A_Haqiqi ? 0 : 1;
                if (_cus.GroupGuid != Guid.Empty)
                {
                    cmbGroup.SelectedValue = _cus.GroupGuid;
                }
                else
                {
                    if (cusGroupBindingSource.Count > 0)
                    {
                        cmbGroup.SelectedIndex = 0;
                    }
                }

                if (_cus.Guid == Guid.Empty)
                {
                    NewCode();
                }

                if (_cus.Amount_AvalDore < 0)
                {
                    cmbAmountMahiat.SelectedIndex = 1;
                }
                if (_cus.Amount_AvalDore == 0)
                {
                    cmbAmountMahiat.SelectedIndex = 0;
                }
                if (_cus.Amount_AvalDore > 0)
                {
                    cmbAmountMahiat.SelectedIndex = 2;
                }
            }
            catch (Exception ex)
            {
                frmMessage f = new frmMessage(EnumMessageFlag.ShowFlag, Color.Red, ex.Message);
                f.ShowDialog();
            }
        }
Пример #11
0
 private void NewCode(Guid kolGuid)
 {
     try
     {
         txtCode.Text = MoeinBussines.NewCode(kolGuid);
     }
     catch (Exception exception)
     {
         txtCode.Text = "001";
     }
 }
Пример #12
0
 private void txtMoeinCode_TextChanged(object sender, EventArgs e)
 {
     try
     {
         var a = MoeinBussines.GetByCode(txtMoeinCode.Text.Trim());
         txtMoeinName.Text = a?.Name ?? "";
         _moein            = a;
     }
     catch
     {
         txtMoeinName.Text = "";
         _moein.Guid       = Guid.Empty;
     }
 }
Пример #13
0
 private void BtnSearchMoein_Click(object sender, EventArgs e)
 {
     try
     {
         frmShow_MoeinHesab f = new frmShow_MoeinHesab(true);
         if (f.ShowDialog() == DialogResult.OK)
         {
             moein             = MoeinBussines.Get(f.SelectedGuid);
             txtMoeinCode.Text = moein?.Code ?? "";
             txtMoeinName.Text = moein?.Name ?? "";
         }
     }
     catch (Exception exception)
     {
         frmMessage frm = new frmMessage(EnumMessageFlag.ShowFlag, Color.Red, exception.Message);
         frm.ShowDialog();
     }
 }
        public void FillData(SellerBussines _seller)
        {
            try
            {
                cmbType.Items.Clear();
                cmbType.Items.Add(SellerType.A_Haqiqi.GetDisplay());
                cmbType.Items.Add(SellerType.A_Hoqouqi.GetDisplay());
                cmbType.SelectedIndex = 0;
                LoadMahiat();
                txtCode.Text        = _seller.Half_Code;
                txtName.Text        = _seller.Name;
                txtDescription.Text = _seller.Description;
                txtResName.Text     = _seller.RespName;
                txtEcoCode.Text     = _seller.EconomyCode;
                txtAmount.Text      = (Math.Abs(_seller.Amount_AvalDore)).ToString();
                moein             = MoeinBussines.Get(_seller.MoeinAmountAvalDore);
                txtMoeinName.Text = moein?.Name ?? "";
                txtMoeinCode.Text = moein?.Code ?? "";
                if (_seller.Guid == Guid.Empty)
                {
                    NewCode();
                }

                if (_seller.Amount_AvalDore < 0)
                {
                    cmbAmountMahiat.SelectedIndex = 1;
                }
                if (_seller.Amount_AvalDore == 0)
                {
                    cmbAmountMahiat.SelectedIndex = 0;
                }
                if (_seller.Amount_AvalDore > 0)
                {
                    cmbAmountMahiat.SelectedIndex = 2;
                }
            }
            catch (Exception ex)
            {
                var f = new frmMessage(EnumMessageFlag.ShowFlag, Color.Red, ex.Message);
                f.ShowDialog();
            }
        }
Пример #15
0
 private static MoeinBussines SetDef(string name, string code, Guid guid, Guid kolGuid)
 {
     try
     {
         var state = new MoeinBussines()
         {
             Name    = name,
             Account = 0,
             Guid    = guid,
             Code    = code,
             KolGuid = kolGuid
         };
         return(state);
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
         return(null);
     }
 }
Пример #16
0
 private void SetMoein()
 {
     try
     {
         var frm = new frmKolMoein(true);
         if (frm.ShowDialog(this) == DialogResult.OK)
         {
             var moein = MoeinBussines.Get(frm.SelectedMoeinGuid);
             if (moein != null)
             {
                 txtMoeinName.Text = moein.Name;
                 _moeinGuid        = moein.Guid;
             }
         }
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
     }
 }
        private void LoadData(string search = null)
        {
            try
            {
                if (search == null)
                {
                    var lst = MoeinBussines.GetAll().Where(q => q.Status).OrderBy(q => q.Code).ToList();
                    MoeinBindingSource.DataSource = lst.ToList();
                }
                else
                {
                    var list = MoeinBussines.Search(search).Where(q => q.Status).ToList();
                    MoeinBindingSource.DataSource = list;
                }

                lblCounter.Text = MoeinBindingSource.Count.ToString();
            }
            catch (Exception exception)
            {
                frmMessage frm = new frmMessage(EnumMessageFlag.ShowFlag, Color.Red, exception.Message);
                frm.ShowDialog();
            }
        }
        private static MoeinBussines LoadData(SqlDataReader dr)
        {
            var item = new MoeinBussines();

            try
            {
                item.Guid               = (Guid)dr["Guid"];
                item.Modified           = (DateTime)dr["Modified"];
                item.Name               = dr["Name"].ToString();
                item.Code               = dr["Code"].ToString();
                item.Account            = (decimal)dr["Account"];
                item.KolGuid            = (Guid)dr["KolGuid"];
                item.DateM              = (DateTime)dr["DateM"];
                item.ServerDeliveryDate = (DateTime)dr["ServerDeliveryDate"];
                item.ServerStatus       = (ServerStatus)dr["ServerStatus"];
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

            return(item);
        }
Пример #19
0
        private void BtnFinish_Click(object sender, EventArgs e)
        {
            try
            {
                btnFinish.Enabled = false;
                if (moein.Guid == Guid.Empty)
                {
                    moein.Guid     = Guid.NewGuid();
                    moein.DateSabt = DateConvertor.M2SH(DateTime.Now);
                }

                if (kol.Guid == Guid.Empty)
                {
                    frmMessage f = new frmMessage(EnumMessageFlag.ShowFlag, Color.Red, "حساب کل را انتخاب نمایید");
                    f.ShowDialog();
                    txtKolCode.Focus();
                    return;
                }

                if (string.IsNullOrWhiteSpace(txtCode.Text))
                {
                    frmMessage f = new frmMessage(EnumMessageFlag.ShowFlag, Color.Red, "کد حساب را وارد نمایید");
                    f.ShowDialog();
                    txtCode.Focus();
                    return;
                }

                if (txtCode.Text.Length > 3 || txtCode.Text.Length < 3)
                {
                    frmMessage f = new frmMessage(EnumMessageFlag.ShowFlag, Color.Red, "حتما باید سه کاراکتر به عنوان کد حساب معین وارد نمایید");
                    f.ShowDialog();
                    txtCode.Focus();
                    return;
                }

                if (!MoeinBussines.Check_Code(txtKolCode.Text + txtCode.Text.Trim(), moein.Guid))
                {
                    frmMessage f = new frmMessage(EnumMessageFlag.ShowFlag, Color.Red, "کد حساب وارد شده تکراری است");
                    f.ShowDialog();
                    txtCode.Focus();
                    return;
                }

                if (cmbMahiat.SelectedIndex == -1)
                {
                    frmMessage f = new frmMessage(EnumMessageFlag.ShowFlag, Color.Red, "ماهیت حساب را وارد نمایید");
                    f.ShowDialog();
                    cmbMahiat.Focus();
                    return;
                }
                if (string.IsNullOrWhiteSpace(txtName.Text))
                {
                    frmMessage f = new frmMessage(EnumMessageFlag.ShowFlag, Color.Red, "عنوان حساب را وارد نمایید");
                    f.ShowDialog();
                    txtName.Focus();
                    return;
                }

                if (!MoeinBussines.Check_Name(txtName.Text.Trim(), moein.Guid))
                {
                    frmMessage f = new frmMessage(EnumMessageFlag.ShowFlag, Color.Red, "عنوان حساب وارد شده تکراری است");
                    f.ShowDialog();
                    txtName.Focus();
                    return;
                }

                moein.Mahiat      = (EnumMahiat)cmbMahiat.SelectedIndex;
                moein.Half_Code   = txtCode.Text;
                moein.Code        = txtKolCode.Text + txtCode.Text;
                moein.Description = txtDescription.Text;
                moein.Name        = txtName.Text;
                moein.Status      = true;
                moein.System      = false;
                moein.KolGuid     = kol.Guid;

                if (moein.Save())
                {
                    frmMessage f = new frmMessage(EnumMessageFlag.ShowFlag, Color.Green, "عملیات با موفقیت انجام شد");
                    f.ShowDialog();
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
            }
            catch (Exception exception)
            {
                frmMessage f = new frmMessage(EnumMessageFlag.ShowFlag, Color.Red, exception.Message);
                f.ShowDialog();
            }


            finally{ btnFinish.Enabled = true; }
        }
Пример #20
0
        public void FillData(PerssonelBussines _perssonel)
        {
            try
            {
                lblCode.Text = AccountGroupBussines.Get((int)HesabType.A_Haqiqi).Aouth_Code;
                LoadGroups();
                LoadMahiat();
                txtCode.Text   = _perssonel.Half_Code;
                txtName.Text   = _perssonel.Name;
                txtAmount.Text = (Math.Abs(_perssonel.Amount_AvalDore)).ToString();
                txtDateBirth.Value.FarsiSelectedDate = _perssonel.DateBirth;
                txtDescription.Text   = _perssonel.Description;
                txtNatCode.Text       = _perssonel.NationalCode;
                txtPerssonelCode.Text = _perssonel.PerssonelCode;
                txtPlaceBirth.Text    = _perssonel.PlaceBirth;
                moein             = MoeinBussines.Get(_perssonel.MoeinAmountAvalDore);
                txtMoeinName.Text = moein?.Name ?? "";
                txtMoeinCode.Text = moein?.Code ?? "";
                if (_perssonel.PerssonelGroup != Guid.Empty)
                {
                    cmbGroup.SelectedValue = _perssonel.PerssonelGroup;
                }
                else
                {
                    if (PerssonelGroupBindingSource.Count > 0)
                    {
                        cmbGroup.SelectedIndex = 0;
                    }
                }

                var gender = _perssonel.Gender;
                if (gender == EnumGender.Male)
                {
                    rbtnMale.Checked = true;
                }
                if (gender == EnumGender.Female)
                {
                    rbtnFemale.Checked = true;
                }
                if (_perssonel.Guid == Guid.Empty)
                {
                    NewCode();
                    SetPerssonelCode();
                }

                if (_perssonel.Amount_AvalDore < 0)
                {
                    cmbAmountMahiat.SelectedIndex = 1;
                }
                if (_perssonel.Amount_AvalDore == 0)
                {
                    cmbAmountMahiat.SelectedIndex = 0;
                }
                if (_perssonel.Amount_AvalDore > 0)
                {
                    cmbAmountMahiat.SelectedIndex = 2;
                }
            }
            catch (Exception ex)
            {
                frmMessage f = new frmMessage(EnumMessageFlag.ShowFlag, Color.Red, ex.Message);
                f.ShowDialog();
            }
        }
Пример #21
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());
            }
        }
Пример #22
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);
            }
        }
Пример #23
0
 public frmMoein()
 {
     InitializeComponent();
     moein = new MoeinBussines();
 }
Пример #24
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;
                }));
            }
        }