private void cmb_fueltypes_SelectedIndexChanged(object sender, EventArgs e) { //KeyValue value = (KeyValue)cmb_fueltypes.SelectedValue; if (commonFunctions.ToInt(cmb_fueltypes.SelectedValue.ToString()) > 0) { FuelType ft = CustomeRepository.GetFuelRecord(commonFunctions.ToInt(cmb_fueltypes.SelectedValue.ToString())); txt_price.Text = ft.UnitPrice.ToString(); CalculateBalance(); } }
private void button6_Click(object sender, EventArgs e) { if (MessageBox.Show("Do you want to Save this record?", Messaging.MessageCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { FuelType ft = CustomeRepository.GetFuelRecord(commonFunctions.ToInt(cmb_fueltypes.SelectedValue.ToString())); UnloadingFuel model = new UnloadingFuel(); model.Id = ft.Id; model.Price = ft.UnitPrice; model.Quntity = txt_qty.Value; model.Total = num_total.Value; model.Net = commonFunctions.ToDecimal(lbl_nettotal.Text.Trim()); model.FuelType = cmb_fueltypes.Text; model.Additions = num_additions.Value; model.Deductions = num_deductions.Value; repo.Add(model); dgmain.DataSource = repo; Calculate(); } }
private void LoadFuels() { try { List <KeyValue> listoffuels = KeyValueRepository.GetFuelTypes().ToList(); if (listoffuels.Count > 0) { cmb_fueltypes.DataSource = listoffuels; cmb_fueltypes.DisplayMember = "Name"; cmb_fueltypes.ValueMember = "Id"; cmb_fueltypes.SelectedIndex = 0; if (commonFunctions.ToInt(cmb_fueltypes.SelectedValue.ToString()) > 0) { FuelType ft = CustomeRepository.GetFuelRecord(commonFunctions.ToInt(cmb_fueltypes.SelectedValue.ToString())); txt_price.Text = ft.UnitPrice.ToString(); } } } catch (Exception ex) { MessageBox.Show("Error Has found when loading data. Please forword following details to technical" + Environment.NewLine + "[" + ex.Message + Environment.NewLine + ex.Source + "]", Messaging.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } }