protected override void LoadPage() { CustomCombo cbType = fldType.field as CustomCombo; cbType.lookup_action = (key) => { List <KeyValuePair <string, string> > source = new List <KeyValuePair <string, string> >(); var enum_list = (Setting.SettingType[])Enum.GetValues(typeof(Setting.SettingType)); foreach (Setting.SettingType setting in enum_list) { string des = SRL.ClassManagement.GetEnumDescription(setting); var keypair = new KeyValuePair <string, string>(setting.ToString(), des); source.Add(keypair); } return(Task.FromResult(source)); }; _ = cbType.BindData(null); List <string> setting_type = new List <string>(); fldType.Combo_SelectedIndexChangedResult(setting_type); fldKey.enabled_action = (key) => { return(Task.FromResult(key != Setting.SettingType.AnnualProfit.ToString())); }; fldType.Combo_SelectedIndexChanged((s, e) => fldKey.Enablation(setting_type[0])); fldKey.Enablation(setting_type[0]); fldKey.driven_action = (key) => { string rez = null; if (key == Setting.SettingType.AnnualProfit.ToString()) { rez = Setting.SettingType.AnnualProfit.ToString(); } return(Task.FromResult(rez)); }; fldType.Combo_SelectedIndexChanged((s, e) => { fldKey.Drivtion(setting_type[0], FieldPanel.FieldType.Textbox); }); LoadAsynch(); }
protected override void LoadPage() { LoadAsynch(); _ = new Fund().LoadAllToComboBox(fldFund); List <string> fund_key = new List <string>(); fldFund.Combo_SelectedIndexChangedResult(fund_key); CustomCombo cbUnit = fldUnit.field as CustomCombo; cbUnit.lookup_action = (key) => TempUnits(key); bool first_load = true; fldFund.Combo_SelectedIndexChanged((s, e) => _ = cbUnit.BindData(fund_key[0], () => { if (first_load) { LoadAfterAsyncEditData(() => { fldUnit.SetValue(EntityToEditObject.unit_cost_id); }); first_load = false; } }) ); List <string> unit_key = new List <string>(); fldUnit.Combo_SelectedIndexChangedResult(unit_key); CustomCombo cbAccount = fldAccount.field as CustomCombo; cbAccount.lookup_action = (key) => { var accounts = new List <KeyValuePair <string, string> >(); if (!string.IsNullOrWhiteSpace(key)) { accounts = new Account().GetAccounts(long.Parse(key)); } return(Task.FromResult(accounts)); }; fldFund.Combo_SelectedIndexChanged((s, e) => _ = cbAccount.BindData(fund_key[0])); fldUnit.Combo_SelectedIndexChanged(async(s, e) => { if (!string.IsNullOrWhiteSpace(unit_key[0])) { var unit = await new UnitCost().Get <UnitCost>(unit_key[0]); fldIssueCost.Text_SetText(unit.Model?.issue_cost?.ToString()); } else { fldIssueCost.Text_SetText(""); } }); List <decimal?> count = new List <decimal?>(); fldCount.Numeric_ValueChangedResult(count); List <string> issue_cost = new List <string>(); fldIssueCost.Text_ValueChangedResult(issue_cost); fldAmount.driven_action = (key) => { return(Task.FromResult(key)); }; fldCount.Numeric_ValueChanged((s, e) => { AmountDriveAcion(count, issue_cost); }); fldIssueCost.Text_ValueChanged((s, e) => { AmountDriveAcion(count, issue_cost); }); buyerGridLastRow.AddAggregatedColumn(nameof(Purchase.amount), DataGridLastRow.AggreagteAction.Sum); dataGridView1.LastRowGrid = buyerGridLastRow; dataGridView1.InsertColumns(new Purchase().GetGridColumns()); dataGridView1.SelectionChanged += DataGridView1_SelectionChanged; }
protected override void LoadPage() { CustomCombo cbCalc = fldCalcType.field as CustomCombo; cbCalc.lookup_action = (key) => { List <KeyValuePair <string, string> > source = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>(CalcType.percent.ToString(), "درصدی"), new KeyValuePair <string, string>(CalcType.number.ToString(), "عددی") }; return(Task.FromResult(source)); }; _ = cbCalc.BindData(null); List <string> calc_type = new List <string>(); fldCalcType.Combo_SelectedIndexChangedResult(calc_type); fldAmountPercent.enabled_action = (key) => { return(Task.FromResult(key == "percent")); }; fldCalcType.Combo_SelectedIndexChanged((s, e) => fldAmountPercent.Enablation(calc_type[0])); fldAmountPercent.Enablation(calc_type[0]); List <decimal?> tashim_percent = new List <decimal?>(); fldAmountPercent.Numeric_ValueChangedResult(tashim_percent); fldKasrAz.enabled_action = (key) => { return(Task.FromResult(key == "kasri")); }; fldCalcType.Combo_SelectedIndexChanged((s, e) => fldKasrAz.Enablation(calc_type[0])); fldKasrAz.Enablation(calc_type[0]); List <decimal?> kasr_az = new List <decimal?>(); fldKasrAz.Numeric_ValueChangedResult(kasr_az); fldKasrTa.enabled_action = (key) => { return(Task.FromResult(key == "kasri")); }; fldCalcType.Combo_SelectedIndexChanged((s, e) => fldKasrTa.Enablation(calc_type[0])); fldKasrTa.Enablation(calc_type[0]); List <decimal?> kasr_ta = new List <decimal?>(); fldKasrTa.Numeric_ValueChangedResult(kasr_ta); fldAmount.enabled_action = (key) => { return(Task.FromResult(key == "number")); }; fldCalcType.Combo_SelectedIndexChanged((s, e) => fldAmount.Enablation(calc_type[0])); fldAmount.Enablation(calc_type[0]); fldAmount.driven_action = (key) => { decimal percent; string result = null; if (decimal.TryParse(key, out percent)) { result = ((long)(percent * total_amount)).ToString(); } return(Task.FromResult(result)); }; fldAmountPercent.Numeric_ValueChanged((s, e) => fldAmount.Drivtion((tashim_percent[0] / 100)?.ToString(), FieldPanel.FieldType.Textbox)); fldKasrAz.Numeric_ValueChanged((s, e) => { if (kasr_az[0] != null && kasr_az[0] != 0 && kasr_ta[0] != null && kasr_ta[0] != 0) { fldAmount.Drivtion((kasr_az[0] / kasr_ta[0]).ToString(), FieldPanel.FieldType.Textbox); } }); fldKasrTa.Numeric_ValueChanged((s, e) => { if (kasr_az[0] != null && kasr_az[0] != 0 && kasr_ta[0] != null && kasr_ta[0] != 0) { fldAmount.Drivtion((kasr_az[0] / kasr_ta[0]).ToString(), FieldPanel.FieldType.Textbox); } }); fldCalcType.Combo_SetValue(CalcType.percent.ToString()); fldAmountPercent.Numeric_SetText(100); lblAmountLeft.Tag = "مبلغ قابل تخصیص: "; SetLeftAmount(); LoadAsynch(); }