Exemplo n.º 1
0
        private void CompanyRemainedButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (FromDatefaDatePicker.IsNull)
                {
                    throw new ApplicationException("از تاریخ خالی است");
                }
                else if (string.IsNullOrEmpty(Hepsa.Core.Common.PersentationController.GetMaskedTextBoxValue(FromTimeTextBox)))
                {
                    throw new ApplicationException("از ساعت خالی است");
                }
                else if (ToDatefaDatePicker.IsNull)
                {
                    throw new ApplicationException("تا تاریخ خالی است");
                }
                else if (string.IsNullOrEmpty(Hepsa.Core.Common.PersentationController.GetMaskedTextBoxValue(ToTimeTextBox)))
                {
                    throw new ApplicationException("تا ساعت خالی است");
                }
                Hepsa.Core.Validation.DateRule <string> FromDateValidator = new Hepsa.Core.Validation.DateRule <string>("FromDate", "از تاریخ", null, null);
                if (FromDateValidator.Validate(FromDatefaDatePicker.Text) == false)
                {
                    throw new ApplicationException(FromDateValidator.Description);
                }

                Hepsa.Core.Validation.DateRule <string> ToDateValidator = new Hepsa.Core.Validation.DateRule <string>("ToDate", "تا تاریخ", null, null);
                if (ToDateValidator.Validate(ToDatefaDatePicker.Text) == false)
                {
                    throw new ApplicationException(ToDateValidator.Description);
                }
                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);
                }


                string CompanyList_nvc = string.Empty;
                foreach (Janus.Windows.GridEX.GridEXRow itm in companyGrid.GetCheckedRows())
                {
                    CompanyList_nvc += itm.Cells["CompanyID_int"].Value.ToString() + ",";
                }
                if (CompanyList_nvc.EndsWith(","))
                {
                    CompanyList_nvc = CompanyList_nvc.Remove(CompanyList_nvc.Length - 1);
                }

                string LaderTypeList_nvc = string.Empty;
                foreach (Janus.Windows.GridEX.GridEXRow itm in laderTypeGrid.GetCheckedRows())
                {
                    LaderTypeList_nvc += itm.Cells["LaderTypeID_int"].Value.ToString() + ",";
                }
                if (LaderTypeList_nvc.EndsWith(","))
                {
                    LaderTypeList_nvc = LaderTypeList_nvc.Remove(LaderTypeList_nvc.Length - 1);
                }

                string GoodList_nvc = string.Empty;
                foreach (Janus.Windows.GridEX.GridEXRow itm in goodGrid.GetCheckedRows())
                {
                    GoodList_nvc += itm.Cells["GoodID_int"].Value.ToString() + ",";
                }
                if (GoodList_nvc.EndsWith(","))
                {
                    GoodList_nvc = GoodList_nvc.Remove(GoodList_nvc.Length - 1);
                }
                goodGrid.UnCheckAllRecords();

                string PortPlaceList_nvc = string.Empty;
                foreach (Janus.Windows.GridEX.GridEXRow itm in portPlaceGrid.GetCheckedRows())
                {
                    PortPlaceList_nvc += itm.Cells["PortPlacesID_int"].Value.ToString() + ",";
                }
                if (PortPlaceList_nvc.EndsWith(","))
                {
                    PortPlaceList_nvc = PortPlaceList_nvc.Remove(PortPlaceList_nvc.Length - 1);
                }
                portPlaceGrid.UnCheckAllRecords();

                string DestinationCityList_nvc = string.Empty;
                foreach (Janus.Windows.GridEX.GridEXRow itm in destinationCityGrid.GetCheckedRows())
                {
                    DestinationCityList_nvc += itm.Cells["CityID_int"].Value.ToString() + ",";
                }
                if (DestinationCityList_nvc.EndsWith(","))
                {
                    DestinationCityList_nvc = DestinationCityList_nvc.Remove(DestinationCityList_nvc.Length - 1);
                }
                destinationCityGrid.UnCheckAllRecords();
                ////////////////////////////////////////
                //HPS.Reports.ReportDoc.CompanyAllRemainedLaderTypeReport rpt = new HPS.Reports.ReportDoc.CompanyAllRemainedLaderTypeReport(FromDatefaDatePicker.Text, FromTimeTextBox.Text, ToDatefaDatePicker.Text, ToTimeTextBox.Text, LaderTypeList_nvc, CompanyList_nvc, GoodList_nvc, DestinationCityList_nvc, PortPlaceList_nvc);
                //viewer1.Document = rpt.Document;
                //rpt.Document.Printer.PrinterName = string.Empty;
                //rpt.Run();
                HPS.BLL.PortPlacesBLL.BLLPortPlaces_TFactory PortPlaceFactory = new HPS.BLL.PortPlacesBLL.BLLPortPlaces_TFactory();

                GeneralReport.Dictionary.Synchronize();
                GeneralReport.Dictionary.Databases.Clear();
                GeneralReport.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", Hepsa.Core.Common.ConnectionString.ConnectionString));
                GeneralReport.Compile();
                GeneralReport["organ"] = new HPS.BLL.SettingsBLL.BLLSetting_TFactory().GetBy(new BLL.SettingsBLL.BLLSetting_TKeys()
                {
                    SettingID_int = 1029
                }).Value_nvc.ToString();
                GeneralReport["fromDate_nvc"]  = FromDatefaDatePicker.Text;
                GeneralReport["fromTime_nvc"]  = FromTimeTextBox.Text;
                GeneralReport["toTime_nvc"]    = ToTimeTextBox.Text;
                GeneralReport["toDate_nvc"]    = ToDatefaDatePicker.Text;
                GeneralReport["date_vc"]       = PortPlaceFactory.ServerJalaliDate + "   " + PortPlaceFactory.ServerTime;;
                GeneralReport["Username_nvc"]  = HPS.Common.CurrentUser.user.UserName_nvc;
                GeneralReport["title_nvc"]     = "لیست بارهای درخواستی و جامانده شرکت های حمل و نقل";
                ExportToExcelButton.Enabled    = true;
                GeneralReport["@fromdate_nvc"] = FromDatefaDatePicker.Text;
                GeneralReport["@fromtime_nvc"] = FromTimeTextBox.Text;
                GeneralReport["@totime_nvc"]   = ToTimeTextBox.Text;
                GeneralReport["@todate_nvc"]   = ToDatefaDatePicker.Text;
                if (string.IsNullOrEmpty(LaderTypeList_nvc))
                {
                    GeneralReport["@LaderTypeID_nvc"] = DBNull.Value;
                }
                else
                {
                    GeneralReport["@LaderTypeID_nvc"] = LaderTypeList_nvc;
                }

                if (string.IsNullOrEmpty(CompanyList_nvc))
                {
                    GeneralReport["@CompanyID_nvc"] = DBNull.Value;
                }
                else
                {
                    GeneralReport["@CompanyID_nvc"] = CompanyList_nvc;
                }

                if (string.IsNullOrEmpty(GoodList_nvc))
                {
                    GeneralReport["@GoodIDList_nvc"] = DBNull.Value;
                }
                else
                {
                    GeneralReport["@GoodIDList_nvc"] = GoodList_nvc;
                }

                if (string.IsNullOrEmpty(DestinationCityList_nvc))
                {
                    GeneralReport["@DestinationCityIDList_nvc"] = DBNull.Value;
                }
                else
                {
                    GeneralReport["@DestinationCityIDList_nvc"] = DestinationCityList_nvc;
                }

                if (string.IsNullOrEmpty(PortPlaceList_nvc))
                {
                    GeneralReport["@PortPlaceIDList_nvc"] = DBNull.Value;
                }
                else
                {
                    GeneralReport["@PortPlaceIDList_nvc"] = PortPlaceList_nvc;
                }

                GeneralReport.Render();
                stiViewerControl1.Report = GeneralReport;
            }
            catch (Exception ex)
            {
                Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
            }
        }