Esempio n. 1
0
        internal bool GetByDate(Entities.TourCollection tours, DateTime date)
        {
            bool res = false;

            try
            {
                this.query.Parameters.Clear();
                this.query.Parameters.Add(new SqlParameter("@TourTime", Utils.GetDbTime(date)));

                res = this.query.ExecuteReader("ToursGetByDate", MapTourToObject, tours);
            }
            catch (Exception ex)
            {
                try
                {
                    DomainModel.Application.Status.Update(
                        StatusController.Abstract.StatusTypes.Error,
                        "",
                        ex.Message);
                }
                catch { }
            }

            return(res);
        }
Esempio n. 2
0
        public ToursListView(Entities.TourCollection tours)
            : base()
        {
            InitializeComponent();

            SetupControls();
            BindControls(tours);
        }
Esempio n. 3
0
        private void BindControls(Entities.TourCollection tours)
        {
            this.Tours              = tours;
            this.Tours.ListChanged += new ListChangedEventHandler(Tours_ListChanged);

            this.ctrlManager = new FormControlManager(this.flpTours, tours);
            this.ctrlManager.CreateControl       = CreateTour;
            this.ctrlManager.FindControl         = TourFindControl;
            this.ctrlManager.ListContainsControl = ListContainsTour;
        }
Esempio n. 4
0
        protected void MapTourToObject(SqlDataReader reader, object userData)
        {
            Entities.TourCollection tours = (Entities.TourCollection)userData;
            Entities.Tour           tour  = new Entities.Tour();

            tour.Id         = Utils.GetSafeInt32(reader, "TourId");
            tour.Time.Value = Utils.GetSafeDateTime(reader, "TourTime", DateTime.Now);
            tour.Comments   = Utils.GetSafeString(reader, "Comments");

            if (tour.Time != null)
            {
                tour.Time.IsDirty = false;
            }
            tour.IsDirty = false;

            tours.Add(tour);
        }
Esempio n. 5
0
        private void BindControls()
        {
            this.tours = new Entities.TourCollection();

            bstMaster            = new BindingSource();
            bstMaster.DataSource = this.tours;

            /*
             * this.rtbComments.DataBindings.Add(
             *  new Binding(
             *      "Text",
             *      this.bstMaster,
             *      "Comments",
             *      false,
             *      DataSourceUpdateMode.OnPropertyChanged,
             *      string.Empty,
             *      string.Empty,
             *      null));*/
        }
