public ContractGrid GetAllContracts(InstagramContractSearchObject searchObject) { var gridPageSize = searchObject.PageSize ?? Utility.PageSize; var contractService = InstagramContractService.GetInstance(); int totalCount = 0; var data = (from c in contractService.GetDefaultQuery(searchObject, out totalCount) select new ContractViewModel { Id = c.Id, ContractNo = c.ContractNo, PersianContractDate = c.ContractDate.ToPersianString(), CustomerMobile = c.CustomerMobile, CustomerName = c.CustomerName, CustomerManagerName = c.CustomerManagerName, InstagramId = c.InstagramId, PaymentTotalPriceStr = c.PaymentTotalPrice.ToString("N0", new NumberFormatInfo() { NumberGroupSizes = new[] { 3 }, NumberGroupSeparator = "," }), }); var gridData = new ContractGrid { ContractList = data.ToList(), PageCount = Utility.CalculatePageSize(totalCount, gridPageSize), PageSize = gridPageSize }; return(gridData); }
public ContractGrid GetAllContracts(WebsiteContractSearchObject searchObject) { var gridPageSize = searchObject.PageSize ?? Utility.PageSize; var contractService = WebsiteContractService.GetInstance(); int totalCount = 0; var data = (from c in contractService.GetDefaultQuery(searchObject, out totalCount) select new ContractViewModel { Id = c.Id, ContractNo = c.ContractNo, PersianContractDate = c.ContractDate.ToPersianString(), CustomerMobile = c.CustomerMobile, CustomerName = c.CustomerName, CustomerManagerName = c.CustomerManagerName, DomainId = c.DomainId, PaymentTotalPriceStr = c.PaymentTotalPrice.SplitDigit() }); var gridData = new ContractGrid { ContractList = data.ToList(), PageCount = Utility.CalculatePageSize(totalCount, gridPageSize), PageSize = gridPageSize }; return(gridData); }
private async void ReqContractDetailsButton_Click(object sender, EventArgs e) { ContractGrid.Rows.Clear(); var contract = new Contract() { ConId = int.Parse(ConIdText.Text), Currency = CurrencyText.Text, Exchange = ExchangeText.Text, IncludeExpired = int.Parse(IncludeExpiredText.Text) != 0, LastTradeDateOrContractMonth = LastTradeDateOrContractMonthText.Text, LocalSymbol = LocalSymbolText.Text, Multiplier = MultiplierText.Text, PrimaryExch = PrimaryExchangeText.Text, Right = RightText.Text, SecId = SecIdText.Text, SecIdType = SecIdTypeCombo.SelectedItem?.ToString(), SecType = SecTypeCombo.SelectedItem?.ToString(), Strike = double.Parse(StrikeText.Text), Symbol = SymbolText.Text, TradingClass = TradingClassText.Text }; mContractFetcher = new ContractFetcher(); mContractFetcher.ContractFetchProgress += (s, ev) => { ContractFetchStatusLabel.Text = ev.Status; var suff = ev.NumberOfContracts > 1 ? "s" : ""; ContractsCountLabel.Text = $"{ev.NumberOfContracts} contract{suff}"; ContractFetchProgressBar.Value = (int)ev.PercentComplete; }; ContractFetchStatusLabel.Visible = true; ContractsCountLabel.Visible = true; ContractFetchProgressBar.Visible = true; TabControl1.SelectedTab = ContractsTabPage; this.UseWaitCursor = true; var contractDetailsList = await mContractFetcher.FetchContractsAsync(mApi, contract); mContractFetcher = null; if (contractDetailsList.Count != 0) { ContractGrid.Rows.Add(contractDetailsList.Count); for (int i = 0; i < contractDetailsList.Count; i++) { var row = ContractGrid.Rows[i]; row.Tag = contractDetailsList[i]; var c = contractDetailsList[i].Contract; showContractValue(row, ContractColumnId, c.ConId.ToString()); showContractValue(row, ContractColumnCurrency, c.Currency); showContractValue(row, ContractColumnExchange, c.Exchange); showContractValue(row, ContractColumnPrimaryExchange, c.PrimaryExch); showContractValue(row, ContractColumnExpiry, c.LastTradeDateOrContractMonth); showContractValue(row, ContractColumnLocalSymbol, c.LocalSymbol.Replace(" ", "\u00B7")); showContractValue(row, ContractColumnMultiplier, c.Multiplier); showContractValue(row, ContractColumnRight, c.Right); showContractValue(row, ContractColumnType, c.SecType); showContractValue(row, ContractColumnStrike, c.Strike.ToString()); showContractValue(row, ContractColumnSymbol, c.Symbol); showContractValue(row, ContractColumnTradingClass, c.TradingClass); } ContractGrid.ClearSelection(); } ContractFetchStatusLabel.Visible = false; ContractFetchProgressBar.Visible = false; this.UseWaitCursor = false; }