private void btnNav_Click(object sender, EventArgs e) { if (pSchedule.Visible && !pVehicle.Visible && !pOverview.Visible) { if (dtStart.Value.Date > dtEnd.Value.Date) { MessageBox.Show("End Date can't be lower than Start Date"); } else { var param = new Dictionary <string, object>(); param.Add("@start", dtStart.Value); param.Add("@end", dtEnd.Value); //grd.DataSource = Connection.GetTMSConnection.ExecuteStoredProcedure("SP_AvailableVehicle", param); //grd.ClearSelection(); lb.DataSource = Connection.GetTMSConnection.ExecuteStoredProcedure("SP_AvailableVehicle", param); lb.DisplayMember = "Vehicle"; lb.ValueMember = "Vehicle"; pSchedule.Visible = false; pVehicle.Visible = true; btnBack.Visible = true; } } else if (!pSchedule.Visible && pVehicle.Visible && !pOverview.Visible) // Available Vehicle { //if (grd.SelectedRows.Count == 0) //{ // MessageBox.Show("Select a vehicle."); //} lblExpStart.Text = dtStart.Value.Date.ToShortDateString(); lblExpEnd.Text = dtEnd.Value.Date.ToShortDateString(); lblIncharge.Text = txtIncharge.Text; lblVehicle.Text = lb.SelectedValue.ToString(); pVehicle.Visible = false; pOverview.Visible = true; btnNav.Text = "Save"; } else if (!pSchedule.Visible && !pVehicle.Visible && pOverview.Visible) { var unit = new TripUnit(); var manager = new TripManager(); unit.TripId = DataSupport.GetNextMenuCodeInt("TR"); unit.ExpectedStart = lblExpStart.Text; unit.ExpectedEnd = lblExpEnd.Text; unit.Incharge = lblIncharge.Text; unit.VehicleId = lblVehicle.Text; unit.RouteId = ""; unit.ActualStart = ""; unit.ActualEnd = ""; unit.Cost = ""; unit.LastUpdated = ""; manager.InsertTrip(unit); manager.RunScript(); MessageBox.Show("Successfully saved!"); DialogResult = DialogResult.OK; } }
private void btnNav_Click(object sender, EventArgs e) { if (cbRoute.SelectedIndex == -1) { MessageBox.Show("Select Route"); return; } var manager = new TripManager(); var tripUnit = new TripUnit(); tripUnit.TripId = lblTripNo.Text; tripUnit.ExpectedStart = lblTripStart.Text; tripUnit.ExpectedEnd = lblTripEnd.Text; tripUnit.Incharge = lblIncharge.Text; tripUnit.VehicleId = lblVehicle.Text; tripUnit.RouteId = cbRoute.SelectedValue.ToString(); tripUnit.ActualStart = ""; tripUnit.ActualEnd = ""; tripUnit.Cost = ""; tripUnit.LastUpdated = DateTime.Now.Date.ToShortDateString(); manager.InsertTrip(tripUnit); manager.WMSHeaderInsert(lblTripNo.Text, lblIncharge.Text); foreach (DataGridViewRow row in grdOrders.Rows) { var tripOrderUnit = new TripOrderUnit(); tripOrderUnit.DropSequence = row.Cells["colDropSequence"].Value.ToString(); tripOrderUnit.TripId = lblTripNo.Text; tripOrderUnit.OrderId = row.Cells["colShipId"].Value.ToString(); tripOrderUnit.Reference = row.Cells["colRefDoc"].Value.ToString(); tripOrderUnit.ReferenceDate = row.Cells["colRefDocDate"].Value.ToString(); tripOrderUnit.ClientId = row.Cells["colClient"].Value.ToString(); tripOrderUnit.CustomerId = row.Cells["colCustId"].Value.ToString(); tripOrderUnit.OrderManagementSystem = row.Cells["colClient"].Value.ToString(); tripOrderUnit.DocumentValue = row.Cells["colDocValue"].Value.ToString(); tripOrderUnit.CustomerDeliveryAddress = ""; tripOrderUnit.Remarks = ""; tripOrderUnit.Status = "FOR RECEIVING"; manager.InsertTripOrder(tripOrderUnit); manager.UpdateOutgoingShipmentRequest("out_shipment_id", tripOrderUnit.OrderId); manager.WMSDetailsInsert(tripOrderUnit.TripId, tripOrderUnit.OrderId, tripOrderUnit.DropSequence, lblTripStart.Text); } manager.RunScript(); MessageBox.Show("SAVED"); DialogResult = DialogResult.OK; }