Ejemplo n.º 1
0
        public static async Task <ReturnedSaveFuncInfo> SaveAsync(KitchenServiceBussines cls)
        {
            var res = new ReturnedSaveFuncInfo();

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

            return(res);
        }
        public async Task <ReturnedSaveFuncInfo> SaveAsync(KitchenServiceBussines item, SqlTransaction tr)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var cmd = new SqlCommand("sp_KitchenService_Save", tr.Connection, tr)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.AddWithValue("@guid", item.Guid);
                cmd.Parameters.AddWithValue("@st", item.Status);
                cmd.Parameters.AddWithValue("@name", item.Name ?? "");
                cmd.Parameters.AddWithValue("@modif", item.Modified);
                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 <KitchenServiceBussines> GetAsync(string _connectionString, Guid guid)
        {
            var obj = new KitchenServiceBussines();

            try
            {
                using (var cn = new SqlConnection(_connectionString))
                {
                    var cmd = new SqlCommand("sp_KitchenService_Get", cn)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    cmd.Parameters.AddWithValue("@guid", guid);
                    await cn.OpenAsync();

                    var dr = await cmd.ExecuteReaderAsync();

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

            return(obj);
        }
 public frmKitchenServiceMain()
 {
     InitializeComponent();
     cls                 = new KitchenServiceBussines();
     ucHeader.Text       = "افزودن سرویس آشپزخانه جدید";
     ucHeader.IsModified = cls.IsModified;
 }
 public frmKitchenServiceMain(Guid guid, bool isShowMode)
 {
     InitializeComponent();
     cls                 = KitchenServiceBussines.Get(guid);
     ucHeader.Text       = !isShowMode ? $"ویرایش سرویس آشپزخانه {cls.Name}" : $"مشاهده سرویس آشپزخانه {cls.Name}";
     ucHeader.IsModified = cls.IsModified;
     grp.Enabled         = !isShowMode;
     btnFinish.Enabled   = !isShowMode;
 }
        private async Task LoadDataAsync(string search = "")
        {
            try
            {
                var list = await KitchenServiceBussines.GetAllAsync(search, _token.Token);

                Invoke(new MethodInvoker(() => KitchenBindingSource.DataSource =
                                             list.Where(q => q.Status == _st).OrderBy(q => q.Name).ToSortableBindingList()));
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
 private static KitchenServiceBussines SetDef(string name)
 {
     try
     {
         var reg = new KitchenServiceBussines()
         {
             Name = name,
             Guid = Guid.NewGuid(),
         };
         return(reg);
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
         return(null);
     }
 }
        private KitchenServiceBussines LoadData(SqlDataReader dr)
        {
            var item = new KitchenServiceBussines();

            try
            {
                item.Guid               = (Guid)dr["Guid"];
                item.Modified           = (DateTime)dr["Modified"];
                item.Status             = (bool)dr["Status"];
                item.Name               = dr["Name"].ToString();
                item.ServerDeliveryDate = (DateTime)dr["ServerDeliveryDate"];
                item.ServerStatus       = (ServerStatus)dr["ServerStatus"];
                item.IsModified         = true;
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

            return(item);
        }
        private async void frmKitchenServiceMain_Load(object sender, EventArgs e)
        {
            try
            {
                SetData();
                var myCollection = new AutoCompleteStringCollection();
                _token?.Cancel();
                _token = new CancellationTokenSource();
                var list = await KitchenServiceBussines.GetAllAsync(_token.Token);

                foreach (var item in list.ToList())
                {
                    myCollection.Add(item.Name);
                }
                txtName.AutoCompleteCustomSource = myCollection;
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
        public async Task <ReturnedSaveFuncInfo> ChangeStatusAsync(KitchenServiceBussines item, bool status, SqlTransaction tr)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var cmd = new SqlCommand("sp_KitchenService_ChangeStatus", tr.Connection, tr)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.AddWithValue("@Guid", item.Guid);
                cmd.Parameters.AddWithValue("@st", status);

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

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

                    res.AddReturnedValue(await prd.ChangeStatusAsync(true));
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    var frm = new FrmShowErrorMessage(res, "خطا در تغییر وضعیت سرویس آشپزخانه");
                    frm.ShowDialog(this);
                    frm.Dispose();
                }
                else
                {
                    await LoadDataAsync(txtSearch.Text);
                }
            }
        }
Ejemplo n.º 12
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);
            }
        }
Ejemplo n.º 13
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());
            }
        }
Ejemplo n.º 14
0
        private async Task <ReturnedSaveFuncInfo> SetObjectAsync()
        {
            var res = new ReturnedSaveFuncInfo();

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

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

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

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

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

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

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

            return(res);
        }
Ejemplo n.º 15
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;
                }));
            }
        }