Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["User"] == null) Response.Redirect("Default.aspx");

        Display disp = new Display();
        Date dt = new Date();
        SAPDB db = new SAPDB();
        SQLDB sql = new SQLDB();
        PeriodDB perdb = new PeriodDB();

        Person user = (Person)Session["User"];

        //List<Role> rol = user.Roles;
        //foreach (Role r in rol)
        //    Response.Write(r.RoleID + " = " + r.RoleName);

        if (!IsPostBack)
        {
            fillMonths();
            if (Request.QueryString["data"] == null)
                period.SelectedValue = dt.getMonthToday();
        }

        year = period.SelectedItem.Text.Substring(period.SelectedItem.Text.Length - 4);
        month = period.SelectedItem.Value;

        string fio = "";
        string tab_number = "";
        string post = "";
        check = false;
        closed = false;

        count_days = dt.getCountDays(Convert.ToInt32(month), Convert.ToInt32(year));

        if (Request.QueryString["type"] != null) role = Request.QueryString["type"].ToString();

        Period per = perdb.getPeriod(Convert.ToInt32(month), Convert.ToInt32(year));

        if (per.IsClosed == 1)
        {
            lbStatus.Text = "������";
            Traffic.Text = "<img alt='' src='App_Resources/red.bmp' style='position:relative; top:4px;' />";
            closed = true;
        }
        else Traffic.Text = "<img alt='' src='App_Resources/green.bmp' style='position:relative; top:4px;' />";

        if (Request.QueryString["data"] != null)
        {
            EncryptedQueryString QueryString = new EncryptedQueryString(Request.QueryString["data"]);
            if (QueryString["fio"] != null) fio = QueryString["fio"];
            if (QueryString["tab"] != null) tab_number = QueryString["tab"];
            if (QueryString["post"] != null) post = QueryString["post"];
            if (QueryString["role"] != null) role = QueryString["role"];
            if (QueryString["check"] != null) check = true;
            if (!QueryString["month"].Equals(period.SelectedItem.Value))
            {
                fio = "";
                tab_number = "";
                post = "";
                check = false;
            }
        }

        //Response.Write(month);

        //Response.Write("fio=" + fio + "tab=" + tab_number + " - " + month + "<br>");
        //Response.Write(post + "<br>");

        string start_date = dt.getSAPStartPeriodDate(month, year);
        string end_date = dt.getSAPEndPeriodDate(month, year);

        StartDateOfPeriod = start_date;
        EndDateOfPeriod = end_date;
        //Response.Write(start_date + end_date);

        Label lb = new Label();
        lb.Text = disp.DisplayDaysTabel(count_days, 18);
        days.Controls.Add(lb);

        //Response.Write(start_date + end_date);
        //Period period_time = perdb.getPeriod(Convert.ToInt32(month), Convert.ToInt32(year));

        setButtons(role);

        //Response.Write(start_date + "-" + end_date + "<br>");

        this.employees = null;/// db.getEmployeeList(start_date, end_date, user.TabNum, this.role);
        EmployeeList emp_list = new EmployeeList();
        List<Post> post_list = null;/// pl.getPosts(db.getPostList(start_date, end_date, user.TabNum, this.role));
        if (post_list != null)
        {
            fillPosts(post_list);
        }
        else
        {
            ListItem li = new ListItem("�������� ���������");
            ddl_post.Items.Add(li);
        }

        /*if (post != "")
        {
            if (post != "���")
            {
                EmployeeList empl = new EmployeeList();
               // this.employees = empl.getEmployeesOnCurrentPost(post, employees);

            }
        }

        if (fio != "")
        {
            EmployeeList emp_fio = new EmployeeList();
            this.employees = emp_fio.getEmployeesByFIO(fio, employees);
        }

        if (tab_number != "")
        {
            EmployeeList emp_tab = new EmployeeList();
            this.employees = emp_tab.getEmployeesByTab(tab_number, employees);
        }*/

        if (check)
        {
            EmployeeList emp_check = new EmployeeList();
            /////this.employees = emp_check.getWrongCheckedEmployees(employees, count_days, hours, overhours);
        }

        if (employees != null)
        {

            DepartmentList department_list = new DepartmentList();
            List<Department> departments = department_list.getDepartments(employees);

            foreach (Department dep in departments)
            {

                Label depart = new Label();
                depart.Text = disp.DisplayDepartmentName(dep.DepartmentName, dep.DepartmentID, StartDateOfPeriod);
                content.Controls.Add(depart);

                Label lbEmps = new Label();
                lbEmps.Text = "<div  id='" + dep.DepartmentID + "' style='display:none'>";

                // �������� ���� �������� ��� �������� ��������
                /*EmployeeList emp_list = new EmployeeList();
                List<Employee> emps = emp_list.getEmployeesOfDepartment(dep.DepartmentID, employees);
                EmployeeComparerByPostASC cmpByPostASC = new EmployeeComparerByPostASC();
                emps.Sort(cmpByPostASC);
                //for (int j = 0; j < 100; j++)
                foreach (Employee em in emps)
                {
                    lbEmps.Text += "<table cellpadding='0' cellspacing='0' border='0' class='employee'><tr><td class='main_info_left_no'>&nbsp</td><td class='employee_post'>" + em.Post + "</td><td class='employee_id'>" + em.EmployeeID + "</td><td class='employee_name'><img src='App_Resources/person.gif' style='cursor: hand; cursor: pointer;'>&nbsp<span style='cursor: hand; cursor: pointer;'  onclick='window.open(\"" + getCardUrl(em.EmployeeID) +"\",\"displayWindow\",\"menubar=no,width=800,height=600,resizable=yes,scrollbars=yes\")'>" + em.FullName + "</span></td><td class='employee_grid_line_center'>&nbsp;</td><td>" + disp.DisplaySchedules(count_days, 18, em.EmployeeID, dep.DepartmentID, hours, overhours, em.Schedule, em.ScheduleDeflection, role, check, closed) + "</td><td class='main_info_right_no'></td></tr></table>";

                }*/
                lbEmps.Text += "</div>";
                content.Controls.Add(lbEmps);

            }

        }

        // ajax �� �������� ������ ����������� ������������� �������������
        string cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "ClientCallback", "context");
        string func_name = "FillEmployeesCallback";
        string cbScript = "function " + func_name + "(arg, context)" + "{" + cbReference + ";" + "}";
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), func_name, cbScript, true);
    }