private void getStartDates() { DateTime startDate; cboStartDate.Items.Clear(); foreach (var item in DrayageSchemeService.GetDrayageScheme(Conversions.ToInteger(cboTuckingCompany.SelectedValue), Conversions.ToString(cboRateType.SelectedItem))) { //TODO //startDate = Conversions.ToDate(item.fromDate); //if (!cboStartDate.Items.Contains(startDate.ToString("dd-MMM-yyyy"))) //{ // cboStartDate.Items.Add(startDate.ToString("dd-MMM-yyyy")); //} } if (cboStartDate.Items.Count > 0) { cboStartDate.SelectedIndex = 0; } }
private void getAssignedRates() { try { if (!Information.IsNothing(cboRateType.SelectedItem)) { var fromDate = Convert.ToDateTime(cboStartDate.SelectedItem); DrayageSchemeRateBindingSource.DataSource = DrayageSchemeService.GetAssignedRates(Conversions.ToInteger(cboTuckingCompany.SelectedValue), Conversions.ToString(cboRateType.SelectedItem), Conversions.ToString(fromDate.Date)); dgvAssignedRates.Columns[1].Visible = false; dgvAssignedRates.Columns[2].Visible = false; dgvAssignedRates.Columns[3].Visible = false; dgvAssignedRates.Columns[4].Visible = false; dgvAssignedRates.Columns[5].Visible = false; dgvAssignedRates.Columns[10].Visible = false; // dgvAssignedRates.RowsDefaultCellStyle.ForeColor = Color.Black } } catch (Exception ex) { Debugger.Break(); } }
private void saveButton_Click(object sender, EventArgs e) { MdlLoadingSetting.waitForm.Show(); var fromID = default(int); var toId = default(int); DateTime startDate; var toDateTime = dtpEndDate.MinDate; int drayageRateId; int schemaID = DrayageSchemeService.GetByFromToId(Conversions.ToInteger(cboTuckingCompany.SelectedValue), fromID, toId); if (IsUpdate()) { for (int j = 0, loopTo = dgvAssignedRates.Rows.Count - 1; j <= loopTo; j++) { if (Conversions.ToBoolean(Operators.ConditionalCompareObjectEqual(dgvAssignedRates.Rows[j].Cells[0].Value, true, false))) { drayageRateId = Conversions.ToInteger(dgvAssignedRates.Rows[j].Cells[1].Value); startDate = Convert.ToDateTime(cboStartDate.SelectedItem); schemaID = Conversions.ToInteger(dgvAssignedRates.Rows[j].Cells[2].Value); if (dtpEndDate.CustomFormat.Equals(" ")) { bool isupdated = dr.Update(drayageRateId, schemaID, startDate.Date, toDateTime, NumericUpDown1.Value, Conversions.ToString(cboRateType.SelectedItem)); } else { bool isupdated = dr.Update(drayageRateId, schemaID, startDate.Date, dtpEndDate.Value.Date, NumericUpDown1.Value, Conversions.ToString(cboRateType.SelectedItem)); } } } } else if (isNewRate()) { for (int i = 0, loopTo1 = dgvFromDock.Rows.Count - 1; i <= loopTo1; i++) { if (Conversions.ToBoolean(Operators.ConditionalCompareObjectEqual(dgvFromDock.Rows[i].Cells[1].Value, true, false))) { fromID = Conversions.ToInteger(dgvFromDock.Rows[i].Cells[0].Value); for (int s = 0, loopTo2 = dgvToDock.Rows.Count - 1; s <= loopTo2; s++) { if (Conversions.ToBoolean(Operators.ConditionalCompareObjectEqual(dgvToDock.Rows[s].Cells[1].Value, true, false))) { toId = Conversions.ToInteger(dgvToDock.Rows[s].Cells[0].Value); schemaID = DrayageSchemeService.GetByFromToId(Conversions.ToInteger(cboTuckingCompany.SelectedValue), fromID, toId); if (schemaID == 0) { DrayageSchemeService.Insert(Conversions.ToInteger(cboTuckingCompany.SelectedValue), fromID, toId); schemaID = DrayageSchemeService.GetByFromToId(Conversions.ToInteger(cboTuckingCompany.SelectedValue), fromID, toId); } startDate = Convert.ToDateTime(cboStartDate.SelectedItem); if (dtpEndDate.CustomFormat.Equals(" ")) { DrayageRateService.Insert(schemaID, startDate.Date, toDateTime, NumericUpDown1.Value, Conversions.ToString(cboRateType.SelectedItem)); } else { DrayageRateService.Insert(schemaID, startDate.Date, dtpEndDate.Value.Date, NumericUpDown1.Value, Conversions.ToString(cboRateType.SelectedItem)); } } } } } } getAssignedRates(); checkSaveButton(); MdlLoadingSetting.waitForm.Close(); }