コード例 #1
0
        // /////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        // STEP1 - BEGIN
        //
        // ////////////////////////////////////////////////////////////////////////
        // STEP1 - BEGIN - AUXILIAR EVENTS
        //
        protected void ddlSelectAPeriod_SelectedIndexChanged(object sender, EventArgs e)
        {
            Page.Validate("Begin");

            if (Page.IsValid)
            {
                StepBeginProcessGrid();

                // Load
                VacationsSetupTDS dataSet = new VacationsSetupTDS();
                dataSet.VacationsSetup.Merge(vacationsSetup, true);
                VacationsSetup model = new VacationsSetup(dataSet);

                if (dataSet.VacationsSetup.Select(string.Format("Year = {0}", Int32.Parse(ddlSelectAPeriod.SelectedValue))).Length == 0)
                {
                    // ... Load
                    model.LoadByYear(Int32.Parse(ddlSelectAPeriod.SelectedValue), Int32.Parse(hdfCompanyId.Value));

                    dataSet.VacationsSetup.Merge(vacationsSetup, true);
                    odsVacationsSetup.FilterExpression = string.Format("Year = {0}", Int32.Parse(ddlSelectAPeriod.SelectedValue));
                }
                else
                {
                    odsVacationsSetup.FilterExpression = string.Format("Year = {0}", Int32.Parse(ddlSelectAPeriod.SelectedValue));
                }

                // Store tables
                vacationsSetup = (VacationsSetupTDS.VacationsSetupDataTable)model.Table;
                Session["vacationsSetup"] = vacationsSetup;
            }

            grdVacationsSetup.DataBind();
        }
コード例 #2
0
        // /////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        // STEP2 - SUMMARY
        //
        // ////////////////////////////////////////////////////////////////////////
        // STEP2 - SUMMARY - METHODS
        //
        private void StepSummaryIn()
        {
            // Set instruction
            Label instruction = (Label)this.Master.FindControl("lblInstruction");
            instruction.Text = "Summary";

            // Initialize summary
            VacationsSetupTDS dataSet = new VacationsSetupTDS();
            dataSet.VacationsSetup.Merge(vacationsSetup, true);
            VacationsSetup model = new VacationsSetup(dataSet);

            tbxSummary.Text = model.GetSummary(Int32.Parse(ddlSelectAPeriod.SelectedValue));
        }
コード例 #3
0
        // ////////////////////////////////////////////////////////////////////////
        // STEP1 - BEGIN - METHODS
        //
        private void StepBeginIn()
        {
            // Set instruction
            Label instruction = (Label)this.Master.FindControl("lblInstruction");
            instruction.Text = "Please provide paid vacation days information";

            // Initiaize data
            vacationsSetup = new VacationsSetupTDS.VacationsSetupDataTable();

            // Load
            VacationsSetupTDS dataSet = new VacationsSetupTDS();
            VacationsSetup model = new VacationsSetup(dataSet);

            model.LoadByYear(Int32.Parse(ddlSelectAPeriod.SelectedValue), Int32.Parse(hdfCompanyId.Value));

            // Store tables
            vacationsSetup = (VacationsSetupTDS.VacationsSetupDataTable)model.Table;
            Session["vacationsSetup"] = vacationsSetup;
        }
コード例 #4
0
        private void StepBeginProcessGrid()
        {
            if (ExistsDataModified())
            {
                VacationsSetupTDS dataSet = new VacationsSetupTDS();
                dataSet.VacationsSetup.Merge(vacationsSetup, true);
                VacationsSetup model = new VacationsSetup(dataSet);

                // update rows
                foreach (GridViewRow row in grdVacationsSetup.Rows)
                {
                    int year = Int32.Parse(grdVacationsSetup.DataKeys[row.RowIndex].Values["Year"].ToString());
                    int employeeId = Int32.Parse(grdVacationsSetup.DataKeys[row.RowIndex].Values["EmployeeID"].ToString());
                    double newVacationDays = double.Parse(((TextBox)row.FindControl("tbxVacationDays")).Text);
                    double newCarryOverDays = double.Parse(((TextBox)row.FindControl("tbxCarryOverDays")).Text);

                    model.Update(year, employeeId, newVacationDays, newCarryOverDays);
                }

                vacationsSetup = (VacationsSetupTDS.VacationsSetupDataTable)model.Table;
                Session["vacationsSetup"] = vacationsSetup;

                hdfUpdate.Value = "yes";
            }
        }
コード例 #5
0
        private void Save()
        {
            // process sections
            VacationsSetupTDS dataSet = new VacationsSetupTDS();
            dataSet.VacationsSetup.Merge(vacationsSetup, true);
            VacationsSetup model = new VacationsSetup(dataSet);

            // save to database
            DB.Open();
            DB.BeginTransaction();
            try
            {
                model.Save(int.Parse(hdfCompanyId.Value));

                DB.CommitTransaction();
            }
            catch (Exception ex)
            {
                DB.RollbackTransaction();

                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }
        }