public AllInfoByDateReport(string FromDate, string FromTime, string ToDate, string ToTime) { // // Required for Windows Form Designer support // InitializeComponent(); try { HPS.BLL.TrafficBLL.BLLTraffic_TFactory TrafficFactory = new HPS.BLL.TrafficBLL.BLLTraffic_TFactory(); DataTable AllDataTable = new DataTable(); DataTable LadeAssignmentTable = new DataTable(); TrafficFactory.TurnAndLadeAssignmentInfoByLaderTypeReport(FromDate, FromTime, ToDate, ToTime, null, ref AllDataTable); TrafficFactory.LadeAssignmentInfoByLaderType(FromDate, FromTime, ToDate, ToTime, null, ref LadeAssignmentTable); DataRow[] dr = null; foreach (DataRow row in AllDataTable.Rows) { dr = LadeAssignmentTable.Select(string.Format(" LaderTypeID_int={0} ", row["LaderTypeID_int"])); if (dr != null && dr.Length > 0) { row["CarCount_int"] = dr[0][2]; row["ladBillCount_int"] = dr[0][3]; row["LadeRemainedCount_int"] = dr[0][4]; row["RemainedPercent_flt"] = dr[0][5]; } else { //var set = new HashSet<int>(LadeAssignmentTable.AsEnumerable().Select(p =>Convert.ToInt32(p["LaderTypeID_int"]))); //var result = AllDataTable.AsEnumerable().Where(i => !set.Contains(Convert.ToInt32(i["LaderTypeID_int"]))).ToList(); ////not in LadeAssignmentTable but in AllDataTable //for (int i = 0; i < result.Count; i++) //{ // row["LaderTypeID_int"] = result[i]["LaderTypeID_int"]; // row["LaderType_nvc"] = result[i]["LaderType_nvc"]; // row["CarCount_int"] = result[i]["CarCount_int"]; // row["ladBillCount_int"] = result[i]["ladBillCount_int"]; // row["LadeRemainedCount_int"] = result[i]["LadeRemainedCount_int"]; // row["RemainedPercent_flt"] = result[i]["RemainedPercent_flt"]; // row["TurnRemainedCount_int"] = 0; // AllDataTable.Rows.Add(row); //} ////not in AllDataTable but in LadeAssignmentTable var ladeset = new HashSet <int>(AllDataTable.AsEnumerable().Select(p => Convert.ToInt32(p["LaderTypeID_int"]))); var ladeResult = LadeAssignmentTable.AsEnumerable().Where(i => !ladeset.Contains(Convert.ToInt32(i["LaderTypeID_int"]))).ToList(); for (int i = 0; i < ladeResult.Count; i++) { row["LaderTypeID_int"] = ladeResult[i]["LaderTypeID_int"]; row["LaderType_nvc"] = ladeResult[i]["LaderType_nvc"]; row["CarCount_int"] = ladeResult[i]["CarCount_int"]; row["ladBillCount_int"] = ladeResult[i]["ladBillCount_int"]; row["LadeRemainedCount_int"] = ladeResult[i]["LadeRemainedCount_int"]; row["RemainedPercent_flt"] = ladeResult[i]["RemainedPercent_flt"]; row["TurnRemainedCount_int"] = 0; AllDataTable.Rows.Add(row); } } } this.DataSource = AllDataTable; FromDatetxt.Text = FromDate; FromTimetxt.Text = FromTime; ToDatetxt.Text = ToDate; ToTimetxt.Text = ToTime; TurnToDatetextBox.Text = ToDate; TurnToTimetextBox.Text = ToTime; UserNameTextBox.Text = HPS.Common.CurrentUser.user.UserName_nvc; Datetxt.Text = TrafficFactory.ServerJalaliDate; Timetxt.Text = TrafficFactory.ServerTime; LaderType_nvctxt.DataField = "LaderType_nvc"; TurnCounttxt.DataField = "TurnRemainedCount_int"; LadeAssignmenttxt.DataField = "CarCount_int"; LadBillCount_inttextbox.DataField = "LadBillCount_int"; Remaindtxt.DataField = "LadeRemainedCount_int"; Percenttxt.DataField = "RemainedPercent_flt"; Int64?AllturnRemainedRecords = (from row in AllDataTable.AsEnumerable() select Convert.ToInt32(row["TurnRemainedCount_int"])).Sum(); AllTurnRemainedtxt.Text = AllturnRemainedRecords.HasValue ? AllturnRemainedRecords.ToString() : "0"; Int64?AllRemainedCountRecords = (from row in AllDataTable.AsEnumerable() select Convert.ToInt32(row["LadeRemainedCount_int"])).Sum(); AllLadeRemaindedCounttxt.Text = AllRemainedCountRecords.HasValue ? AllRemainedCountRecords.ToString() : "0"; Int64?AllRequestCountRecords = (from row in AllDataTable.AsEnumerable() select Convert.ToInt32(row["CarCount_int"])).Sum(); AllRequesttxt.Text = AllRequestCountRecords.HasValue ? AllRequestCountRecords.ToString() : "0"; Int64?AllLadBillCountRecords = (from row in AllDataTable.AsEnumerable() select Convert.ToInt32(row["LadBillCount_int"])).Sum(); AllLadBillxt.Text = AllLadBillCountRecords.HasValue ? AllLadBillCountRecords.ToString() : "0"; if (Convert.ToInt32(AllRequesttxt.Text) != 0) { AllRemainedPercentTxt.Text = (Convert.ToDouble(AllLadeRemaindedCounttxt.Text) * 100 / Convert.ToDouble(AllRequesttxt.Text)).ToString("0.##"); } else { AllRemainedPercentTxt.Text = "0"; } } catch (Exception ex) { Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message); } }
private void ShowButton_Click(object sender, EventArgs e) { try { if (FromDatefaDatePicker.IsNull) { throw new ApplicationException("از تاریخ خالی است"); } else if (ToDatefaDatePicker.IsNull) { throw new ApplicationException("تا تاریخ خالی است"); } else if (string.IsNullOrEmpty(Hepsa.Core.Common.PersentationController.GetMaskedTextBoxValue(FromTimeTextBox))) { throw new ApplicationException("از ساعت خالی است"); } else if (string.IsNullOrEmpty(Hepsa.Core.Common.PersentationController.GetMaskedTextBoxValue(ToTimeTextBox))) { throw new ApplicationException("تا ساعت خالی است"); } Hepsa.Core.Validation.TimeRule <string> FromTimeValidator = new Hepsa.Core.Validation.TimeRule <string>("FromTime", "از ساعت", null, null); if (FromTimeValidator.Validate(Hepsa.Core.Common.PersentationController.GetMaskedTextBoxValue(FromTimeTextBox)) == false) { throw new ApplicationException(FromTimeValidator.Description); } Hepsa.Core.Validation.TimeRule <string> ToTimeValidator = new Hepsa.Core.Validation.TimeRule <string>("ToTime", "تا ساعت", null, null); if (ToTimeValidator.Validate(Hepsa.Core.Common.PersentationController.GetMaskedTextBoxValue(ToTimeTextBox)) == false) { throw new ApplicationException(ToTimeValidator.Description); } //// HPS.BLL.TrafficBLL.BLLTraffic_TFactory TrafficFactory = new HPS.BLL.TrafficBLL.BLLTraffic_TFactory(); DataTable AllDataTable = new DataTable(); DataTable LadeAssignmentTable = new DataTable(); TrafficFactory.TurnAndLadeAssignmentInfoByLaderTypeReport(FromDatefaDatePicker.Text, FromTimeTextBox.Text, ToDatefaDatePicker.Text, ToTimeTextBox.Text, null, ref AllDataTable); TrafficFactory.LadeAssignmentInfoByLaderType(FromDatefaDatePicker.Text, FromTimeTextBox.Text, ToDatefaDatePicker.Text, ToTimeTextBox.Text, null, ref LadeAssignmentTable); DataRow[] dr = null; foreach (DataRow row in AllDataTable.Rows) { dr = LadeAssignmentTable.Select(string.Format(" LaderTypeID_int={0} ", row["LaderTypeID_int"])); if (dr != null && dr.Length > 0) { row["Canceled_int"] = dr[0][2]; row["CarCount_int"] = dr[0][3]; row["ladBillCount_int"] = dr[0][4]; row["LadeRemainedCount_int"] = dr[0][5]; row["RemainedPercent_flt"] = dr[0][6]; } else { var ladeset = new HashSet <int>(AllDataTable.AsEnumerable().Select(p => Convert.ToInt32(p["LaderTypeID_int"]))); var ladeResult = LadeAssignmentTable.AsEnumerable().Where(i => !ladeset.Contains(Convert.ToInt32(i["LaderTypeID_int"]))).ToList(); for (int i = 0; i < ladeResult.Count; i++) { row["LaderTypeID_int"] = ladeResult[i]["LaderTypeID_int"]; row["LaderType_nvc"] = ladeResult[i]["LaderType_nvc"]; row["CarCount_int"] = ladeResult[i]["CarCount_int"]; row["ladBillCount_int"] = ladeResult[i]["ladBillCount_int"]; row["LadeRemainedCount_int"] = ladeResult[i]["LadeRemainedCount_int"]; row["RemainedPercent_flt"] = ladeResult[i]["RemainedPercent_flt"]; row["TurnRemainedCount_int"] = 0; AllDataTable.Rows.Add(row); } } } Int64? AllRemainedCountRecords = (from row in AllDataTable.AsEnumerable() select Convert.ToInt32(row["LadeRemainedCount_int"])).Sum(); string AllLadeRemaindedCounttxt = AllRemainedCountRecords.HasValue ? AllRemainedCountRecords.ToString() : "0"; Int64? AllRequestCountRecords = (from row in AllDataTable.AsEnumerable() select Convert.ToInt32(row["CarCount_int"])).Sum(); string AllRequesttxt = AllRequestCountRecords.HasValue ? AllRequestCountRecords.ToString() : "0"; Int64? AllLadBillCountRecords = (from row in AllDataTable.AsEnumerable() select Convert.ToInt32(row["LadBillCount_int"])).Sum(); string AllLadBillxt = AllLadBillCountRecords.HasValue ? AllLadBillCountRecords.ToString() : "0"; string AllRemainedPercentTxt = ""; if (Convert.ToInt32(AllRequesttxt) != 0) { AllRemainedPercentTxt = (Convert.ToDouble(AllLadeRemaindedCounttxt) * 100 / Convert.ToDouble(AllRequesttxt)).ToString("0.##"); } else { AllRemainedPercentTxt = "0"; } DataSet MyDataset = new DataSet(); MyDataset.Tables.Add(AllDataTable); AllInfoByDatestiReport.Dictionary.Synchronize(); AllInfoByDatestiReport.Dictionary.Databases.Clear(); AllInfoByDatestiReport.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", Hepsa.Core.Common.ConnectionString.ConnectionString)); AllInfoByDatestiReport.RegData(MyDataset); AllInfoByDatestiReport.Compile(); AllInfoByDatestiReport["organ"] = new HPS.BLL.SettingsBLL.BLLSetting_TFactory().GetBy(new BLL.SettingsBLL.BLLSetting_TKeys() { SettingID_int = 1029 }).Value_nvc.ToString(); AllInfoByDatestiReport["date_vc"] = TrafficFactory.ServerJalaliDate + " " + TrafficFactory.ServerTime; AllInfoByDatestiReport["UserName_vc"] = HPS.Common.CurrentUser.user.UserName_nvc; AllInfoByDatestiReport["AllRemainedPercentTxt"] = AllRemainedPercentTxt; AllInfoByDatestiReport["fromdate_vc"] = FromDatefaDatePicker.Text; AllInfoByDatestiReport["todate_vc"] = ToDatefaDatePicker.Text; AllInfoByDatestiReport["fromTime_vc"] = FromTimeTextBox.Text; AllInfoByDatestiReport["toTime_vc"] = ToTimeTextBox.Text; AllInfoByDatestiReport.Render(); stiViewerControl1.Report = AllInfoByDatestiReport; //// //HPS.Reports.ReportDoc.AllInfoByDateReport rpt = new HPS.Reports.ReportDoc.AllInfoByDateReport(FromDatefaDatePicker.Text, FromTimeTextBox.Text, ToDatefaDatePicker.Text, ToTimeTextBox.Text); //rpt.Document.Printer.PrinterName = string.Empty; //viewer1.Document = rpt.Document; //rpt.Run(); } catch (Exception ex) { Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message); } }