Esempio n. 6
0
        public static bool Generate(Entities.ReportInfo info)
        {
            bool res = false;

            try
            {
                string title = DomainModel.Application.
                               ResourceManager.GetText("rep_monthly_bill_title");

                int   colnum = 0;
                int   rownum = -1;
                Sheet sheet;
                Row   row;
                Cell  head;

                TypeDic    typeDic = new TypeDic();
                ServiceDic srvDic  = new ServiceDic();
                HeaderRow  headRow = new HeaderRow();

                // Create header
                int index = 0;

                // Create first col: day#
                HeaderCell hc = new HeaderCell(index);
                hc.Text = DomainModel.
                          Application.ResourceManager.GetText("rep_monthly_bill_col_day");
                headRow.Add(hc);
                index++;

                // create service type cols
                srvDic.Clear();
                foreach (Entities.Service srv in DomainModel.Services.GetAll())
                {
                    hc      = new HeaderCell(index);
                    hc.Text = string.Format("  {0} {1} ({2})  ",
                                            srv.ServiceType.Name,
                                            srv.Name,
                                            srv.PricePerPerson.FormattedValue);

                    headRow.Add(hc);

                    srvDic.Add(srv, new ServiceCell(index));

                    index++;
                }

                // Create payment type columns
                foreach (Entities.GeneralType type in DomainModel.PaymentTypes.GetAll())
                {
                    hc      = new HeaderCell(index);
                    hc.Text = "  " + type.Name + "  ";
                    headRow.Add(hc);

                    typeDic.Add(type, new ServiceCell(index));
                    index++;
                }

                HSSFWorkbook hssfworkbook = new HSSFWorkbook();

                // Create theme
                Font headFont = hssfworkbook.CreateFont();
                headFont.Color      = HSSFColor.WHITE.index;
                headFont.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.BOLD;

                CellStyle headstyle = hssfworkbook.CreateCellStyle();
                headstyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.BLACK.index;
                headstyle.FillPattern         = FillPatternType.SOLID_FOREGROUND;
                headstyle.SetFont(headFont);

                //// Create a entry of DocumentSummaryInformation
                DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
                dsi.Company = "Ms. Anke Maass";
                hssfworkbook.DocumentSummaryInformation = dsi;

                //// Create a entry of SummaryInformation
                SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
                si.Subject = "Tour monthly bill";
                hssfworkbook.SummaryInformation = si;

                // For each month in report inf
                for (DateTime date = info.StartTime; date.Month <= info.EndTime.Month; date = date.AddMonths(1))
                {
                    colnum = 0;

                    string month      = date.ToString("MMMM");
                    string sheetTitle = string.Format("{0} {1:00} {2:0000}",
                                                      title, month, DateTime.Now.Year);

                    // Create sheet
                    sheet = hssfworkbook.CreateSheet(month);
                    //sheet.DefaultColumnWidth = 25;

                    rownum = -1;
                    row    = sheet.CreateRow(++rownum); // Title
                    row    = sheet.CreateRow(++rownum); // Space
                    row    = sheet.CreateRow(++rownum); // Col. headers

                    // Set columns titles
                    foreach (HeaderCell headCell in headRow)
                    {
                        row.CreateCell(colnum).SetCellValue(headCell.Text);
                        row.GetCell(colnum).CellStyle = headstyle;
                        sheet.AutoSizeColumn(colnum);

                        colnum++;
                    }

                    // Set sheet title (After columns for autowidth calculations)
                    row            = sheet.GetRow(0);
                    head           = HSSFCellUtil.CreateCell(row, 0, sheetTitle);
                    head.CellStyle = headstyle;
                    sheet.AddMergedRegion(new CellRangeAddress(0, 0, 0, 6));

                    row            = sheet.GetRow(1);
                    head           = HSSFCellUtil.CreateCell(row, 0, "");
                    head.CellStyle = headstyle;
                    sheet.AddMergedRegion(new CellRangeAddress(1, 1, 0, 6));

                    // Create count rows
                    for (DateTime dt = date; dt.Month <= date.Month; dt = dt.AddDays(1))
                    {
                        row = sheet.CreateRow(++rownum);

                        row.CreateCell(0).SetCellValue(dt.Day);
                        row.GetCell(0).CellStyle = headstyle;

                        Entities.TourCollection tours = new Entities.TourCollection();
                        DomainModel.Tours.LoadByDate(dt, tours);

                        // Reset counters
                        foreach (Entities.Service key in srvDic.Keys)
                        {
                            srvDic[key].Count = 0;
                        }

                        foreach (Entities.GeneralType key in typeDic.Keys)
                        {
                            typeDic[key].Value = 0;
                        }

                        // calc columns
                        foreach (Entities.Tour tour in tours)
                        {
                            foreach (Entities.TourGroup group in tour.Groups)
                            {
                                foreach (Entities.Abstract.ITourService srv in group.Services)
                                {
                                    srvDic[srv.Detail].Count += srv.CostDetails.ServiceCount;

                                    foreach (Entities.TourPayment payment in srv.Payments)
                                    {
                                        typeDic[payment.Type].Value += payment.Amount.Value;
                                    }
                                }
                            }
                        }

                        // Set row cells
                        foreach (Entities.Service key in srvDic.Keys)
                        {
                            if (srvDic[key].Count != 0)
                            {
                                row.CreateCell(srvDic[key].Index).SetCellValue(srvDic[key].Count);
                            }
                        }

                        foreach (Entities.GeneralType key in typeDic.Keys)
                        {
                            if (typeDic[key].Value > 0.0M)
                            {
                                row.CreateCell(typeDic[key].Index).SetCellValue(
                                    (double)typeDic[key].Value);
                            }
                        }
                    }
                }

                // Create footer

                //Write the stream data of workbook to the root directory
                FileStream file = new FileStream(info.Path, FileMode.Create);
                hssfworkbook.Write(file);
                file.Close();

                res = true;
            }
            catch (Exception ex)
            {
            }

            return(res);
        }