Beispiel #1
0
    protected void btnExportToExcel_Click(object sender, EventArgs e)
    {
        sDataSource = System.Configuration.ConfigurationManager.ConnectionStrings[Request.Cookies["Company"].Value].ToString();

        int    empNO         = 0;
        int    managerID     = 0;
        string empName       = string.Empty;
        string managerName   = string.Empty;
        string sWeekID       = string.Empty;
        string dTSEDateRange = string.Empty;
        string sApproved     = string.Empty;

        if (ddlEmployee.Text.Trim() != string.Empty)
        {
            empNO = Convert.ToInt32(ddlEmployee.Text.Trim());
            lblEmployeeNumber.Text = empNO.ToString();
        }

        if (ddlApprover.Text.Trim() != string.Empty)
        {
            managerID = Convert.ToInt32(ddlApprover.Text.Trim());
        }

        if (txtDateRange.Text.Trim() != string.Empty)
        {
            dTSEDateRange        = txtDateRange.Text.Trim();
            sWeekID              = DateTimeExtension.CurrentWeekwithYear(Convert.ToDateTime(txtDateRange.Text));
            lblSelectedWeek.Text = DateTimeExtension.GetFormatWeekForGivenWeekID(sWeekID);
        }

        if (drpsApproved.Text.Trim() != string.Empty)
        {
            sApproved = drpsApproved.Text.Trim();
            lblApprovedStatus.Text = sApproved.ToString();
        }

        BusinessLogic bl = new BusinessLogic(sDataSource);

        bl.GetEmployeeMangerName(empNO, out empName, managerID, out managerName);
        lblEmployeeName.Text = empName;
        lblArroverName.Text  = managerName;

        if (bl.IsManagerForThisEmployee(empNO, managerID))
        {
            DataSet ds = bl.generateTSEReportDSNew(sWeekID, empNO, managerID, sApproved, sDataSource);
            gvTSE.DataSource = ds;
            gvTSE.DataBind();

            ExportToExcel();
        }
        else
        {
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Selected Employee is not reporting to this Approver. Report cannot be generated.');", true);
        }
    }
Beispiel #2
0
    protected void btnGenerateReport_Click(object sender, EventArgs e)
    {
        sDataSource = System.Configuration.ConfigurationManager.ConnectionStrings[Request.Cookies["Company"].Value].ToString();

        int    empNO         = 0;
        int    managerID     = 0;
        string dTSEDateRange = string.Empty;
        string sApproved     = string.Empty;
        string sWeekID       = string.Empty;

        if (ddlEmployee.Text.Trim() != string.Empty)
        {
            empNO = Convert.ToInt32(ddlEmployee.Text.Trim());
            lblEmployeeNumber.Text = empNO.ToString();
        }

        if (ddlApprover.Text.Trim() != string.Empty)
        {
            managerID = Convert.ToInt32(ddlApprover.Text.Trim());
        }

        if (txtDateRange.Text.Trim() != string.Empty)
        {
            dTSEDateRange        = txtDateRange.Text.Trim();
            sWeekID              = DateTimeExtension.CurrentWeekwithYear(Convert.ToDateTime(dTSEDateRange));
            lblSelectedWeek.Text = dTSEDateRange.ToString();
        }

        if (drpsApproved.Text.Trim() != string.Empty)
        {
            sApproved = drpsApproved.Text.Trim();
            lblApprovedStatus.Text = sApproved.ToString();
        }

        div1.Visible    = true;
        divmain.Visible = false;

        BusinessLogic bl = new BusinessLogic(sDataSource);

        if (bl.IsManagerForThisEmployee(empNO, managerID))
        {
            Response.Write("<script language='javascript'> window.open('TimeSheetReports1.aspx?empNO=" + empNO + "&sApproved=" + sApproved + "&smanagerID= " + managerID + "&sWeekID=" + sWeekID + " ' , 'window','height=700,width=1000,left=172,top=10,toolbar=yes,scrollbars=yes,resizable=yes');</script>");
        }
        else
        {
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Selected Employee is not reporting to this Approver. Report cannot be generated.');", true);
        }
    }