Exemplo n.º 1
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            int     servID    = 0;
            int     frcRateID = 0;
            string  compCode  = "";
            var     rateType  = default(string);
            decimal rate;

            if (typeOfUpdate.Equals("update"))
            {
                servID = Conversions.ToInteger(My.MyProject.Forms.FrmServices.servicesDataGridView.Rows[My.MyProject.Forms.FrmServices.servicesDataGridView.CurrentRow.Index].Cells[0].Value);
            }
            else
            {
                servID = 0;
            }

            foreach (DataRow company in My.MyProject.Forms.FrmServices.companiesDT.Rows)
            {
                if (company["DescCompanyType"].Equals("Trucking Company"))
                {
                    if (company["CompanyName"].ToString().ToUpper().Equals(truckNameDropdown6.SelectedItem))
                    {
                        compCode = Conversions.ToString(company["CompanyCode"]);
                    }
                }
            }

            if (servTypeDropdown.SelectedItem.Equals("Drayage"))
            {
                if (singleEmptyRadioButton.Checked)
                {
                    rateType = "Single Empty";
                }
                else if (multipleEmtyRadioButton.Checked)
                {
                    rateType = "Multiple Empty";
                }
                else if (multLoadRadioButton.Checked)
                {
                    rateType = "Multiple Load";
                }
                else if (singleLoadsRadioButton2.Checked)
                {
                    rateType = "Single Load";
                }
                else if (deadCallRadioButton.Checked)
                {
                    rateType = "Dead Call";
                }
                else if (transfersRadioButton.Checked)
                {
                    rateType = "Transfer";
                }

                dbCeres.saveUpdateDrayage(servID, Conversions.ToString(truckNameDropdown6.SelectedItem), rateType, Conversions.ToString(fromDropdown.SelectedItem), Conversions.ToString(toDropdown.SelectedItem), rateNumericUpDown.Value);
            }
            else if (servTypeDropdown.SelectedItem.Equals("FSC"))
            {
                dbCeres.saveUpdateFSC(frcRateID, Conversions.ToString(truckNameDropdown6.SelectedItem), fromDatePicker.Value, toDatePicker.Value, rateFSCUpDown.Value, Conversions.ToString(servTypeDropdown.SelectedItem), toDateToggleSwitch.Value);
            }
            else
            {
                if (sameRateRadioButton.Checked == true)
                {
                    wkEndCutOffTimePicker.Value   = wkDayCutOfftimePicker.Value;
                    wkEndsDayNumericUpDown.Value  = wkDayDayRateFeeday.Value;
                    wkEndNightNumericUpDown.Value = wkDayNightRateUpDown.Value;
                }

                dbCeres.saveUpdateTEF(servID, wkDayCutOfftimePicker.Value, wkDayDayRateFeeday.Value, wkDayNightRateUpDown.Value, wkEndCutOffTimePicker.Value, wkEndsDayNumericUpDown.Value, wkEndNightNumericUpDown.Value, Conversions.ToString(portsRvDropdown.SelectedItem), fromRVDatePicker.Value, toRVDatePicker.Value, Conversions.ToString(rvRateTypeDropdown.SelectedItem));
            }

            My.MyProject.Forms.FrmServices.populateServices();
            Close();
        }