public IEnumerable <BuildingListViewModel> GetLastList(EnRequestType type)
        {
            var list = new List <BuildingListViewModel>();

            try
            {
                var headers = Request.Headers?.ToList();
                if (headers == null || headers.Count <= 0)
                {
                    return(null);
                }
                var guid = Request.Headers.GetValues("cusGuid").FirstOrDefault();
                if (string.IsNullOrEmpty(guid))
                {
                    return(list);
                }
                var cusGuid = Guid.Parse(guid);
                if (!Assistence.CheckCustomer(cusGuid))
                {
                    return(list);
                }
                list = BuildingBussines.GetAllBuildingListViewModel(cusGuid, type);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

            return(list);
        }
Beispiel #2
0
        private void BtnMosharekatOnClick(object sender, EventArgs e)
        {
            if (_type == EnRequestType.Mosharekat)
            {
                return;
            }
            _type = EnRequestType.Mosharekat;
            RefreshButtons();
            btnMosharekat.SetTextColor(Color.White);
            btnMosharekat.SetBackgroundColor(new Color(GetColor(Resource.Color.Blue)));

            BindList();
        }
 public frmFilterForm(EnRequestType type, Guid buildingType, Guid accountType, int roomCount, int fMasahat,
                      int sMasahat, decimal fPrice1, decimal sPrice1, decimal fPrice2, decimal sPrice2, List <Guid> regList)
 {
     InitializeComponent();
     ucHeader.Text = "فیلتر جستجوی ملک";
     RegionList    = regList;
     Task.Run(SetDataAsync);
     Type             = type;
     BuildingTypeGuid = buildingType;
     AccountTypeGuid  = accountType;
     RoomCount        = roomCount;
     FirstMasahat     = fMasahat;
     SecondMasahat    = sMasahat;
     FirstPrice1      = fPrice1;
     SecondPrice1     = sPrice1;
     FirstPrice2      = fPrice2;
     SecondPrice2     = sPrice2;
     SetAccess();
     btnRegion.Enabled = false;
 }
        public static async Task <List <BuildingViewModel> > GetAllAsync(string code, CancellationToken token, Guid buildingGuid,
                                                                         Guid buildingAccountTypeGuid, int fMasahat, int lMasahat, int roomCount, decimal fPrice1, decimal lPrice1,
                                                                         decimal fPrice2, decimal lPrice2, EnRequestType type, List <Guid> regionList)
        {
            try
            {
                IEnumerable <BuildingBussines> res = await GetAllAsync(token);

                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                if (regionList != null && regionList.Count > 0)
                {
                    res = res.Where(q => regionList.Contains(q.RegionGuid));
                }
                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                if (!string.IsNullOrEmpty(code))
                {
                    res = res.Where(q => q.Code.Contains(code));
                }
                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                if (buildingGuid != Guid.Empty)
                {
                    res = res.Where(q => q.BuildingTypeGuid == buildingGuid);
                }
                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                if (buildingAccountTypeGuid != Guid.Empty)
                {
                    res = res.Where(q => q.BuildingAccountTypeGuid == buildingAccountTypeGuid);
                }
                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                if (fMasahat != 0)
                {
                    res = res.Where(q => q.Masahat >= fMasahat);
                }
                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                if (lMasahat != 0)
                {
                    res = res.Where(q => q.Masahat <= lMasahat);
                }
                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                if (roomCount != 0)
                {
                    res = res.Where(q => q.RoomCount <= roomCount);
                }
                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                if (type == EnRequestType.Rahn)
                {
                    if (token.IsCancellationRequested)
                    {
                        return(null);
                    }
                    if (fPrice1 != 0)
                    {
                        res = res.Where(q => q.RahnPrice1 >= fPrice1);
                    }
                    if (fPrice2 != 0)
                    {
                        res = res.Where(q => q.RahnPrice2 <= fPrice2);
                    }
                    if (token.IsCancellationRequested)
                    {
                        return(null);
                    }
                    if (lPrice1 != 0)
                    {
                        res = res.Where(q => q.EjarePrice1 >= lPrice1);
                    }
                    if (lPrice2 != 0)
                    {
                        res = res.Where(q => q.EjarePrice2 <= lPrice2);
                    }
                }
                else
                {
                    if (token.IsCancellationRequested)
                    {
                        return(null);
                    }
                    if (fPrice1 != 0)
                    {
                        res = res.Where(q => q.SellPrice > 0 && q.SellPrice >= fPrice1);
                    }
                    if (fPrice2 != 0)
                    {
                        res = res.Where(q => q.SellPrice > 0 && q.SellPrice <= fPrice2);
                    }
                }
                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                var val = new List <BuildingViewModel>();

                foreach (var item in res)
                {
                    if (token.IsCancellationRequested)
                    {
                        return(null);
                    }
                    var a = new BuildingViewModel()
                    {
                        RoomCount       = item.RoomCount.ToString(),
                        SaleSakht       = item.SaleSakht,
                        Tabaqe          = $"{item.TabaqeNo} از {item.TedadTabaqe}",
                        Description     = item.ShortDesc,
                        Metrazh         = item.Masahat,
                        Region          = item.RegionName,
                        RentalAuthority = item.RentalAuthorityName,
                        Parent          = $"فایل های سیستم کد {item.Code}",
                        Options         = item.OptionList.Select(q => q.OptionName)?.ToList(),
                        Address         = item.Address,
                        Mobile          = PeoplesBussines.Get(item.OwnerGuid)?.FirstNumber
                    };
                    if (token.IsCancellationRequested)
                    {
                        return(null);
                    }
                    if (type == EnRequestType.Rahn)
                    {
                        a.Price1 = item.RahnPrice1;
                        a.Price2 = item.EjarePrice1;
                        if (item.RahnPrice2 != 0)
                        {
                            a.Tabdil = item.RahnPrice2 + "ریال ودیعه";
                        }
                        if (item.EjarePrice2 != 0)
                        {
                            a.Tabdil = a.Tabdil + item.EjarePrice2 + "ریال ودیعه";
                        }
                        if (item.RahnPrice2 == 0 && item.EjarePrice2 == 0)
                        {
                            a.Tabdil = "غیرقابل تبدیل";
                        }
                        a.Type = EnRequestType.Rahn;
                    }
                    else
                    {
                        if (token.IsCancellationRequested)
                        {
                            return(null);
                        }
                        a.Price1 = item.SellPrice;
                        a.Price2 = 0;
                        a.Type   = EnRequestType.Forush;
                    }
                    val.Add(a);
                }

                return(val);
            }
            catch (TaskCanceledException) { return(null); }
            catch (OperationCanceledException) { return(null); }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                return(new List <BuildingViewModel>());
            }
        }
        public static async Task <List <BuildingRequestBussines> > GetAllAsync(EnRequestType type, CancellationToken token, decimal price1,
                                                                               decimal price2, int masahat,
                                                                               int roomCount, Guid accountTypeGuid, Guid conditionGuid, Guid regionGuid)
        {
            try
            {
                IEnumerable <BuildingRequestBussines> res = await GetAllAsync(token);

                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                if (type == EnRequestType.Forush)
                {
                    res = res.Where(q => q.SellPrice1 <= price1 && q.SellPrice2 >= price1);
                }
                else if (type == EnRequestType.Rahn)
                {
                    if (token.IsCancellationRequested)
                    {
                        return(null);
                    }
                    res = res.Where(q => q.RahnPrice1 <= price1 && q.RahnPrice2 >= price1);
                    if (price2 != 0)
                    {
                        res = res.Where(q => q.EjarePrice1 <= price2 && q.EjarePrice2 >= price2);
                    }
                }
                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                if (masahat > 0)
                {
                    res = res.Where(q => q.Masahat1 <= masahat && q.Masahat2 >= masahat);
                }
                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                if (roomCount > 0)
                {
                    res = res.Where(q => q.RoomCount <= roomCount);
                }
                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                if (accountTypeGuid != Guid.Empty)
                {
                    res = res.Where(q =>
                                    q.BuildingAccountTypeGuid == Guid.Empty ||
                                    q.BuildingAccountTypeGuid == accountTypeGuid);
                }
                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                if (conditionGuid != Guid.Empty)
                {
                    res = res.Where(q => q.BuildingConditionGuid == Guid.Empty ||
                                    q.BuildingConditionGuid == conditionGuid);
                }
                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                if (regionGuid != Guid.Empty)
                {
                    res = res.Where(q => q.RegionList.Select(p => p.RegionGuid).Contains(regionGuid));
                }
                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                return(res?.ToList());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                return(null);
            }
        }
