private void SearchData() { Cursor.Current = Cursors.WaitCursor; DateTime dtFromDate, dtToDate; string strFromDate, strToDate; string strCompany = string.Empty; string strPOType = string.Empty; int intStatus = 0; try { dtFromDate = Convert.ToDateTime(dtSearchDateFrom.EditValue); dtToDate = Convert.ToDateTime(dtSearchDateTo.EditValue).AddDays(1); strFromDate = Functions.FunctionDateToString(dtFromDate, 0); strToDate = Functions.FunctionDateToString(dtToDate, 0); dtFromDate = Convert.ToDateTime(strFromDate); dtToDate = Convert.ToDateTime(strToDate); strCompany = Functions.GetcheckedComboBoxValue(lueSearchCustomer); strPOType = Functions.GetcheckedComboBoxValue(lueSearchPOType); if (chkPalletDate.Checked) { intStatus = 1; // Available Pallet QTY } else { intStatus = 0; // Period by Pallet Date } gvList.Columns.Clear(); gcList.DataSource = null; if (rdbSummary.Checked) { var qry = db.stp_DailyResult_By_Summary(dtFromDate, dtToDate, strCompany, strPOType, intStatus).ToList(); if (qry.Count() > 0) { gcList.DataSource = qry; gvList.BestFitColumns(); gvList.OptionsBehavior.ReadOnly = true; gvList.FocusedRowHandle = gvList.GetVisibleRowHandle(0); gvList.Columns["QTY"].DisplayFormat.FormatString = "#,##0"; gvList.Columns["QTY"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom; gvList.OptionsView.ShowFooter = true; gvList.Columns["QTY"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum; gvList.Columns["QTY"].SummaryItem.FieldName = "QTY"; gvList.Columns["QTY"].SummaryItem.DisplayFormat = "Total QTY: {0:n0}"; } else { gcList.DataSource = null; MessageBox.Show("No Results", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { var qry = db.stp_DailyResult_By_Daily(dtFromDate, dtToDate, strCompany, strPOType).ToList(); if (qry.Count() > 0) { gcList.DataSource = qry; gvList.BestFitColumns(); gvList.OptionsBehavior.ReadOnly = true; gvList.FocusedRowHandle = gvList.GetVisibleRowHandle(0); gvList.Columns["QTY"].DisplayFormat.FormatString = "#,##0"; gvList.Columns["QTY"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom; gvList.OptionsView.ShowFooter = true; gvList.Columns["QTY"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum; gvList.Columns["QTY"].SummaryItem.FieldName = "QTY"; gvList.Columns["QTY"].SummaryItem.DisplayFormat = "Total QTY: {0:n0}"; } else { gcList.DataSource = null; MessageBox.Show("No Results", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show("Couldn't Search Customer List!" + Environment.NewLine + ex.Message.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Cursor.Current = Cursors.Default; } }