//******************************** Navigation **************************************** private void btnNext1_Click(object sender, EventArgs e) { // one they click the button, check for changed items, check for correct input validation, then commit changes. // user should be allowed to go forward if there are any changes. Show a message box to confirm this. bool isFormValid = false; // Need to include error checking if (hasDataChanged == true) { ResetAllErrorMessage(); // reset any error messages isFormValid = ValidateGasSales(); hasDataChanged = false; // reset the data changed flag if (isFormValid == true) { // commit changes to database // get salesid ArrayList arrFueldata = new ArrayList(); //int fuelType, decimal price, int NumberOfUnits, decimal soldamount, decimal dollaramount, decimal costofga arrFueldata.Add(new FuelData(1, decimal.Parse(txtPriceUnleaded.Text), 1, decimal.Parse(txtUnleaded.Text), decimal.Parse(txtTotalDollarsUnleaded.Text), decimal.Parse(txtCostUnleaded.Text))); //arrFueldata.Add(new FuelData(1, 123.45m, 1, 123.78m, 123.98m, 123.32m)); arrFueldata.Add(new FuelData(2, decimal.Parse(txtPricePremium.Text), 1, decimal.Parse(txtPremium.Text), decimal.Parse(txtTotalDollarsPremium.Text), decimal.Parse(txtCostPremium.Text))); arrFueldata.Add(new FuelData(3, decimal.Parse(txtPricePlus.Text), 1, decimal.Parse(txtPlus.Text), decimal.Parse(txtTotalDollarsPlus.Text), decimal.Parse(txtCostPlus.Text))); // call update method. GasSalesDB updateFuelData = new GasSalesDB(); BusinessDate salesDate = new BusinessDate(dtBusinessDate.Value); updateFuelData.UpdateGasSalesChanges(arrFueldata, salesDate.SalesDateID); if (updateFuelData.ExceptionsMessages.Message != "") { DisplayErrorMessage(lblGasSalesErrorMessage, //updateFuelData.ExceptionsMessages.Message + "\n\n" + updateFuelData.ExceptionsMessages.ErrorMessage + "\n\n" + updateFuelData.ExceptionsMessages.ErrorType + "\n\n" //updateFuelData.ExceptionsMessages.AdditionalMessage ); } } } else { //pnlGasSales.Hide(); pnlSOTG.Visible = true; } //pnlSOTG.Visible = true; }
// get one dataset using one call to db for combobox population // this will populate the 'global' variable so that you can access data within the set at any time. // private bool PopulateGasSalesForm() { // PopulateGasSalesForm(): // Populating this form should occur on_load, when salesdate has changed, bool updateCompleted = true; // Retrieves an ArrayList of FuelData objs then will cycle through them to update the text boxes. ArrayList arrGasSales = new ArrayList(); GasSalesDB getGasSales = new GasSalesDB(); arrGasSales = getGasSales.GetGasSalesByDateId(SalesDateId); if (arrGasSales != null) // only update the form if there are any no errors. { foreach (var fueldataitem in arrGasSales) { FuelData fdGasSales = (FuelData)fueldataitem; //lblResults.Text += fdGasSales.ReturnFuelDataClass() + "\n"; if (fdGasSales.FuelType == 1) { // udpate the unleaded box txtUnleaded.Text = fdGasSales.SoldAmount.ToString(); txtPriceUnleaded.Text = String.Format("{0:C3}", fdGasSales.Price); txtTotalDollarsUnleaded.Text = String.Format("{0:C3}", fdGasSales.DollarAmount); txtCostUnleaded.Text = String.Format("{0:C3}", fdGasSales.CostOfGas); } else if (fdGasSales.FuelType == 3) { // udpate all the plus text boxes //txtPlus.Text = fdGasSales.SoldAmount.ToString(); txtPlus.Text = fdGasSales.SoldAmount.ToString(); txtPricePlus.Text = String.Format("{0:C3}", fdGasSales.Price); txtTotalDollarsPlus.Text = String.Format("{0:C3}", fdGasSales.DollarAmount); txtCostPlus.Text = String.Format("{0:C3}", fdGasSales.CostOfGas); } else if (fdGasSales.FuelType == 2) { //txtPlus.Text = fdGasSales.SoldAmount.ToString(); txtPremium.Text = fdGasSales.SoldAmount.ToString(); txtPricePremium.Text = String.Format("{0:C3}", fdGasSales.Price); txtTotalDollarsPremium.Text = String.Format("{0:C3}", fdGasSales.DollarAmount); txtCostPremium.Text = String.Format("{0:C3}", fdGasSales.CostOfGas); } } } else { DisplayErrorMessage(lblGasSalesErrorMessage, getGasSales.ExceptionsMessages.Message); } hasDataChanged = false; // delete flag that indicates taht the data has changed. return(updateCompleted); }