Beispiel #6
0
        public static List <BuildingListViewModel> GetAllBuildingListViewModel(Guid customerGuid, EnRequestType type)
        {
            var list = new List <BuildingListViewModel>();

            try
            {
                using (var cn = new SqlConnection(Cache.ConnectionString))
                {
                    var cmd = new SqlCommand("sp_Buildings_GetBuildingListViewModel", cn)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    cmd.Parameters.AddWithValue("@cusGuid", customerGuid);
                    cmd.Parameters.AddWithValue("@buType", (short)type);

                    cn.Open();
                    var dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        list.Add(LoadData(dr));
                    }
                    dr.Close();
                    cn.Close();
                }

                list = list?.OrderByDescending(q => q.CreateDate)?.Take(100).ToList();
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
            return(list);
        }
        private async Task SetFormControlAsync(EnRequestType type, Guid buildingType, Guid accountType, int roomCount, int fMasahat,
                                               int sMasahat, decimal fPrice1, decimal sPrice1, decimal fPrice2, decimal sPrice2)
        {
            try
            {
                while (!loadComlete)
                {
                    await Task.Delay(100);
                }
                cmbReqType.SelectedIndex             = (int)type;
                cmbBuildingType.SelectedValue        = buildingType;
                cmbBuildingAccountType.SelectedValue = accountType;
                txtRoomCount.Text = roomCount.ToString();

                if (fMasahat == 0)
                {
                    txtFMasahat.Text = fMasahat.ToString();
                }
                if (fMasahat != 0)
                {
                    if (fMasahat >= 10000)
                    {
                        txtFMasahat.Text = (fMasahat / 10000).ToString();
                    }
                    if (fMasahat <= 9999)
                    {
                        txtFMasahat.Text = fMasahat.ToString();
                    }
                }


                if (sMasahat == 0)
                {
                    txtSMasahat.Text = sMasahat.ToString();
                }
                if (sMasahat != 0)
                {
                    if (sMasahat >= 10000)
                    {
                        txtSMasahat.Text = (sMasahat / 10000).ToString();
                    }
                    if (sMasahat <= 9999)
                    {
                        txtSMasahat.Text = sMasahat.ToString();
                    }
                }



                if (fPrice1 == 0)
                {
                    txtFPrice1.Text        = fPrice1.ToString();
                    cmbRahn1.SelectedIndex = 0;
                }
                if (fPrice1 != 0)
                {
                    if (fPrice1 >= 10000 && fPrice1 >= 9999)
                    {
                        txtFPrice1.Text        = (fPrice1 / 10000).ToString();
                        cmbRahn1.SelectedIndex = 0;
                    }
                    if (fPrice1 >= 10000000 && fPrice1 >= 9999999)
                    {
                        txtFPrice1.Text        = (fPrice1 / 10000000).ToString();
                        cmbRahn1.SelectedIndex = 1;
                    }
                    if (fPrice1 >= 10000000000 && fPrice1 >= 9999999999)
                    {
                        txtFPrice1.Text        = (fPrice1 / 10000000000).ToString();
                        cmbRahn1.SelectedIndex = 2;
                    }
                }


                if (sPrice1 == 0)
                {
                    txtSPrice1.Text         = sPrice1.ToString();
                    cmbEjare1.SelectedIndex = 0;
                }
                if (sPrice1 != 0)
                {
                    if (sPrice1 >= 10000 && sPrice1 >= 9999)
                    {
                        txtSPrice1.Text         = (sPrice1 / 10000).ToString();
                        cmbEjare1.SelectedIndex = 0;
                    }
                    if (sPrice1 >= 10000000 && sPrice1 >= 9999999)
                    {
                        txtSPrice1.Text         = (sPrice1 / 10000000).ToString();
                        cmbEjare1.SelectedIndex = 1;
                    }
                    if (sPrice1 >= 10000000000 && sPrice1 >= 9999999999)
                    {
                        txtSPrice1.Text         = (sPrice1 / 10000000000).ToString();
                        cmbEjare1.SelectedIndex = 2;
                    }
                }



                if (fPrice2 == 0)
                {
                    txtFPrice2.Text        = fPrice2.ToString();
                    cmbRahn2.SelectedIndex = 0;
                }
                if (fPrice2 != 0)
                {
                    if (fPrice2 >= 10000 && fPrice2 >= 9999)
                    {
                        txtFPrice2.Text        = (fPrice2 / 10000).ToString();
                        cmbRahn2.SelectedIndex = 0;
                    }
                    if (fPrice2 >= 10000000 && fPrice2 >= 9999999)
                    {
                        txtFPrice2.Text        = (fPrice2 / 10000000).ToString();
                        cmbRahn2.SelectedIndex = 1;
                    }
                    if (fPrice2 >= 10000000000 && fPrice2 >= 9999999999)
                    {
                        txtFPrice2.Text        = (fPrice2 / 10000000000).ToString();
                        cmbRahn2.SelectedIndex = 2;
                    }
                }


                if (sPrice2 == 0)
                {
                    txtSPrice2.Text         = sPrice2.ToString();
                    cmbEjare2.SelectedIndex = 0;
                }
                if (sPrice2 != 0)
                {
                    if (sPrice2 >= 10000 && sPrice2 >= 9999)
                    {
                        txtSPrice2.Text         = (sPrice2 / 10000).ToString();
                        cmbEjare2.SelectedIndex = 0;
                    }
                    if (sPrice2 >= 10000000 && sPrice2 >= 9999999)
                    {
                        txtSPrice2.Text         = (sPrice2 / 10000000).ToString();
                        cmbEjare2.SelectedIndex = 1;
                    }
                    if (sPrice2 >= 10000000000 && sPrice2 >= 9999999999)
                    {
                        txtSPrice2.Text         = (sPrice2 / 10000000000).ToString();
                        cmbEjare2.SelectedIndex = 2;
                    }
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }