private void button1_Click(object sender, EventArgs e) { DateTime fromDate = dtpFrom.Value; DateTime toDate = dtpTo.Value; List <tblTrain> listTrain = TrainFactory.SearchTrain("", Convert.ToInt16(((ComboBoxItem)ddlTypeName.SelectedItem).Value), true, fromDate, toDate); try { var report = new ReportPassengerTrain(); var txtType = (TextObject)report.Section1.ReportObjects["txtType"]; var txtFrom = (TextObject)report.Section1.ReportObjects["txtFrom"]; var txtTo = (TextObject)report.Section1.ReportObjects["txtTo"]; txtType.Text = ("HÀNH KHÁCH " + ddlTypeName.Text + " BẰNG ĐƯỜNG SẮT").ToUpper(); txtFrom.Text = txtFrom.Text + " " + dtpFrom.Text; txtTo.Text = txtTo.Text + " " + dtpTo.Text; DataSet1 dataset = new DataSet1(); DataTable dt = dataset.tblTrain; foreach (tblTrain train in listTrain) { dt.Rows.Add(train.TrainID, train.Number, train.Type, train.DateImportExport, train.Jounery, train.PassengerVN, train.PassengerForegin, train.Staff, train.CreatedDate, train.CreatedByName, train.ModifiedDate, train.ModifiedByName); } report.SetDataSource(dataset); FrmPreviewReport frmReport = new FrmPreviewReport(report); frmReport.MdiParent = this.MdiParent; frmReport.Show(); } catch (Exception ex) { } }
private void btnSearch_Click(object sender, EventArgs e) { try { var listTrain = TrainFactory.SearchTrain(txtNumberTrain.Text.Trim(), Convert.ToInt32(((ComboBoxItem)ddlTypeName.SelectedItem).Value), dtpDateXNC.Value); grdTrain.AutoGenerateColumns = false; grdTrain.DataSource = listTrain; for (var i = 0; i < grdTrain.Rows.Count; i++) { // Add to count Column grdTrain.Rows[i].Cells[0].Value = (i + 1).ToString(); } } catch (Exception ex) { if (GlobalInfo.IsDebug) { MessageBox.Show(ex.ToString()); } } }
public void search() { try { DateTime fromDate = dtpFrom.Value; DateTime toDate = dtpTo.Value; var listTrain = TrainFactory.SearchTrain(txtNumberTrain.Text.Trim(), Convert.ToInt16(((ComboBoxItem)ddlTypeName.SelectedItem).Value), cbNgayXNC.Checked, fromDate, toDate); grdTrain.AutoGenerateColumns = false; grdTrain.DataSource = listTrain; for (var i = 0; i < grdTrain.Rows.Count; i++) { // Add to count Column grdTrain.Rows[i].Cells[1].Value = (i + 1).ToString(); short type = short.Parse(grdTrain.Rows[i].Cells[4].Value.ToString()); if (type == (short)ChuyenTauType.TypeExport) { grdTrain.Rows[i].Cells[5].Value = "Xuất cảnh"; } if (type == (short)ChuyenTauType.TypeImport) { grdTrain.Rows[i].Cells[5].Value = "Nhập cảnh"; } } } catch (Exception ex) { if (GlobalInfo.IsDebug) { MessageBox.Show(ex.ToString()); } } }