Пример #1
0
        public static bool UpdateDailyShiftSchedule(ShiftDS schedule)
        {
            //Update a daily shift schedule
            bool result = false;

            try {
                result = Mediator.ExecuteNonQuery("uspEnterpriseShiftUpdate", new object[] { schedule });
            }
            catch (Exception ex) { throw ex; }
            return(result);
        }
Пример #2
0
        public static ShiftDS GetDailyShiftSchedule(int terminalID, string weekday)
        {
            //Get a daily shift schedule for a specified terminal and a single day of the week
            ShiftDS schedule = new ShiftDS();

            try {
                DataSet ds = Mediator.FillDataset("uspEnterpriseShiftDayGetForTerminalAndDay", "ShiftDetailTable", new object[] { terminalID, weekday });
                if (ds != null)
                {
                    schedule.Merge(ds, true, MissingSchemaAction.Ignore);
                }
            }
            catch (Exception ex) { throw ex; }
            return(schedule);
        }
Пример #3
0
        public static ShiftDS ViewShiftSchedules(int terminalID)
        {
            //Get the daily shift schedule for one terminal
            ShiftDS schedule = new ShiftDS();

            try {
                DataSet ds = Mediator.FillDataset("uspEnterpriseShiftDayGetListForTerminal", "ShiftViewTable", new object[] { terminalID });
                if (ds != null)
                {
                    schedule.Merge(ds);
                }
            }
            catch (Exception ex) { throw ex; }
            return(schedule);
        }
Пример #4
0
        public ShiftDS GetShifts(string terminal, DateTime date)
        {
            //Event handler for change in selected terminal
            ShiftDS shifts = null;

            try {
                shifts = new ShiftDS();
                DataSet ds = FillDataset(USP_SHIFTS, TBL_SHIFTS, new object[] { terminal, date.ToString("yyyy-MM-dd") });
                if (ds.Tables[TBL_SHIFTS] != null && ds.Tables[TBL_SHIFTS].Rows.Count > 0)
                {
                    shifts.Merge(ds);
                }
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected exception creating shift list.", ex); }
            return(shifts);
        }
Пример #5
0
    protected void OnButtonCommand(object sender, CommandEventArgs e)
    {
        //Event handler for view button clicked
        //Change view to Viewer and reset to clear existing data
        Master.Viewer.Reset();

        //Get parameters for the query
        string _start    = this.ddpPickups.ToDate.ToString("yyyy-MM-dd");
        string _terminal = this.cboTerminal.SelectedValue;
        int    _shift    = int.Parse(this.cboShift.SelectedValue);
        string _header   = "Shift Report";

        //Initialize control values
        LocalReport report = Master.Viewer.LocalReport;

        report.DisplayName          = REPORT_NAME;
        report.EnableExternalImages = true;
        EnterpriseGateway enterprise = new EnterpriseGateway();
        DataSet           ds         = new DataSet(REPORT_DS);
        DataSet           _ds        = enterprise.FillDataset(USP_REPORT, TBL_REPORT, new object[] { _terminal, _start, _shift });

        if (_ds.Tables[TBL_REPORT].Rows.Count >= 0)
        {
            string filter = "";
            switch (this.cboType.SelectedValue.ToLower())
            {
            case "tsort": filter = "FreightType = 'Tsort'"; _header = "Tsort"; break;

            case "returns": filter = "FreightType = 'Returns'"; _header = "Return"; break;

            case "both": filter = null; _header = "Tsort & Return"; break;
            }
            DataRow[] rows = _ds.Tables[TBL_REPORT].Select(filter);
            ds.Merge(rows);

            switch (e.CommandName)
            {
            case "Run":
                //Set local report and data source
                System.IO.Stream stream = Master.GetReportDefinition(REPORT_SRC);
                report.LoadReportDefinition(stream);
                report.DataSources.Clear();
                report.DataSources.Add(new ReportDataSource(REPORT_DS, ds.Tables[TBL_REPORT]));

                //Set the report parameters for the report
                ReportParameter terminalID  = new ReportParameter("TerminalID", _terminal);
                ReportParameter start       = new ReportParameter("Date", _start);
                ReportParameter shift       = new ReportParameter("ShiftNumber", _shift.ToString());
                ReportParameter terminal    = new ReportParameter("SortedLocation", this.cboTerminal.SelectedItem.Text);
                ReportParameter freigthType = new ReportParameter("FreightType", _header);

                ShiftDS shiftDS = new ShiftDS();
                shiftDS.Merge(enterprise.GetShifts(_terminal, this.ddpPickups.ToDate));
                ShiftDS.ShiftTableRow row           = (ShiftDS.ShiftTableRow)shiftDS.ShiftTable.Select("NUMBER='" + this.cboShift.SelectedValue.ToString() + "'")[0];
                ReportParameter       shiftTimeIn   = new ReportParameter("ShiftTimeIn", row.StartTime.ToString("yyyy-MM-dd"));
                ReportParameter       shiftTimeOut  = new ReportParameter("ShiftTimeOut", row.EndTime.ToString("yyyy-MM-dd"));
                ReportParameter       shiftBreak    = new ReportParameter("ShiftBreak", row.BreakTime.ToString("yyyy-MM-dd"));
                ReportParameter       shiftProdTime = new ReportParameter("ProductionTime", string.Concat(Decimal.Truncate((row.ProductionTime / 60)), ":", Convert.ToString(row.ProductionTime % 60)));
                report.SetParameters(new ReportParameter[] { terminalID, start, shift, terminal, shiftTimeIn, shiftTimeOut, shiftBreak, shiftProdTime, freigthType });

                //Update report rendering with new data
                report.Refresh();

                if (!Master.Viewer.Enabled)
                {
                    Master.Viewer.CurrentPage = 1;
                }
                break;

            case "Data":
                //Set local export report and data source
                report.LoadReportDefinition(Master.CreateExportRdl(ds, REPORT_DS, "RGXSQLR.TSORT"));
                report.DataSources.Clear();
                report.DataSources.Add(new ReportDataSource(REPORT_DS, ds.Tables[TBL_REPORT]));
                report.Refresh();
                break;

            case "Excel":
                //Create Excel mime-type page
                Response.ClearHeaders();
                Response.Clear();
                Response.Charset = "";
                Response.AddHeader("Content-Disposition", "inline; filename=Shift.xls");
                Response.ContentType = "application/vnd.ms-excel";      //application/octet-stream";
                System.IO.StringWriter       sw = new System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
                DataGrid dg = new DataGrid();
                dg.DataSource = ds.Tables[TBL_REPORT];
                dg.DataBind();
                dg.RenderControl(hw);
                Response.Write(sw.ToString());
                Response.End();
                break;
            }
        }
        else
        {
            Master.Status = "There were no records found.";
        }
    }