Beispiel #1
0
        [Test] //ExSkip
        public void CustomDataSourceRoot()
        {
            // Create a document with two mail merge regions named "Washington" and "Seattle".
            string[] mailMergeRegions = { "Vancouver", "Seattle" };
            Document doc = CreateSourceDocumentWithMailMergeRegions(mailMergeRegions);

            // Create two data sources for the mail merge.
            EmployeeList employeesWashingtonBranch = new EmployeeList();

            employeesWashingtonBranch.Add(new Employee("John Doe", "Sales"));
            employeesWashingtonBranch.Add(new Employee("Jane Doe", "Management"));

            EmployeeList employeesSeattleBranch = new EmployeeList();

            employeesSeattleBranch.Add(new Employee("John Cardholder", "Management"));
            employeesSeattleBranch.Add(new Employee("Joe Bloggs", "Sales"));

            // Register our data sources by name in a data source root.
            //  If we are about to use this data source root in a mail merge with regions,
            // each source's registered name must match the name of an existing mail merge region in the mail merge source document.
            DataSourceRoot sourceRoot = new DataSourceRoot();

            sourceRoot.RegisterSource(mailMergeRegions[0], new EmployeeListMailMergeSource(employeesWashingtonBranch));
            sourceRoot.RegisterSource(mailMergeRegions[1], new EmployeeListMailMergeSource(employeesSeattleBranch));

            // Since we have consecutive mail merge regions, we would normally have to perform two mail merges.
            // However, one mail merge source with a data root can fill in multiple regions
            // if the root contains tables with corresponding names/column names.
            doc.MailMerge.ExecuteWithRegions(sourceRoot);

            doc.Save(ArtifactsDir + "MailMergeCustom.CustomDataSourceRoot.docx");
            TestCustomDataSourceRoot(mailMergeRegions, sourceRoot, new Document(ArtifactsDir + "MailMergeCustom.CustomDataSourceRoot.docx")); //ExSkip
        }
        public override Task <EmployeeList> GetAll(Empty empty, ServerCallContext context)
        {
            EmployeeList pl = new EmployeeList();

            pl.Employee.AddRange(_employee);
            return(Task.FromResult(pl));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["employeeToView"] != null)
                {
                    //this must be an edit
                    //set formview as edit mode only

                    // display the account to be edited
                    Employee     employeeToBeEdited = Session["employeeToView"] as Employee;
                    EmployeeList employeeList       = new EmployeeList();
                    employeeList.Add(employeeToBeEdited);
                    fViewEmployee.ChangeMode(FormViewMode.Edit);
                    fViewEmployee.DataSource = employeeList;
                    fViewEmployee.DataBind();

                    //clear the session["accountToView"]
                    Session["employeeToView"] = null;
                }

                else
                {
                    //create a new employee
                }
            }
        }
Beispiel #4
0
        [Test] //ExSkip
        public void MailMergeCustomDataSourceRoot()
        {
            // Create a document with two mail merge regions named "Washington" and "Seattle"
            Document doc = CreateSourceDocumentWithMailMergeRegions(new string[] { "Washington", "Seattle" });

            // Create two data sources
            EmployeeList employeesWashingtonBranch = new EmployeeList();

            employeesWashingtonBranch.Add(new Employee("John Doe", "Sales"));
            employeesWashingtonBranch.Add(new Employee("Jane Doe", "Management"));

            EmployeeList employeesSeattleBranch = new EmployeeList();

            employeesSeattleBranch.Add(new Employee("John Cardholder", "Management"));
            employeesSeattleBranch.Add(new Employee("Joe Bloggs", "Sales"));

            // Register our data sources by name in a data source root
            DataSourceRoot sourceRoot = new DataSourceRoot();

            sourceRoot.RegisterSource("Washington", new EmployeeListMailMergeSource(employeesWashingtonBranch));
            sourceRoot.RegisterSource("Seattle", new EmployeeListMailMergeSource(employeesSeattleBranch));

            // Since we have consecutive mail merge regions, we would normally have to perform two mail merges
            // However, one mail merge source data root call every relevant data source and merge automatically
            doc.MailMerge.ExecuteWithRegions(sourceRoot);

            doc.Save(ArtifactsDir + "MailMerge.MailMergeCustomDataSourceRoot.docx");
        }
        private void BindData()
        {
            EmployeeBLL EmployeeBL             = new EmployeeBLL(connectionString);
            List <EmployeeViewModel> employees = EmployeeBL.GetEmployeeInventory();

            string[]      date_notime        = new string[3];
            List <string> employees_in_modal = new List <string>();

            foreach (EmployeeViewModel element in employees)
            {
                date_notime       = element.BirthDate.Split(' ');
                element.BirthDate = date_notime[0];
                date_notime       = element.StartDate.Split(' ');
                element.StartDate = date_notime[0];
                if (!String.IsNullOrEmpty(element.EndDate))
                {
                    date_notime     = element.EndDate.Split(' ');
                    element.EndDate = date_notime[0];
                }
                else
                {
                    employees_in_modal.Add(element.Name);
                }
            }

            TerminateEmployeeList.DataSource = employees_in_modal;
            TerminateEmployeeList.DataBind();

            EmployeeList.DataSource = employees;
            EmployeeList.DataBind();
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            var employees = new EmployeeList();

            var employee = default(Employee);
            employee = new Employee();
            employee.Name = "Akira Sugiura";
            employee.Id = employees.Count + 1;
            employees.Add(employee);

            employee = new Employee();
            employee.Name = "Yusuke Fujiwara";
            employee.Id = employees.Count + 1;
            employees.Add(employee);

            employee = new Employee();
            employee.Name = "Takahiro Nagao";
            employee.Id = employees.Count + 1;
            employees.Add(employee);

            foreach (IEmployee _employee in employees)
            {
                Console.WriteLine(string.Format("Employee{0:d2}: {1}", _employee.Id, _employee.Name));
            }

            Console.ReadLine();
        }
        protected void bind(string sortExpression)
        {
            sortExpression = sortExpression.Replace("Ascending", "ASC");

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                con.Open();

                using (SqlDataAdapter dAd = new SqlDataAdapter("AireSpringEmployees_GetAll", con))
                {
                    DataTable dTable = new DataTable();

                    dAd.Fill(dTable);

                    dTable.DefaultView.Sort = sortExpression;

                    EmployeeList.DataSource = dTable;

                    EmployeeList.DataBind();
                }

                Session.Clear();

                con.Close();
            }
        }
 public bool AddNewEmployeeToDb(string title, string firstName, string middleName, string lastName,
                                string phoneNumber, string email, Address personalAddress,
                                int employeeNumber, DateTime dateOfBirth, string ppsn, double wage, int employeeCategory,
                                int employeeCardNumber, DateTime hireDate, string photo)
 {
     try
     {
         int maxId = 0;
         // need some code to avoid dulicate usernames
         // maybe add some logic (busiess rules) about password policy
         //      IUser user = new User(name, password, userType); // Construct a User Object
         foreach (Employee employee in EmployeeList)
         {
             if (employee.employeeNumber > maxId)
             {
                 maxId = employee.employeeNumber;
             }
         }
         IEmployee theEmployee = EmployeeFactory.GetEmployee(title, firstName, middleName, lastName, phoneNumber,
                                                             email, personalAddress, employeeNumber, dateOfBirth, ppsn, wage, employeeCategory,
                                                             employeeCardNumber, hireDate, photo);
         // Using a Factory to create the user entity object. ie seperating object creation from business logic
         EmployeeList.Add(theEmployee);             // Add a reference to the newly created object to the Models UserList
         DataLayer.AddNewEmployeeToDb(theEmployee); //Gets the DataLayer to add the new user to the DB.
         return(true);
     }
     catch (System.Exception excep)
     {
         return(false);
     }
 }
 public View()
 {
     EmployeeList = new EmployeeList()
     {
         List = { new Employee("Alex", "Z"), new Employee("Alex", "K") }
     };
 }
Beispiel #10
0
        public IHttpActionResult PutEmployeeList(int id, EmployeeList employeeList)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employeeList.EmployeeId)
            {
                return(BadRequest());
            }

            db.Entry(employeeList).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeListExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #11
0
        public void EditContactDetails()
        {
            // Employee data
            #region
            string eeName      = "Test Ess";
            string addr1       = "1060 West Addison";
            string addr2       = "Unit 200A";
            string city        = "Chicago";
            string state       = "Illinois";
            string zip         = "60613";
            string country     = "United States";
            string homePhone   = "773-388-8270";
            string mobilePhone = "773-380-2222";
            string workPhone   = "773-388-8271";
            string workEmail   = "*****@*****.**";
            string otherEmail  = "*****@*****.**";
            #endregion

            Home.GoTo();
            Home.LoginAsAdmin();

            Menu.PIM.EmployeeList.GoTo();
            EmployeeList.SearchForEmployee(eeName);
            Employee.EditContactDetails(EmployeeList.SelectEmployeeInTableById(), addr1: addr1, addr2: addr2, city: city, state: state, zip: zip, country: country,
                                        homePhone: homePhone, mobilePhone: mobilePhone, workPhone: workPhone, workEmail: workEmail, otherEmail: otherEmail);

            Assert.IsTrue(Employee.ContactCorrectlyAdded(addr1, addr2, city, state, zip, country, homePhone, mobilePhone, workPhone, workEmail, otherEmail), "Contact Details were not added successfully.");


            Home.Logout();
        }
Beispiel #12
0
        public async void ExecuteLoadEmployeeCommand()

        {
            try

            {
                EmployeeList.Clear();

                var employees = await DataStoreEmp.GetAllAsync();

                foreach (var item in employees)

                {
                    EmployeeList.Add(item);
                }

                int nb = EmployeeList.Count;
            }

            catch (Exception ex)

            {
                Debug.WriteLine(ex);
            }
        }
Beispiel #13
0
        public ActionResult ExpressOffice()
        {
            TabModels viewModel = new TabModels();

            try
            {
                DataMgr myDataMgr = new DataMgr("hi", "hi");

                var                myData      = myDataMgr.getCEXPOffice();
                EmployeeList       myEmpList   = new EmployeeList(myData);
                PrintPreviewModels drugScreens = new PrintPreviewModels();
                foreach (Employee emp in myEmpList)
                {
                    drugScreens.DrugPool.Add(new DrugScreen
                    {
                        ID         = emp.EmpID,
                        FName      = emp.FName,
                        LName      = emp.LName,
                        MI         = emp.MI,
                        Drug       = emp.Drug,
                        Alcohol    = emp.Alcohol,
                        Substitute = emp.Substitute
                    });
                }
                viewModel.TotalActiveDrivers = myData.Rows.Count;
                viewModel.empList            = drugScreens;
            }
            catch (Exception ex)
            {
                return(View(viewModel));
            }

            return(View(viewModel));
        }
Beispiel #14
0
        public void AddJobToExistingEE()
        {
            string eeName = "Test Ess";

            // Job data
            #region
            string jobTitle    = "IT Manager";
            string empStatus   = "Full-Time Permanent";
            string jobCat      = "Officials and Managers";
            string joinDate    = "2015-01-31";
            string subUnit     = "IT";
            string location    = "HQ - CA, USA";
            string ecStartDate = "";
            string ecEndDate   = "";
            #endregion

            Home.GoTo();
            Home.LoginAsAdmin();

            Menu.PIM.EmployeeList.GoTo();
            EmployeeList.SearchForEmployee(eeName);
            Employee.AddJob(EmployeeList.SelectEmployeeInTableById(), jobTitle, empStatus, jobCat, joinDate, subUnit, location, ecStartDate, ecEndDate);
            Assert.IsTrue(Job.JobCorrectlyAdded(jobTitle, empStatus, jobCat, joinDate, subUnit, location, ecStartDate, ecEndDate), "Job was not added successfully.");

            Home.Logout();
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            employeeData = new EmployeeList();

            Console.WriteLine("Payroll process started at {0}", DateTime.Now);
            var sw = Stopwatch.StartNew();

            // Methods to call
            // Ex1Task1_ParallelizeLongRunningService();
            // Ex1Task1_UseParallelForMethod();
            // Ex1Task1_StandardForEach();
            // Ex1Task1_ParallelForEach();
            // Ex1Task1_WalkTree();
            // Ex2Task1_NativeParallelTasks();
            // Ex2Task2_WaitHandling();
            // Ex2Task2_WaitHandlingWaitAll();
            // Ex2Task3_TaskIsCompleted();
            // Ex2Task4_ContinueWith();
            // Ex3Task1_TaskReturnValue();
            // Ex4Task1_PLINQ();
            // Ex4Task1_PLINQAsParallel();
            // Ex4Task2_Extensions();
            // Ex4Task2_ConvertToParallelExtensions();
            Ex4Task3_PLINQComprehensionSyntax();

            Console.WriteLine("Payroll finished at {0} and took {1}",
                                  DateTime.Now, sw.Elapsed.TotalSeconds);
            Console.WriteLine();
            Console.ReadLine();
        }
Beispiel #16
0
    public static void Main()
    {
        EmployeeList employeeList = new EmployeeList();

        employeeList.AddEmployee(new Employee("A", "AA"));
        employeeList.AddEmployee(new Employee("B", "BB"));
        employeeList.AddEmployee(new Employee("C", "CC"));


        Console.WriteLine("Enumerate using default iterator:");
        foreach (Employee member in employeeList)
        {
            Console.WriteLine("  " + member.ToString());
        }

        Console.WriteLine("Enumerate using the FirstTwo iterator:");
        foreach (Employee member in employeeList.FirstTwo)
        {
            Console.WriteLine("  " + member.ToString());
        }

        Console.WriteLine("Enumerate using the Reverse iterator:");
        foreach (Employee member in employeeList.Reverse)
        {
            Console.WriteLine("  " + member.ToString());
        }
    }
        public void VerifyESSDashboardQuickLaunchApplyLeave()
        {
            #region
            string firstName          = "Olive";
            string middleName         = "Ann";
            string lastName           = "Smith";
            bool   createLoginDetails = true;
            string userName           = "******";
            string password           = "******";
            string statusEnabled      = "Enabled";

            string pageName = "Apply Leave";
            #endregion

            // Cretae an ESS user
            Home.GoTo();
            Home.LoginAsAdmin();
            Menu.PIM.EmployeeList.GoTo();
            EmployeeList.AddEmployeeViaButton(firstName, middleName, lastName, createLoginDetails, userName, password, statusEnabled);
            Home.Logout();

            // Login as ESS user
            //Home.GoTo();
            Home.Login(userName, password);

            Menu.Dashboard.GoTo();
            Dashboard.ESSDashboard.SelectApplyLeave();

            Assert.IsTrue(Dashboard.IsCorrectPage(pageName), "The Apply Leave link did not go to the expected screen!");

            Home.Logout();
        }
Beispiel #18
0
        public IActionResult Index()
        {
            var          client   = new EmployeeService.EmployeeServiceClient(channel);
            EmployeeList employee = client.GetAll(new Empty());

            return(View(employee));
        }
    public string GetCallbackResult()
    {
        //SAPDB db = new SAPDB();
        Display disp = new Display();
        //List<Employee> emps = db.getEmployeeListForCurrentDepartment(StartDateOfPeriod, EndDateOfPeriod, "00000050", "1", eventArgument);
        EmployeeList emp_list = new EmployeeList();
        List<Employee> emps = null;// emp_list.getEmployeesOfDepartment(eventArgument, employees);
        EmployeeComparerByPostASC cmpByPostASC = new EmployeeComparerByPostASC();
        emps.Sort(cmpByPostASC);
        string html = "";
        html += eventArgument;
        html += "||";
        //int k = 0;
        //for (int j = 0; j < 100; j++)
        /*foreach (Employee em in emps)
        {
            //k++;
            html += "<table cellpadding='0' cellspacing='0' border='0' class='employee'><tr><td class='employee_post'><div style='width: 105px; height: 80px; overflow: hidden;'>" + em.Post + "</div></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) + "\",\"_blank\",\"menubar=no,width=800,height=600,resizable=yes,scrollbars=yes\")'>" + em.FullName + CheckRedundantEmployee(em) + "</span></td><td>" + disp.DisplaySchedules(count_days, 18, em, em.PostID, eventArgument, hours, overhours, em.Schedule, em.ScheduleDeflection, role, check, closed, false) + "</td></tr></table>";

        }
        */
        html += "||";

        DevDescriptionDB devDB = new DevDescriptionDB();
        List<DevDescription> devdescription = devDB.getDevDescription();
        html += "<table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td align='center' colspan='2'><b>����������� � SAP</b></td></tr>";

        foreach (DevDescription dev in devdescription)
            html += "<tr><td width='30px' align='center'><b>" + dev.Symbols + "</b></td><td>" + dev.Name + "</td></tr>";

        html += "</table>";

        return html;
    }
        private void employeeListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EmployeeList ob = new EmployeeList();

            ob.Show();
            this.Hide();
        }
Beispiel #21
0
        public static EmployeeList GetList()
        {
            EmployeeList   eList  = null;
            MyDBConnection myConn = new MyDBConnection();
            SqlConnection  conn   = new SqlConnection();
            SqlDataReader  dr;
            SqlCommand     cmd = null;
            string         sql = "Select * from AquaOne.dbo.Employee";

            try
            {
                // Open the connection
                conn = myConn.OpenDB();
                cmd  = new SqlCommand(sql, conn);

                dr = cmd.ExecuteReader();

                if (dr.HasRows)
                {
                    eList = new EmployeeList();
                    while (dr.Read())
                    {
                        eList.Add(FillDataRecord(dr));
                    }
                }
            }
            finally
            {
                cmd.Dispose();
                myConn.CloseDB(conn);
            }
            return(eList);
        }
        public EmployeeList GetEmployees(int pageIndex, int pageSize)
        {
            EmployeeInfo empInfo = new EmployeeInfo();
            EmployeeList empList = empInfo.GetEmployees(pageIndex, pageSize);

            return(empList);
        }
Beispiel #23
0
            public void EmployeeApiReturnsData()
            {
                var processedString = EmployeeList.Aggregate("", (current, employee)
                                                             => current + ($"ID: {employee.Id}\r\n" + $"Name: {employee.Name}\r\n" + $"Start Date: {employee.StartDate:dd/MM/yyyy}\r\n\r\n"));

                ProcessedCommand.Should().BeEquivalentTo(processedString);
            }
Beispiel #24
0
        // GET: api/Employee/5
        public EmployeeList Get(int fEmpId)
        {
            var q = from a in db.tEmployee
                    join p in db.tDepartment on a.fDepId equals p.fDepId
                    where a.fEmpId == fEmpId
                    select new
            {
                fEmpId   = a.fEmpId,
                fDepId   = a.fDepId,
                fName    = a.fName,
                fPhone   = a.fPhone,
                fDepName = p.fDepName
            };

            var item     = q.FirstOrDefault();
            var employee = new EmployeeList();

            employee.fEmpId   = item.fEmpId;
            employee.fDepId   = item.fDepId;
            employee.fName    = item.fName;
            employee.fPhone   = item.fPhone;
            employee.fDepName = item.fDepName;

            return(employee);
        }
        //
        #region GetAllEmployees
        public override async Task <EmployeeList> GetAllEmployees(Empty request, ServerCallContext context)
        {
            _logger.LogInformation("Display all employees");

            EmployeeList list = new EmployeeList();

            try
            {
                List <EmployeeModel> employeeList = new List <EmployeeModel>();

                var _employee = _context.Employees.ToList();

                foreach (var e in _employee)
                {
                    employeeList.Add(new EmployeeModel()
                    {
                        EmployeeId   = e.EmployeeId,
                        Surname      = e.Surname,
                        Name         = e.Name,
                        Gender       = e.Gender,
                        DepartmentId = (int)e.DepartmentId,
                    });
                }
                list.Items.AddRange(employeeList);
            }
            catch (Exception ex)
            {
                _logger.LogInformation(ex.ToString());
            }
            return(await Task.FromResult(list));
        }
        public void VerifyESSDashboardQuickLaunchElements()
        {
            #region
            string[] expectedData = new string[] { "Apply Leave", "My Leave", "My Timesheet" };

            string firstName          = "Karen";
            string middleName         = "Ann";
            string lastName           = "Smith";
            bool   createLoginDetails = true;
            string userName           = "******";
            string password           = "******";
            string statusEnabled      = "Enabled";

            #endregion
            // Cretae an ESS user
            Home.GoTo();
            Home.LoginAsAdmin();
            Menu.PIM.EmployeeList.GoTo();
            EmployeeList.AddEmployeeViaButton(firstName, middleName, lastName, createLoginDetails, userName, password, statusEnabled);
            Home.Logout();

            // Login as ESS user
            //Home.GoTo();
            Home.Login(userName, password);

            Menu.Dashboard.GoTo();

            Assert.IsTrue(Dashboard.ESSDashboard.HasCorrectQuickLaunchOptions(expectedData), "The ESS Dashboard is missing expected panels!");

            Home.Logout();
        }
Beispiel #27
0
        public EditEmployeeVM()
        {
            this.MessengerInstance.Register <ChangeSelectedEmployeeMessage>(this, message =>
            {
                EmployeeList    = message.EmployeeList;
                Employee        = message.Employee;
                DepartmentIndex = Departments.IndexOf(Departments.Select(department => department).Where(department => department.Name == Employee.Department.Name).FirstOrDefault());
            });

            EditEmployeeCommand      = new RelayCommand(EditEmployee, CanEditEmployee);
            CloseEditEmployeeCommand = new RelayCommand(CloseEditEmployee);

            using (var context = new Entities())
            {
                Departments = new ObservableCollection <DepartmentVM>(context.Departments.ToList().Select(department => new DepartmentVM(department)));
                Statuses    = new ObservableCollection <string>(context.EmployeeStatus.ToList().Select(status => status.Status));
            }

            MessengerInstance.Register <ChangePageMessage>(this, message =>
            {
                if (message.NextPageType == typeof(EmployeePage) && EmployeeList != null)
                {
                    EmployeeList.RefreshEmployees();
                }
            });
        }
Beispiel #28
0
        public ModelGetEmployeeList GetEmployeeList()
        {
            ModelGetEmployeeList obj = new ModelGetEmployeeList();

            List <EmployeeList> empList = new List <EmployeeList>();
            DataTable           dt      = new DataTable();

            string           q       = "select uid,fname,lname from nworksuser where _type='Admin' or _type='Admin_Employee';";
            MySqlCommand     cmd     = new MySqlCommand(q, conn);
            MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);;

            conn.Open();
            adapter.Fill(dt);
            conn.Close();

            foreach (DataRow row in dt.Rows)
            {
                EmployeeList employee = new EmployeeList();
                employee.uid   = row["uid"].ToString();
                employee.fname = row["fname"].ToString();
                employee.lname = row["lname"].ToString();

                empList.Add(employee);
            }

            obj.ServiceStatus = "Success";
            obj.EmpList       = empList;
            return(obj);
        }
Beispiel #29
0
        public MainWindow()
        {
            InitializeComponent();
            DataContext = new SignInViewModel();
            var window = Application.Current.MainWindow as ModernWindow;

            AdminList    = window?.MenuLinkGroups.ToList();
            EmployeeList = window?.MenuLinkGroups.ToList();
            SignInList   = window?.MenuLinkGroups.ToList();
            var toRemove1 = window?.MenuLinkGroups.ElementAt(4);
            var toRemove2 = window?.MenuLinkGroups.ElementAt(5);
            var toRemove3 = window?.MenuLinkGroups.ElementAt(6);

            AdminList?.Remove(toRemove3);
            EmployeeList?.Remove(toRemove1);
            EmployeeList?.Remove(toRemove2);
            EmployeeList?.Remove(toRemove3);
            SignInList?.Clear();
            SignInList?.Add(toRemove3);
            window?.MenuLinkGroups.Clear();
            if (SignInList == null)
            {
                return;
            }
            foreach (var item in SignInList)
            {
                window?.MenuLinkGroups.Add(item);
            }
        }
Beispiel #30
0
    public static void Main()
    {
        EmployeeList team = new EmployeeList();

        team.AddMember(new Employee("A", "AA", 4));
        team.AddMember(new Employee("B", "BB", 8));
        team.AddMember(new Employee("C", "CC", 8));

        EmployeeList clone = (EmployeeList)team.Clone();

        Console.WriteLine("Original EmployeeList:");
        Console.WriteLine(team);

        Console.WriteLine("Clone EmployeeList:");
        Console.WriteLine(clone);

        Console.WriteLine("*** Make a change to original team ***");
        team.EmployeeListMembers[0].Name  = "L";
        team.EmployeeListMembers[0].Title = "M";
        team.EmployeeListMembers[0].Age   = 4;

        Console.WriteLine("Original EmployeeList:");
        Console.WriteLine(team);

        Console.WriteLine("Clone EmployeeList:");
        Console.WriteLine(clone);
    }
        /// <summary>
        /// Retrieves list of Employee objects from SqlCommand, after database query
        /// number of rows retrieved and returned depends upon the rows field value
        /// </summary>
        /// <param name="cmd">The command object to use for query</param>
        /// <param name="rows">Number of rows to process</param>
        /// <returns>A list of Employee objects</returns>
        private EmployeeList GetList(SqlCommand cmd, long rows)
        {
            // Select multiple records
            SqlDataReader reader;
            long          result = SelectRecords(cmd, out reader);

            //Employee list
            EmployeeList list = new EmployeeList();

            using ( reader )
            {
                // Read rows until end of result or number of rows specified is reached
                while (reader.Read() && rows-- != 0)
                {
                    Employee employeeObject = new Employee();
                    FillObject(employeeObject, reader);

                    list.Add(employeeObject);
                }

                // Close the reader in order to receive output parameters
                // Output parameters are not available until reader is closed.
                reader.Close();
            }

            return(list);
        }
        public ActionResult One_Five()
        {
            using (var db = new NorthwindEntities())
            {
                var Q5Result = (from e in db.Employees
                                where e.Country.ToLower() == "uk"
                                select new { Fullname = e.TitleOfCourtesy + " " + e.FirstName + " " + e.LastName, e.City }).ToList();

                List <(string Fullname, string City)> EmployeeList =
                    new List <(string Fullname, string City)>();

                foreach (var item in Q5Result)
                {
                    var Employee = (
                        item.Fullname,
                        item.City
                        );

                    EmployeeList.Add(Employee);
                }

                ViewBag.Q5 = EmployeeList;
            }

            return(View());
        }
Beispiel #33
0
        public CollectionBindingTestPage()
        {
            InitializeComponent();
            List <Employee> list = new List <Employee>();

            list.Add(new Employee()
            {
                FirstName = "AEvgeny", SecondName = "Solovyov", Position = EmployeePosition.Manager
            });
            list.Add(new Employee()
            {
                FirstName = "ZWasia", SecondName = "Osbourne"
            });
            list.Add(new Employee()
            {
                FirstName = "CMichael", SecondName = "Smith"
            });
            list.Add(new Employee()
            {
                FirstName = "CMichael", SecondName = "Abboth", Position = EmployeePosition.Manager
            });
            list.Add(new Employee()
            {
                FirstName = "BWasia", SecondName = "Kovalev"
            });
            EmployeeList emplList = new EmployeeList()
            {
                List = list
            };

            this.DataContext = emplList;
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     el = new EmployeeList();
     if (!this.IsPostBack)
     {
         tableRefresh();
     }
 }
Beispiel #35
0
  static void Main() 
  {
    // Create an instance of CEO, a class derived from the C# proxy of the 
    // underlying C++ class. The calls to getName() and getPosition() are standard,
    // the call to getTitle() uses the director wrappers to call CEO.getPosition().

    CEO e = new CEO("Alice");
    Console.WriteLine( e.getName() + " is a " + e.getPosition() );
    Console.WriteLine( "Just call her \"" + e.getTitle() + "\"" );
    Console.WriteLine( "----------------------" );

    // Create a new EmployeeList instance.  This class does not have a C++
    // director wrapper, but can be used freely with other classes that do.

    using (EmployeeList list = new EmployeeList()) {

    // EmployeeList owns its items, so we must surrender ownership of objects we add.
    e.disownMemory();
    list.addEmployee(e);
    Console.WriteLine( "----------------------" );

    // Now we access the first four items in list (three are C++ objects that
    // EmployeeList's constructor adds, the last is our CEO). The virtual
    // methods of all these instances are treated the same. For items 0, 1, and
    // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls
    // getPosition which resolves in C#. The call to getPosition is
    // slightly different, however, because of the overridden getPosition() call, since
    // now the object reference has been "laundered" by passing through
    // EmployeeList as an Employee*. Previously, C# resolved the call
    // immediately in CEO, but now C# thinks the object is an instance of
    // class Employee. So the call passes through the
    // Employee proxy class and on to the C wrappers and C++ director,
    // eventually ending up back at the C# CEO implementation of getPosition().
    // The call to getTitle() for item 3 runs the C++ Employee::getTitle()
    // method, which in turn calls getPosition(). This virtual method call
    // passes down through the C++ director class to the C# implementation
    // in CEO. All this routing takes place transparently.

    Console.WriteLine( "(position, title) for items 0-3:" );

    Console.WriteLine( "  " + list.get_item(0).getPosition() + ", \"" + list.get_item(0).getTitle() + "\"" );
    Console.WriteLine( "  " + list.get_item(1).getPosition() + ", \"" + list.get_item(1).getTitle() + "\"" );
    Console.WriteLine( "  " + list.get_item(2).getPosition() + ", \"" + list.get_item(2).getTitle() + "\"" );
    Console.WriteLine( "  " + list.get_item(3).getPosition() + ", \"" + list.get_item(3).getTitle() + "\"" );
    Console.WriteLine( "----------------------" );

    // The using statement ensures the EmployeeList.Dispose() will be called, which will delete all the Employee*
    // items it contains. The last item is our CEO, which gets destroyed as well.
    }
    Console.WriteLine( "----------------------" );

    // All done.

    Console.WriteLine( "C# exit" );
  }
Beispiel #36
0
        static void Main(string[] args)
        {
            employeeData = new EmployeeList();

            Console.WriteLine("Payroll process started at {0}", DateTime.Now);
            var sw = Stopwatch.StartNew();

            // Methods to call
            // Ex1Task1_ParallelizeLongRunningService();
            // Ex1Task1_UseParallelForMethod();
            // Ex1Task1_StandardForEach();
            // Ex1Task1_ParallelForEach();
            Ex1Task1_WalkTree();

            Console.WriteLine("Payroll finished at {0} and took {1}",
                                  DateTime.Now, sw.Elapsed.TotalSeconds);
            Console.WriteLine();
            Console.ReadLine();
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Tag page
                // ... for non vacation managers
                EmployeeGateway employeeGatewayManager = new EmployeeGateway();

                int employeeIdNow = employeeGatewayManager.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"]));

                employeeGatewayManager.LoadByEmployeeId(employeeIdNow);

                if (employeeGatewayManager.GetIsVacationsManager(employeeIdNow))
                {
                    hdfIsVacationManager.Value = "True";
                }
                else
                {
                    hdfIsVacationManager.Value = "False";
                }

                // Security check
                //if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_VACATIONS_ADD"])))
                //{
                if (hdfIsVacationManager.Value == "False")
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }
                //}

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) && ((string)Request.QueryString["employee_id"] == null) && ((string)Request.QueryString["date_to_show"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in vacations_add.aspx");
                }

                // Tag page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfEmployeeId.Value = (string)Request.QueryString["employee_id"];

                Session.Remove("vacationsAddTDS");

                ViewState["date_to_show"] = (string)Request.QueryString["date_to_show"];
                DateTime dateToShow = DateTime.Parse((string)Request.QueryString["date_to_show"]);

                // Prepare initial data
                // ... For employee list

                EmployeeList employeeList = new EmployeeList();

                string employeeTypeNow = employeeGatewayManager.GetType(employeeIdNow);

                if (employeeTypeNow.Contains("CA"))
                {
                    employeeList.LoadBySalariedEmployeeTypeAndAddItem(1, "CA", -1, "(All)");
                }
                else
                {
                    employeeList.LoadBySalariedEmployeeTypeAndAddItem(1, "US", -1, "(All)");
                }

                DropDownList ddlVacationsFor = (DropDownList)tkrpbLeftMenuAllVacations.FindItemByValue("nbVacationsForDDL").FindControl("ddlVacationsFor");
                ddlVacationsFor.DataSource = employeeList.Table;
                ddlVacationsFor.DataValueField = "EmployeeID";
                ddlVacationsFor.DataTextField = "FullName";
                ddlVacationsFor.DataBind();
                ddlVacationsFor.SelectedValue = Session["ddlVacationsForSelectedValue"].ToString();

                // ... For employee ddl
                ddlEmployee.DataSource = employeeList.Table;
                ddlEmployee.DataValueField = "EmployeeID";
                ddlEmployee.DataTextField = "FullName";
                ddlEmployee.DataBind();

                vacationsAddTDS = new VacationsAddTDS();
                vacationDaysInformation = new VacationsAddTDS.DaysInformationDataTable();

                // If there is a selected employee
                if (hdfEmployeeId.Value != "-1")
                {
                    int companyId = Int32.Parse(hdfCompanyId.Value);
                    int employeeId = Int32.Parse(hdfEmployeeId.Value);

                    // ... Verify basic information
                    VacationsAddBasicInformationGateway vacationsAddBasicInformationGateway = new VacationsAddBasicInformationGateway(vacationsAddTDS);
                    vacationsAddBasicInformationGateway.LoadByEmployeeIdYear(employeeId, dateToShow.Year, companyId);

                    if (vacationsAddBasicInformationGateway.Table.Rows.Count == 0)
                    {
                        Response.Redirect("./../../error_page.aspx?error=" + "The team member don't have total paid day vacations defined in the system. Contact your system administrator.");
                    }
                    else
                    {
                        LoadData(employeeId, dateToShow.Year);

                        // ... Load non working days
                        EmployeeGateway employeeGateway = new EmployeeGateway();
                        employeeGateway.LoadByEmployeeId(employeeId);

                        string employeeType = employeeGateway.GetType(employeeId);
                        int companyLevelId = 3; //USA

                        if (employeeType.Contains("CA"))
                        {
                            companyLevelId = 2;//Canada
                        }

                        VacationsAddDaysInformation vacationsAddDaysInformation = new VacationsAddDaysInformation(vacationsAddTDS);
                        //vacationsAddDaysInformation.LoadNonWorkingDaysByCompanyLevelId(companyLevelId, companyId);

                        // ... Load previews vacations
                        //vacationsAddDaysInformation.LoadPreviousVacations(employeeId, companyId);
                        vacationsAddDaysInformation.LoadDataForVacationsAdd(companyLevelId, employeeId, companyId);
                    }
                }

                ViewState["employee_id"] = hdfEmployeeId.Value;

                Session["vacationsAddTDS"] = vacationsAddTDS;
                Session["vacationDaysInformation"] = vacationsAddTDS.DaysInformation;

                Page.DataBind();
            }
            else
            {
                vacationsAddTDS = (VacationsAddTDS)Session["vacationsAddTDS"];
                vacationDaysInformation = (VacationsAddTDS.DaysInformationDataTable)Session["vacationDaysInformation"];

                hdfEmployeeId.Value = ViewState["employee_id"].ToString();
            }
        }
        private void LoadGeneralData()
        {
            // ... for geographical location
            hdfCountryId.DataBind();
            if (hdfCountryId.Value != "")
            {
                CountryGateway countryGateway = new CountryGateway();
                countryGateway.LoadByCountryId(Int64.Parse(hdfCountryId.Value));
                tbxCountry.Text = countryGateway.GetName(Int64.Parse(hdfCountryId.Value));
            }
            else
            {
                tbxCountry.Text = "";
            }

            hdfProvinceStateId.DataBind();
            if (hdfProvinceStateId.Value != "")
            {
                ProvinceGateway provinceGateway = new ProvinceGateway();
                provinceGateway.LoadByProvinceId(Int64.Parse(hdfProvinceStateId.Value));
                tbxProvinceState.Text = provinceGateway.GetName(Int64.Parse(hdfProvinceStateId.Value));
            }
            else
            {
                tbxProvinceState.Text = "";
            }

            hdfCountyId.DataBind();
            if (hdfCountyId.Value != "")
            {
                CountyGateway countyGateway = new CountyGateway();
                countyGateway.LoadByCountyId(Int64.Parse(hdfCountyId.Value));
                tbxCounty.Text = countyGateway.GetName(Int64.Parse(hdfCountyId.Value));
            }
            else
            {
                tbxCounty.Text = "";
            }

            hdfCityId.DataBind();
            if (hdfCityId.Value != "")
            {
                CityGateway cityGateway = new CityGateway();
                cityGateway.LoadByCityId(Int64.Parse(hdfCityId.Value));
                tbxCity.Text = cityGateway.GetName(Int64.Parse(hdfCityId.Value));
            }
            else
            {
                tbxCity.Text = "";
            }

            // ... for project
            ProjectGateway projectGateway = new ProjectGateway(projectTDS);
            int currentCompanyId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString()));
            hdfClientId.Value = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value)).ToString();

            // ... for client
            int companyId = Int32.Parse(hdfCompanyId.Value);
            CompaniesGateway companiesGateway = new CompaniesGateway();
            companiesGateway.LoadAllByCompaniesId(currentCompanyId, companyId);

            if (projectTDS.LFS_PROJECT.Rows.Count > 0)
            {
                tkrdpStartDate.DataBind();
                tkrdpEndDate.DataBind();
                tkrdpProposalDate.DataBind();
                tbxProjectNumber.DataBind();
                tbxName.DataBind();
                tbxDescription.DataBind();
                tbxClientName.Text = companiesGateway.GetName(projectGateway.GetClientID(int.Parse(hdfProjectId.Value)));
                tbxClientProjectNumber.DataBind();

                // ... ... for primary contact
                ContactsList contactList = new ContactsList();
                contactList.LoadAllAndAddItemByCompaniesId(-1, " ", projectGateway.GetClientID(int.Parse(hdfProjectId.Value)), companyId);
                ddlClientPrimaryContactId.DataSource = contactList.Table;
                ddlClientPrimaryContactId.DataValueField = "CONTACTS_ID";
                ddlClientPrimaryContactId.DataTextField = "Name";

                if (projectGateway.GetClientPrimaryContactID(int.Parse(hdfProjectId.Value)).HasValue)
                {
                    ddlClientPrimaryContactId.SelectedValue = projectGateway.GetClientPrimaryContactID(int.Parse(hdfProjectId.Value)).ToString();
                }
                else
                {
                    ddlClientPrimaryContactId.SelectedValue = "-1";
                }

                ddlClientPrimaryContactId.DataBind();

                // ... ... for secondary contact
                ddlClientSecondaryContactId.DataSource = contactList.Table;
                ddlClientSecondaryContactId.DataValueField = "CONTACTS_ID";
                ddlClientSecondaryContactId.DataTextField = "Name";

                if (projectGateway.GetClientSecondaryContactID(int.Parse(hdfProjectId.Value)).HasValue)
                {
                    ddlClientSecondaryContactId.SelectedValue = projectGateway.GetClientSecondaryContactID(int.Parse(hdfProjectId.Value)).ToString();
                }
                else
                {
                    ddlClientSecondaryContactId.SelectedValue = "-1";
                }

                ddlClientSecondaryContactId.DataBind();

                // ... for resources
                // ...  ... for project lead
                EmployeeList employeeList = new EmployeeList();
                employeeList.LoadAndAddItem(-1, " ");
                ddlProjectLeadId.DataSource = employeeList.Table;
                ddlProjectLeadId.DataValueField = "EmployeeID";
                ddlProjectLeadId.DataTextField = "FullName";
                ddlProjectLeadId.SelectedValue = (projectGateway.GetProjectLeadID(int.Parse(hdfProjectId.Value)).HasValue) ? ((int)projectGateway.GetProjectLeadID(int.Parse(hdfProjectId.Value))).ToString() : "-1";
                ddlProjectLeadId.DataBind();

                // ... ... for salesman
                SalesmanListGateway salesmanListGateway = new SalesmanListGateway(new DataSet());
                salesmanListGateway.Load();
                ddlSalesmanId.DataSource = salesmanListGateway.Table;
                ddlSalesmanId.DataValueField = "SalesmanID";
                ddlSalesmanId.DataTextField = "FullName";
                ddlSalesmanId.SelectedValue = ((int)projectGateway.GetSalesmanID(int.Parse(hdfProjectId.Value))).ToString();
                ddlSalesmanId.DataBind();

                // ... ... for Pricing
                if (projectGateway.GetProjectType(int.Parse(hdfProjectId.Value)) == "Ballpark")
                {
                    ProjectSaleBillingPricingGateway projectSaleBillingPricingGateway = new ProjectSaleBillingPricingGateway(projectTDS);

                    if (projectSaleBillingPricingGateway.Table.Rows.Count > 0)
                    {
                        tbxBillPrice.DataBind();
                        ddlBillMoney.DataBind();
                    }
                    else
                    {
                        if (projectGateway.GetCountryID(int.Parse(hdfProjectId.Value)) == 1)
                        {
                            ddlBillMoney.SelectedValue = "CAD";
                        }
                        else
                        {
                            ddlBillMoney.SelectedValue = "USD";
                        }
                    }
                }
            }

            cbxFairWageApplies.DataBind();

            // Data for unit budget tab
            ProjectNavigatorProjectUnitsBudgetGateway projectNavigatorProjectUnitsBudgetGateway = new ProjectNavigatorProjectUnitsBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectUnitsBudgetGateway.Table.Rows.Count > 0)
            {
                tbxUnitsBudget.Text = projectNavigatorProjectUnitsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value)).ToString("n2");
            }

            // Data for materials budget tab
            ProjectNavigatorProjectMaterialsBudgetGateway projectNavigatorProjectMaterialsBudgetGateway = new ProjectNavigatorProjectMaterialsBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectMaterialsBudgetGateway.Table.Rows.Count > 0)
            {
                tbxMaterialsBudget.Text = projectNavigatorProjectMaterialsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value)).ToString("n2");
            }

            // Data for subcontractors budget tab
            ProjectNavigatorProjectSubcontractorsBudgetGateway projectNavigatorProjectSubcontractorsBudgetGateway = new ProjectNavigatorProjectSubcontractorsBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectSubcontractorsBudgetGateway.Table.Rows.Count > 0)
            {
                tbxSubcontractorsBudget.Text = projectNavigatorProjectSubcontractorsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2");
            }

            // Data for hotels budget tab
            ProjectNavigatorProjectHotelsBudgetGateway projectNavigatorProjectHotelsBudgetGateway = new ProjectNavigatorProjectHotelsBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectHotelsBudgetGateway.Table.Rows.Count > 0)
            {
                tbxHotelsBudget.Text = projectNavigatorProjectHotelsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2");
            }

            // Data for bondings budget tab
            ProjectNavigatorProjectBondingsBudgetGateway projectNavigatorProjectBondingsBudgetGateway = new ProjectNavigatorProjectBondingsBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectBondingsBudgetGateway.Table.Rows.Count > 0)
            {
                tbxBondingsBudget.Text = projectNavigatorProjectBondingsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2");
            }

            // Data for insurances budget tab
            ProjectNavigatorProjectInsurancesBudgetGateway projectNavigatorProjectInsurancesBudgetGateway = new ProjectNavigatorProjectInsurancesBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectInsurancesBudgetGateway.Table.Rows.Count > 0)
            {
                tbxInsurancesBudget.Text = projectNavigatorProjectInsurancesBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2");
            }

            CalculateTotalBudget();
        }
    // получаем часы переработок - возвращается 0 - если у человека 0 часов переработок. 1 - если у человека есть ненулевое количество переработок, -1 - нет такого сотрудника
    public int insertOvertimeHoursToDB(string employee_id, string start_period, string begda, string endda, int count_days, int month, int year, string accountant_id, int period_id)
    {
        SQLDB db = new SQLDB();
        Date dt = new Date();

        int day = 1;

        EmployeeList emp_list = new EmployeeList();

        List<TimekeeperHours> current = emp_list.getEmployeesTimekeeperHours(employee_id, start_period, begda, endda);
        List<HRHours> hr_current = emp_list.getEmployeesHRHours(employee_id, start_period, begda, endda);
        List<Schedule> schedule = emp_list.getEmployeesSchedule(employee_id, start_period, begda, endda);
        List<ScheduleDeflection> dschedule = emp_list.getEmployeesScheduleDeflection(employee_id, start_period, begda, endda);

        decimal overhours_count = db.getOverhoursSum(employee_id, start_period, begda, endda);

        bool t13 = false;
        bool diversity = false;

        if (overhours_count == 0)
        {
            db.insertOverhoursToManagement(employee_id, start_period, begda, endda, dt.getDateToSQL(day, month, year), 0, accountant_id, period_id);
            return 0;
        }

        if (overhours_count <= 8) t13 = true;
        else diversity = true;

        // если кол-во переработок больше 8 часов, то используем эти переменные
        decimal m111 = 0; // тип переработок M111 - сумма первых 2 часов переработок, кроме выходных
        decimal m122 = 0; // тип переработок M122 - сумма оставшихся часов и переработки в выходные и праздничные дни
        decimal m210 = 0; // тип переработок M210 - сумма только ночных переработок

        foreach (Schedule sch in schedule)
        {

            // если у нас день не совпадает с днем в графике, заполняю пустым квадратом
            int d = Convert.ToInt32(sch.DayPeriod);

            while (d != day)
            {
                if (day == count_days) break;
                day++;
            }

            HRHours hrh = hr_current.Find(delegate(HRHours h) { return h.Day == day.ToString(); });
            decimal hr_sum = 0;
            if (hrh != null)
                hr_sum = hrh.DayOverHours + hrh.NightOverHours;

            ScheduleDeflection sd = dschedule.Find(delegate(ScheduleDeflection dsch) { return Convert.ToInt32(dsch.DayPeriod) == day; });
            if (sd == null)
            {
                // если у нас выходной то считаем все переработки за этот день
                if (((sch.DaySchedule == "FREE") && (Convert.ToInt32(sch.TimeHours) == 0)) || (sch.DayScheduleVar == "F"))
                {
                    if (hrh != null)
                    {

                        db.insertOverhoursToManagement(employee_id, start_period, begda, endda, dt.getDateToSQL(day, month, year), hr_sum, accountant_id, period_id);
                        if (t13) db.insertOverhoursToT13(employee_id, start_period, begda, endda, dt.getDateToSQL(day, month, year), hr_sum, accountant_id, period_id);
                    }
                    if ((diversity) && (hrh != null)) m122 += hr_sum;
                }
                else        // если рабочий день
                {
                    if (hrh != null)
                    {
                        db.insertOverhoursToManagement(employee_id, start_period, begda, endda, dt.getDateToSQL(day, month, year), hr_sum, accountant_id, period_id);
                        if (t13) db.insertOverhoursToT13(employee_id, start_period, begda, endda, dt.getDateToSQL(day, month, year), hr_sum, accountant_id, period_id);
                    }
                    if ((diversity) && (hrh != null))
                    {
                        if (hr_sum <= 2) m111 += hr_sum;
                        else
                        {
                            m111 += 2;
                            m122 += (hr_sum - 2);
                        }
                        if (hrh.NightOverHours != 0) m210 += hrh.NightOverHours;
                    }

                }
            }
            else // !!!!!!!!!!!! Посмотреть внимательно, когда будет действовать блок закачки переработок в SAP !!!!!!!!!
            {
                // смотрим отклонение Отзыв из отпуска. Если в этот день есть переработка - пишем ее
                if (sd.AbsAttType.Equals("2000") || sd.AbsAttType.Equals("2001"))
                {
                    // если у нас выходной то считаем все переработки за этот день
                    if (((sch.DaySchedule == "FREE") && (Convert.ToInt32(sch.TimeHours) == 0)) || (sch.DayScheduleVar == "F"))
                    {
                        if (hrh != null)
                        {

                            db.insertOverhoursToManagement(employee_id, start_period, begda, endda, dt.getDateToSQL(day, month, year), hr_sum, accountant_id, period_id);
                            if (t13) db.insertOverhoursToT13(employee_id, start_period, begda, endda, dt.getDateToSQL(day, month, year), hr_sum, accountant_id, period_id);
                        }
                        if ((diversity) && (hrh != null)) m122 += hr_sum;
                    }
                    else        // если рабочий день
                    {
                        if (hrh != null)
                        {
                            db.insertOverhoursToManagement(employee_id, start_period, begda, endda, dt.getDateToSQL(day, month, year), hr_sum, accountant_id, period_id);
                            if (t13) db.insertOverhoursToT13(employee_id, start_period, begda, endda, dt.getDateToSQL(day, month, year), hr_sum, accountant_id, period_id);
                        }
                        if ((diversity) && (hrh != null))
                        {
                            if (hr_sum <= 2) m111 += hr_sum;
                            else
                            {
                                m111 += 2;
                                m122 += (hr_sum - 2);
                            }
                            if (hrh.NightOverHours != 0) m210 += hrh.NightOverHours;
                        }

                    }
                }
            }

            day++;
        }

        if (m111 > 0) db.insertOverhoursDiversity(employee_id, start_period, begda, endda, dt.getDateFromSAPToSQL(endda), m111, "M111", accountant_id, period_id);
        if (m122 > 0) db.insertOverhoursDiversity(employee_id, start_period, begda, endda, dt.getDateFromSAPToSQL(endda), m122, "M122", accountant_id, period_id);
        if (m210 > 0) db.insertOverhoursDiversity(employee_id, start_period, begda, endda, dt.getDateFromSAPToSQL(endda), m210, "M210", accountant_id, period_id);

        return 1;
    }
    // получаем список сотрудников у которых графики не совпадают
    public bool checkEmployee(string employee_id, string start_period, string begda, string endda, int count_days)
    {
        bool is_right = true;
        int day = 1;

        EmployeeList emp_list = new EmployeeList();

        List<TimekeeperHours> current = emp_list.getEmployeesTimekeeperHours(employee_id, start_period, begda, endda);
        List<HRHours> hr_current = emp_list.getEmployeesHRHours(employee_id, start_period, begda, endda);
        List<Schedule> schedule = emp_list.getEmployeesSchedule(employee_id, start_period, begda, endda);
        List<ScheduleDeflection> dschedule = emp_list.getEmployeesScheduleDeflection(employee_id, start_period, begda, endda);

        foreach (Schedule sch in schedule)
        {

            // если у нас день не совпадает с днем в графике, заполняю пустым квадратом
            int d = Convert.ToInt32(sch.DayPeriod);

            while (d != day)
            {
                if (day == count_days) break;
                day++;
            }

            is_right = true;
            string time = "";
            decimal hour_timekeeper = 0;
            decimal hour_schedule = 0;
            decimal hour_hr = 0;
            string symbols = "";

            TimekeeperHours th = current.Find(delegate(TimekeeperHours h) { return h.Day == day.ToString(); });

            if (th != null)
            {
                hour_timekeeper = th.Hours;
                symbols = th.Symbols.ToUpper();
            }

            ScheduleDeflection sd = dschedule.Find(delegate(ScheduleDeflection dsch) { return Convert.ToInt32(dsch.DayPeriod) == day; });
            if (sd != null)
            {
                time = sd.CodeT13;
                decimal diversity = sch.TimeHours - sd.TimeHours;
                if (diversity == 0)
                {
                    // если отклонение с кодом 2000 или 2001 - Отзыв из отпуска, то в основной график проставляем часы. Это присутствие.
                    if (sd.AbsAttType.Equals("2000") || sd.AbsAttType.Equals("2001"))
                        hour_schedule = Convert.ToDecimal(sd.TimeHours);
                    else
                        time = sd.CodeT13;
                }
                else
                {
                    if (diversity > 0)
                    {
                        time = CheckDecimalNumber(diversity.ToString());
                        hour_schedule = Convert.ToDecimal(diversity);
                    }
                    else
                    {
                        time = CheckDecimalNumber(sd.TimeHours.ToString());
                        hour_schedule = Convert.ToDecimal(sd.TimeHours);
                    }
                }

            }
            else
            {
                // если у нас выходной то вставляем в квадрат букву В
                if (((sch.DaySchedule == "FREE") && (Convert.ToDecimal(sch.TimeHours) == 0)) || (sch.DayScheduleVar == "F"))
                {
                    time = "В";  // В - в русской раскладке!!!!!!!!
                }
                else
                {
                    time = CheckDecimalNumber(sch.TimeHours.ToString());
                    hour_schedule = Convert.ToDecimal(sch.TimeHours);

                }

            }

            HRHours hrh = hr_current.Find(delegate(HRHours h) { return h.Day == day.ToString(); });
            if (hrh != null)
            {
                if ((hrh.DayOverHours != null) && (hrh.NightOverHours != null)) hour_hr = hrh.DayOverHours + hrh.NightOverHours;
                if ((hrh.DayOverHours != null) && (hrh.NightOverHours == null)) hour_hr = hrh.DayOverHours;
                if ((hrh.DayOverHours == null) && (hrh.NightOverHours != null)) hour_hr = hrh.NightOverHours;
            }

            if (hour_timekeeper <= 0)
            {
                // если в часах табельщика буквы и они совпадают с основным графиком, идем дальше
                try
                {
                    if ((symbols.Equals(time) == true) || ((symbols == "") && (Convert.ToDecimal(time) == 0)))
                        continue;
                }
                catch
                {
                }

                // если в часах табельщика проставлены буквы и они не совпадают с основным графиком, то записываем сотрудника
                if ((symbols.Equals(time) == false) || (hour_hr > 0))
                {
                    is_right = false;
                    break;
                }

            }

            // вычисляем результат = часы табельщика - часы переработки - часы по основному графику
            decimal result = hour_timekeeper - hour_hr - hour_schedule;

            if (result != 0)
            {
                is_right = false;
                break;
            }

            day++;
        }

        return is_right;
    }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Tag page
                // ... for non vacation managers
                EmployeeGateway employeeGatewayManager = new EmployeeGateway();
                int employeeIdNow = employeeGatewayManager.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"]));
                employeeGatewayManager.LoadByEmployeeId(employeeIdNow);

                if (employeeGatewayManager.GetIsVacationsManager(employeeIdNow))
                {
                    hdfIsVacationManager.Value = "True";
                }
                else
                {
                    hdfIsVacationManager.Value = "False";
                }

                // Security check
                if (hdfIsVacationManager.Value == "False")
                {
                    //if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_VACATIONS_EDIT"])))
                    //{
                        Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                    //}
                }

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) && ((string)Request.QueryString["vacation_id"] == null) && ((string)Request.QueryString["request_id"] == null) && ((string)Request.QueryString["date_to_show"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in vacations_edit.aspx");
                }

                // Tag page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfVacationId.Value = (string)Request.QueryString["vacation_id"];
                hdfRequestId.Value = (string)Request.QueryString["request_id"];

                int requestId = Int32.Parse(hdfRequestId.Value);
                int companyId = Int32.Parse(hdfCompanyId.Value);

                ViewState["date_to_show"] = (string)Request.QueryString["date_to_show"];
                DateTime dateToShow = DateTime.Parse((string)Request.QueryString["date_to_show"]);

                // Initialize values
                DropDownList ddlVacationsFor = (DropDownList)tkrpbLeftMenuAllVacations.FindItemByValue("nbVacationsForDDL").FindControl("ddlVacationsFor");
                EmployeeList employeeList = new EmployeeList();
                string employeeTypeNow = employeeGatewayManager.GetType(employeeIdNow);
                if (employeeTypeNow.Contains("CA"))
                {
                    employeeList.LoadBySalariedEmployeeTypeAndAddItem(1, "CA", -1, "(All)");
                }
                else
                {
                    employeeList.LoadBySalariedEmployeeTypeAndAddItem(1, "US", -1, "(All)");
                }
                ddlVacationsFor.DataSource = employeeList.Table;
                ddlVacationsFor.DataValueField = "EmployeeID";
                ddlVacationsFor.DataTextField = "FullName";
                ddlVacationsFor.DataBind();
                ddlVacationsFor.SelectedValue = Session["ddlVacationsForSelectedValue"].ToString();

                // Load Data
                vacationsInformationTDS = new VacationsInformationTDS();
                vacationDaysInformation = new VacationsInformationTDS.DaysInformationDataTable();

                VacationsInformationDaysInformationGateway vacationsInformationDaysInformationGateway = new VacationsInformationDaysInformationGateway(vacationsInformationTDS);
                vacationsInformationDaysInformationGateway.LoadByRequestId(requestId, companyId);

                VacationsInformationRequestsInformationGateway vacationsInformationRequestsInformationGateway = new VacationsInformationRequestsInformationGateway(vacationsInformationTDS);
                vacationsInformationRequestsInformationGateway.LoadByRequestId(requestId, companyId);

                hdfEmployeeId.Value = vacationsInformationRequestsInformationGateway.GetEmployeeID(requestId).ToString();
                int employeeId = Int32.Parse(hdfEmployeeId.Value);

                VacationsInformationBasicInformationGateway vacationsInformationBasicInformationGateway = new VacationsInformationBasicInformationGateway(vacationsInformationTDS);
                vacationsInformationBasicInformationGateway.LoadByEmployeeIdYear(employeeId, dateToShow.Year, companyId);

                Session["vacationsInformationTDS"] = vacationsInformationTDS;
                Session["vacationDaysInformation"] = vacationsInformationTDS.DaysInformation;

                LoadData(employeeId, dateToShow.Year, requestId);

                Page.DataBind();
            }
            else
            {
                vacationsInformationTDS = (VacationsInformationTDS)Session["vacationsInformationTDS"];
                vacationDaysInformation = (VacationsInformationTDS.DaysInformationDataTable)Session["vacationDaysInformation"];
            }
        }
    public void GetReportTimeboard(List<Employee> all_employees, Period per)
    {
        SQLDB sql = new SQLDB();

        Date dt = new Date();

        OpenReportExcelFile(@"C:\Inetpub\wwwroot\timeboard\Reports\ReportTimeboard.xls");
        Excel.Workbook workbook = (Excel.Workbook)thisApplication.Workbooks["ReportTimeboard.xls"];
        Excel.Worksheet worksheet = (Excel.Worksheet)workbook.Worksheets["Sheet1"];

        NightHoursDB nightdb = new NightHoursDB();
        List<NightHours> nighthours = nightdb.getNightHours();

        EmployeeComparerByFullnameASC emp_comp = new EmployeeComparerByFullnameASC();
        all_employees.Sort(emp_comp);

        int count_days = dt.getCountDays(per.MonthID, per.Year);

        worksheet.Cells[1, 1] = "Таб. номер";
        worksheet.Cells[1, 2] = "ФИО";

        int j = 2;
        int i = 1;

        for (i = 1; i <= count_days; i++)
        {
            worksheet.Cells[1, ++j] = i;
            worksheet.Cells[1, ++j] = i + "a";
        }

        i = 2;

        foreach (Employee emp in all_employees)
        {

            worksheet.Cells[i, 1] = DeleteZeroFromEmployeeID(emp.EmployeeID);
            worksheet.Cells[i, 2] = emp.FullName;

            j = 2;

            int day = 1;

            EmployeeList emp_list = new EmployeeList();

            List<HRHours> hr_current = sql.getHRHours(emp.EmployeeID, emp.StartPeriod, emp.BeginDate, emp.EndDate);
            List<Schedule> schedule = sql.getSchedule(emp.EmployeeID, emp.StartPeriod, emp.BeginDate, emp.EndDate);
            List<ScheduleDeflection> dschedule = sql.getScheduleDeflection(emp.EmployeeID, emp.StartPeriod, emp.BeginDate, emp.EndDate);

            foreach (Schedule sch in schedule)
            {
                j++;

                decimal all_hours = 0;
                decimal night_hours = 0;

                int d = Convert.ToInt32(sch.DayPeriod);
                // если у нас день не совпадает с днем в графике, заполняю пустым квадратом

                HRHours hr = hr_current.Find(delegate(HRHours hrh) { return Convert.ToInt32(hrh.Day) == day; });

                if (hr != null)
                {
                    all_hours += hr.DayOverHours + hr.NightOverHours;
                    night_hours += hr.NightOverHours;
                }

                while (d != day)
                {
                    if (day == count_days) break;

                    if (all_hours != 0) worksheet.Cells[i, j] = all_hours.ToString();

                    if (night_hours != 0) worksheet.Cells[i, ++j] = night_hours.ToString();
                    else j++;

                    j++;
                    day++;
                }

                ScheduleDeflection sd = dschedule.Find(delegate(ScheduleDeflection dsch) { return Convert.ToInt32(dsch.DayPeriod) == day; });
                if (sd != null)
                {
                    //time = CheckDecimalNumber(sd.CodeT13);

                    decimal diversity = sch.TimeHours - sd.TimeHours;
                    if (diversity != 0)
                    {
                        if (diversity > 0)
                        {

                            all_hours = diversity;
                        }
                        else
                        {

                            all_hours = sd.TimeHours;
                        }
                    }

                    if (all_hours != 0) worksheet.Cells[i, j] = all_hours.ToString();

                    if (night_hours != 0) worksheet.Cells[i, ++j] = night_hours.ToString();
                    else j++;

                }
                else
                {

                    // если выходной или изменение на выходной то пишем в отклонения по выходному дню
                    if (((sch.DaySchedule == "FREE") && (Convert.ToInt32(sch.TimeHours) == 0)) || (sch.DayScheduleVar == "F"))
                    {
                        if (all_hours != 0) worksheet.Cells[i, j] = all_hours.ToString();

                        if (night_hours != 0) worksheet.Cells[i, ++j] = night_hours.ToString();
                        else j++;
                    }
                    else
                    {
                        //decimal hour_start = Convert.ToInt32(sch.TimeBegin.Substring(0, 2));
                        //decimal hour_end = Convert.ToInt32(sch.TimeEnd.Substring(0, 2));
                        //decimal minute_start = Convert.ToDecimal(sch.TimeBegin.Substring(2, 2));
                        //decimal minute_end = Convert.ToDecimal(sch.TimeEnd.Substring(2, 2));

                        //if (hour_start == 0) hour_start = 24;
                        //if (hour_end == 0) hour_end = 24;\
                        /*
                        hour_start += minute_start / 60;
                        hour_end += minute_end / 60;

                        if (sch.TimeHours != 0)
                        {
                            if ((hour_start > 6) && (hour_end < 22))
                                all_hours += sch.TimeHours;
                            if (hour_start <= 6)
                            {
                                night_hours += 6 - hour_start - 1;
                                all_hours += sch.TimeHours;
                            }
                            if (hour_end >= 22)
                            {
                                night_hours += hour_end - 22;
                                all_hours += sch.TimeHours;
                            }
                        }*/

                        all_hours += sch.TimeHours;

                        NightHours nhour = nighthours.Find(delegate(NightHours nh) { return nh.DaySchedule.ToUpper() == sch.DaySchedule.ToUpper(); });

                        if (nhour != null)
                        {
                            night_hours += nhour.Night_Hours;
                        }

                        //day_hours += (night_hours + sch.TimeHours);
                        if (all_hours != 0) worksheet.Cells[i, j] = all_hours.ToString();

                        if (night_hours != 0) worksheet.Cells[i, ++j] = night_hours.ToString();
                        else j++;
                    }
                }

                day++;
            }

            while (day <= count_days)
            {
                decimal all_hours = 0;
                decimal night_hours = 0;

                //HRHours hr = hr_current.Find(delegate(HRHours hrh) { return Convert.ToInt32(hrh.Day) == day; });

                if (all_hours != 0) worksheet.Cells[i, j] = all_hours.ToString();

                if (night_hours != 0) worksheet.Cells[i, ++j] = night_hours.ToString();
                else j++;

                j++;
                day++;
            }

            worksheet.Cells[i, ++j] = getCompany(emp.Department);
            worksheet.Cells[i, ++j] = getPath(emp.Department);
            worksheet.Cells[i, ++j] = getDepartment(emp.Department);

            i++;

        }

        SaveReportToExcel();
    }
    protected void period_SelectedIndexChanged(object sender, EventArgs e)
    {
        ddl_post.Items.Clear();
        Person user = (Person)Session["User"];
        SAPDB db = new SAPDB();
        EmployeeList emp_list = new EmployeeList();
        List<Post> post_list = null;/// pl.getPosts(db.getPostList(StartDateOfPeriod, EndDateOfPeriod, user.TabNum, this.role));
        ListItem li = new ListItem("�������� ���������");
        ddl_post.Items.Add(li);
        if (post_list != null) fillPosts(post_list);

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

        if (per.IsClosed == 1) lbStatus.Text = "������";
        else lbStatus.Text = "������";
    }
    protected void Save_Click(object sender, ImageClickEventArgs e)
    {
        //Response.Write(Request.Form["test"]);
        Person user = (Person)Session["User"];
        PeriodDB perdb = new PeriodDB();
        Period per = perdb.getPeriod(Convert.ToInt32(this.month), Convert.ToInt32(this.year));

        if (this.employees != null)
        {

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

            foreach (Department dep in departments)
            {
                EmployeeList emp_list = new EmployeeList();
                List<Employee> emps = null;//// emp_list.getEmployeesOfDepartment(dep.DepartmentID, employees);
                EmployeeComparerByPostASC cmpByPostASC = new EmployeeComparerByPostASC();
                emps.Sort(cmpByPostASC);
                foreach (Employee em in emps)
                {
                    EmployeeList emplist = new EmployeeList();
                    List<TimekeeperHours> current = null;//emplist.getEmployeesTimekeeperHours(em);
                    List<HRHours> hr_current = null;/// emplist.getEmployeesHRHours(em);

                    for (int i = 1; i <= count_days; i++)
                    {
                        string textbox_id = "tb" + dep.DepartmentID + em.PostID + em.EmployeeID + i.ToString();
                        //string hr_id = "hr" + dep.DepartmentID + em.EmployeeID + i.ToString();

                        Date dt = new Date();
                        SQLDB db = new SQLDB();

                        string hour = Request.Form[textbox_id];
                        //string overhour = Request.Form[hr_id];

                        TimekeeperHours th = current.Find(delegate(TimekeeperHours ht) { return ht.Day == i.ToString(); });

                        decimal h = -1;
                        string sym = "";

                        if ((hour != "") && (hour != null))
                        {
                            if (HasSymbols(hour))
                            {
                                if (th == null)
                                    db.insertTimekeeperHoursAndSymbols(em.EmployeeID, em.StartPeriod, em.BeginDate, em.EndDate, h, hour, user.TabNum, dep.DepartmentID, em.PostID, i.ToString(), month, year, per.PeriodID);
                                else
                                    if (!th.Symbols.Equals(hour))
                                        db.updateTimekeeperHoursAndSymbols(user.TabNum, h, hour, th.ID);
                            }
                            else
                            {
                                h = Convert.ToDecimal(hour);

                                if (th == null)
                                    db.insertTimekeeperHoursAndSymbols(em.EmployeeID, em.StartPeriod, em.BeginDate, em.EndDate, h, sym, user.TabNum, dep.DepartmentID, em.PostID, i.ToString(), month, year, per.PeriodID);
                                else
                                    if (th.Hours != h)
                                        db.updateTimekeeperHoursAndSymbols(user.TabNum, h, sym, th.ID);
                            }
                        }

                        if ((hour == "") && (th != null)) db.deleteTimekeeperHours(th.ID);

                    }
                }

            }
        }

        EncryptedQueryString QueryString = new EncryptedQueryString();
        QueryString.Add("month", period.SelectedItem.Value);
        QueryString.Add("role", role);
        //Server.Transfer("TimeTable.aspx?data=" + QueryString.ToString());
        //Response.Redirect("Tabel.aspx?data=" + QueryString.ToString());
    }
 internal static HandleRef getCPtr(EmployeeList obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
    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);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["User"] == null) Response.Redirect("Default.aspx");

        Date dt = new Date();
        SAPDB db = new SAPDB();
        SQLDB sql = new SQLDB();
        PeriodDB perdb = new PeriodDB();
        NightHoursDB nightdb = new NightHoursDB();
        Person user = (Person)Session["User"];

        string role = "";
        string month_id = "";
        string year = "";
        string start_date = "";
        string end_date = "";

        if (Request.QueryString["rtb"] != null)
        {
            EncryptedQueryString QueryString = new EncryptedQueryString(Request.QueryString["rtb"]);
            if (QueryString["role"] != null) role = QueryString["role"].ToString();
            if (QueryString["month_id"] != null) month_id = QueryString["month_id"].ToString();
            if (QueryString["year"] != null) year = QueryString["year"].ToString();
            if (QueryString["start_date"] != null) start_date = QueryString["start_date"].ToString();
            if (QueryString["end_date"] != null) end_date = QueryString["end_date"].ToString();
        }

        List<NightHours> nighthours = nightdb.getNightHours();

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

        EmployeeList emp_list = new EmployeeList();

        List<Employee> all_employees = db.getEmployeeListForReports(start_date, end_date, user.TabNum, role);

        if (all_employees == null)
        {
            MessageBox.Show("Невозможно сформировать отчет! Список сотрудников за период пуст!");
            return;
        }

        EmployeeComparerByFullnameASC emp_comp = new EmployeeComparerByFullnameASC();
        all_employees.Sort(emp_comp);

        Response.Clear();
        Response.Charset = "utf-8";
        Response.ContentType = "application/vnd.ms-excel";

        string str = @"<table cellspacing='0' cellpadding='0' border='1'>
                            <tr>
                                <td width='30px' style='font-weight: bold;' align='center' valign='middle'>
                                    Таб. номер
                                </td>
                                <td width='100px' style='font-weight: bold;' align='center' valign='middle'>
                                    ФИО
                                </td>";

        int count_days = dt.getCountDays(per.MonthID, per.Year);

        for (int i = 1; i <= count_days; i++)
            str += "<td width='20px' style='font-weight: bold;' align='center'>" + i.ToString() + "</td><td width='20px' style='background-color: #99CCFF; font-weight: bold;' align='center' >" + i.ToString() + "a</td>";

        str += "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";

        foreach (Employee emp in all_employees)
        {

            str += "<tr>";
            str += "<td width='30px' align='center'>" + DeleteZeroFromEmployeeID(emp.EmployeeID) + "</td>";
            str += "<td width='100px' align='center'>" + emp.FullName + "</td>";

            int day = 1;

            List<HRHours> hr_current = sql.getHRHours(emp.EmployeeID, emp.StartPeriod, emp.BeginDate, emp.EndDate);
            List<Schedule> schedule = sql.getSchedule(emp.EmployeeID, emp.StartPeriod, emp.BeginDate, emp.EndDate);
            List<ScheduleDeflection> dschedule = sql.getScheduleDeflection(emp.EmployeeID, emp.StartPeriod, emp.BeginDate, emp.EndDate);

           foreach (Schedule sch in schedule)
           {

               decimal all_hours = 0;
               decimal night_hours = 0;

               int d = Convert.ToInt32(sch.DayPeriod);
               // если у нас день не совпадает с днем в графике, заполняю пустым квадратом

               //TimekeeperHours tkh = tkh_current.Find(delegate(TimekeeperHours h) { return Convert.ToInt32(h.Day) == day; });
               HRHours hr = hr_current.Find(delegate(HRHours hrh) { return Convert.ToInt32(hrh.Day) == day; });

               if (hr != null)
               {
                   all_hours += hr.DayOverHours + hr.NightOverHours;
                   night_hours += hr.NightOverHours;
               }

               while (d != day)
               {
                   if (day == count_days) break;

                   if (all_hours != 0) str += "<td width='20px' align='center'>" + all_hours.ToString() + "</td>";
                   else str += "<td width='20px' align='center'>&nbsp;</td>";

                   if (night_hours != 0) str += "<td width='20px' style='background-color: #99CCFF;' align='center'>" + night_hours.ToString() + "</td>";
                   else str += "<td width='20px' style='background-color: #99CCFF;' align='center'>&nbsp;</td>";

                   day++;
               }

               ScheduleDeflection sd = dschedule.Find(delegate(ScheduleDeflection dsch) { return Convert.ToInt32(dsch.DayPeriod) == day; });
               if (sd != null)
               {
                   //time = CheckDecimalNumber(sd.CodeT13);

                   decimal diversity = sch.TimeHours - sd.TimeHours;
                   if (diversity != 0)
                   {
                       if (diversity > 0)
                       {

                           all_hours = diversity;
                       }
                       else
                       {

                           all_hours = sd.TimeHours;
                       }
                   }

                   if (all_hours != 0) str += "<td width='20px' align='center'>" + all_hours.ToString() + "</td>";
                   else str += "<td width='20px' align='center'>&nbsp;</td>";

                   if (night_hours != 0) str += "<td width='20px' style='background-color: #99CCFF;' align='center'>" + night_hours.ToString() + "</td>";
                   else str += "<td width='20px' style='background-color: #99CCFF;' align='center'>&nbsp;</td>";
               }
               else
               {

                   // если выходной или изменение на выходной то пишем в отклонения по выходному дню
                   if (((sch.DaySchedule == "FREE") && (Convert.ToInt32(sch.TimeHours) == 0)) || (sch.DayScheduleVar == "F"))
                   {
                       if (all_hours != 0) str += "<td width='20px' align='center'>" + all_hours.ToString() + "</td>";
                       else str += "<td width='20px' align='center'>&nbsp;</td>";

                       if (night_hours != 0) str += "<td width='20px' style='background-color: #99CCFF;' align='center'>" + night_hours.ToString() + "</td>";
                       else str += "<td width='20px' style='background-color: #99CCFF;' align='center'>&nbsp;</td>";
                   }
                   else
                   {
                       //decimal hour_start = Convert.ToInt32(sch.TimeBegin.Substring(0, 2));
                       //decimal hour_end = Convert.ToInt32(sch.TimeEnd.Substring(0, 2));
                       //decimal minute_start = Convert.ToDecimal(sch.TimeBegin.Substring(2, 2));
                       //decimal minute_end = Convert.ToDecimal(sch.TimeEnd.Substring(2, 2));

                       //if (hour_start == 0) hour_start = 24;
                       //if (hour_end == 0) hour_end = 24;\
                       /*
                       hour_start += minute_start / 60;
                       hour_end += minute_end / 60;

                       if (sch.TimeHours != 0)
                       {
                           if ((hour_start > 6) && (hour_end < 22))
                               all_hours += sch.TimeHours;
                           if (hour_start <= 6)
                           {
                               night_hours += 6 - hour_start - 1;
                               all_hours += sch.TimeHours;
                           }
                           if (hour_end >= 22)
                           {
                               night_hours += hour_end - 22;
                               all_hours += sch.TimeHours;
                           }
                       }
                       */

                       all_hours += sch.TimeHours;

                       NightHours nhour = nighthours.Find(delegate(NightHours nh) { return nh.DaySchedule.ToUpper() == sch.DaySchedule.ToUpper(); });

                       if (nhour != null)
                       {
                           night_hours += nhour.Night_Hours;
                       }

                       //day_hours += (night_hours + sch.TimeHours);
                       if (all_hours != 0) str += "<td width='20px' align='center'>" + all_hours.ToString() + "</td>";
                       else str += "<td width='20px' align='center'>&nbsp;</td>";

                       if (night_hours != 0) str += "<td width='20px' style='background-color: #99CCFF;' align='center'>" + night_hours.ToString() + "</td>";
                       else str += "<td width='20px' style='background-color: #99CCFF;' align='center'>&nbsp;</td>";
                   }
               }

               day++;
           }

           while (day <= count_days)
           {
               decimal all_hours = 0;
               decimal night_hours = 0;

               //HRHours hr = hr_current.Find(delegate(HRHours hrh) { return Convert.ToInt32(hrh.Day) == day; });

               if (all_hours != 0) str += "<td width='20px' align='center'>" + all_hours.ToString() + "</td>";
               else str += "<td width='20px' align='center'>&nbsp;</td>";

               if (night_hours != 0) str += "<td width='20px' style='background-color: #99CCFF;' align='center'>" + night_hours.ToString() + "</td>";
               else str += "<td width='20px' style='background-color: #99CCFF;' align='center'>&nbsp;</td>";

               day++;
           }

           str += "<td>" + getCompany(emp.Department) + "</td><td>" + getPath(emp.Department) + "</td><td>" + getDepartment(emp.Department) + "</td>";

           str += "</tr>";

        }

        str += "</table>";

        Response.Write(str);
        Response.End();
    }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_VACATIONS_VIEW"])))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in vacations_all.aspx");
                }

                // Tag page
                int companyId = Int32.Parse(Session["companyID"].ToString());
                hdfCompanyId.Value = companyId.ToString();

                // ... For non vacation managers
                EmployeeGateway employeeGatewayManager = new EmployeeGateway();

                int employeeIdNow = employeeGatewayManager.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"]));

                employeeGatewayManager.LoadByEmployeeId(employeeIdNow);

                if (employeeGatewayManager.GetIsVacationsManager(employeeIdNow))
                {
                    hdfIsVacationManager.Value = "True";
                }
                else
                {
                    hdfIsVacationManager.Value = "False";
                }

                // Initialize values
                DropDownList ddlVacationsFor = (DropDownList)tkrpbLeftMenuAllVacations.FindItemByValue("nbVacationsForDDL").FindControl("ddlVacationsFor");
                EmployeeList employeeList = new EmployeeList();

                string employeeTypeNow = employeeGatewayManager.GetType(employeeIdNow);

                if (employeeTypeNow.Contains("CA"))
                {
                    employeeList.LoadBySalariedEmployeeTypeAndAddItem(1, "CA", -1, "(All)");
                }
                else
                {
                    employeeList.LoadBySalariedEmployeeTypeAndAddItem(1, "US", -1, "(All)");
                }
                ddlVacationsFor.DataSource = employeeList.Table;
                ddlVacationsFor.DataValueField = "EmployeeID";
                ddlVacationsFor.DataTextField = "FullName";
                ddlVacationsFor.DataBind();

                //... date_to_show
                if ((string)Request.QueryString["date_to_show"] == null)
                {
                    ViewState["date_to_show"] = DateTime.Now.ToString();
                }
                else
                {
                    ViewState["date_to_show"] = (string)Request.QueryString["date_to_show"];
                }

                // Load vacations
                vacationsInformationTDS = new VacationsInformationTDS();
                vacationsInformation = new VacationsInformationTDS.VacationsInformationDataTable();

                VacationsInformationGateway vacationsInformationGateway = new VacationsInformationGateway(vacationsInformationTDS);

                if (hdfIsVacationManager.Value == "False")
                {
                    EmployeeGateway employeeGateway1 = new EmployeeGateway();
                    ViewState["employee_id"] = employeeGateway1.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"]));

                    EmployeeInformationBasicInformationGateway employeeInformationBasicInformationGateway = new EmployeeInformationBasicInformationGateway();
                    employeeInformationBasicInformationGateway.LoadByEmployeeId(Int32.Parse(ViewState["employee_id"].ToString()));

                    string employeeType = employeeInformationBasicInformationGateway.GetType(Int32.Parse(ViewState["employee_id"].ToString()));

                    if (employeeType.Contains("CA"))
                    {
                        ddlWorkingLocation.SelectedValue = "CA";

                    }
                    else
                    {
                        ddlWorkingLocation.SelectedValue = "US";
                    }

                    vacationsInformationGateway.LoadByEmployeeIdEmployeeType(Int32.Parse(ViewState["employee_id"].ToString()), employeeType, companyId);
                }
                else
                {
                    if ((string)Request.QueryString["employee_id"] == null)
                    {
                        ViewState["employee_id"] = "-1";

                        if (employeeTypeNow.Contains("CA"))
                        {
                            ddlWorkingLocation.SelectedValue = "CA";
                        }
                        else
                        {
                            ddlWorkingLocation.SelectedValue = "US";
                        }

                        vacationsInformationGateway.LoadByEmployeeType(employeeTypeNow, companyId);
                    }
                    else
                    {
                        ViewState["employee_id"] = (string)Request.QueryString["employee_id"];

                        EmployeeInformationBasicInformationGateway employeeInformationBasicInformationGateway = new EmployeeInformationBasicInformationGateway();
                        employeeInformationBasicInformationGateway.LoadByEmployeeId(Int32.Parse(ViewState["employee_id"].ToString()));

                        string employeeType = employeeInformationBasicInformationGateway.GetType(Int32.Parse(ViewState["employee_id"].ToString()));

                        if (employeeTypeNow.Contains("CA"))
                        {
                            ddlWorkingLocation.SelectedValue = "CA";
                        }
                        else
                        {
                            ddlWorkingLocation.SelectedValue = "US";
                        }

                        vacationsInformationGateway.LoadByEmployeeIdEmployeeType(Int32.Parse(ViewState["employee_id"].ToString()), employeeType, companyId);

                        ddlVacationsFor.SelectedValue = ViewState["employee_id"].ToString();
                    }
                }

                Session["vacationsInformationTDS"] = vacationsInformationTDS;
                Session["vacationsInformation"] = vacationsInformationTDS.VacationsInformation;

                tkrsVacations.SelectedDate = DateTime.Parse(ViewState["date_to_show"].ToString());
                lblTitle.Text = "Vacations Calendar for " + tkrsVacations.SelectedDate.ToString("MMMM") + " " + tkrsVacations.SelectedDate.Year.ToString();

                // Databind
                Page.DataBind();

                // For Open Vacation event
                if ((Request.Params["__EVENTTARGET"]) == "openVacation")
                {
                    int vacationId = Int32.Parse(Request.Params.Get("__EVENTARGUMENT").ToString()) ;
                    VacationsInformationDaysInformationGateway vacationsInformationDaysInformationGateway = new VacationsInformationDaysInformationGateway();
                    vacationsInformationDaysInformationGateway.LoadByVacationId(vacationId, companyId);
                    int requestId = vacationsInformationDaysInformationGateway.GetRequestID(vacationId);

                    Session["ddlVacationsForSelectedValue"] = ddlVacationsFor.SelectedValue;

                    Response.Redirect("./vacations_summary.aspx?source_page=vacations_all.aspx&vacation_id=" + vacationId.ToString() + "&request_id=" + requestId.ToString() + "&date_to_show=" + ViewState["date_to_show"]);
                }
            }
            else
            {
                vacationsInformationTDS = (VacationsInformationTDS)Session["vacationsInformationTDS"];
                vacationsInformation = (VacationsInformationTDS.VacationsInformationDataTable)Session["vacationsInformation"];

                // For Open Vacation event
                if ((Request.Params["__EVENTTARGET"]) == "openVacation")
                {
                    int vacationId = Int32.Parse(Request.Params.Get("__EVENTARGUMENT").ToString());
                    VacationsInformationDaysInformationGateway vacationsInformationDaysInformationGateway = new VacationsInformationDaysInformationGateway();
                    vacationsInformationDaysInformationGateway.LoadByVacationId(vacationId, Int32.Parse(hdfCompanyId.Value));
                    int requestId = vacationsInformationDaysInformationGateway.GetRequestID(vacationId);

                    DropDownList ddlVacationsFor = (DropDownList)tkrpbLeftMenuAllVacations.FindItemByValue("nbVacationsForDDL").FindControl("ddlVacationsFor");
                    Session["ddlVacationsForSelectedValue"] = ddlVacationsFor.SelectedValue;

                    Response.Redirect("./vacations_summary.aspx?source_page=vacations_all.aspx&vacation_id=" + vacationId.ToString() + "&request_id=" + requestId.ToString() + "&date_to_show=" + ViewState["date_to_show"]);
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Validate query string
                if ((string)Request.QueryString["source_page"] == null)
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in timesheet_approve.aspx");
                }

                // Security check
                EmployeeGateway employeeGateway1 = new EmployeeGateway(new DataSet());
                int employeeId = employeeGateway1.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"]));
                hdfCurrentEmployeeId.Value = employeeGateway1.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"])).ToString();
                employeeGateway1.LoadByEmployeeId(employeeId);

                if (!employeeGateway1.GetApproveTimesheets(employeeId))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Tag page
                Session.Remove("projectTimeApproveDummy");

                // Initialize  variables
                lblError.Visible = false;

                // ... Initialize viewstate variables
                System.Configuration.AppSettingsReader appSettingReader = new System.Configuration.AppSettingsReader();
                ViewState["LHMode"] = appSettingReader.GetValue("LABOUR_HOURS_OPERATION_MODE", typeof(System.String)).ToString();

                // Labour Hours Mode check
                if ((string)ViewState["LHMode"] == "Partial")
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "The system is on partial mode. Contact your system administrator.");
                }

                ViewState["others"] = Request.QueryString["others"];

                PayPeriodGateway payPeriodGateway = new PayPeriodGateway(new DataSet());
                ViewState["period_id"] = payPeriodGateway.GetPayPeriodId(DateTime.Now);

                // Load data
                // ... Loading employees accordingly to the admins country.
                EmployeeList employeeList = new EmployeeList(new DataSet());
                string employeeType = employeeGateway1.GetType(employeeId);
                odsClient.SelectParameters.RemoveAt(2);
                if (employeeType.Contains("CA"))
                {
                    employeeList.LoadByRequestProjectTimeEmployeeTypeEmployeeIdApproveManagerAndAddItem(1, "CA", -1, "(All)", employeeId);

                    odsClient.SelectParameters.Add("countryId", "1");
                }
                else
                {
                    if (employeeType.Contains("US"))
                    {
                        employeeList.LoadByRequestProjectTimeEmployeeTypeEmployeeIdApproveManagerAndAddItem(1, "US", -1, "(All)", employeeId);

                        odsClient.SelectParameters.Add("countryId", "2");
                    }
                    else
                    {
                        employeeList.LoadByRequestProjectTimeEmployeeTypeEmployeeIdApproveManagerAndAddItem(1, "SOTA", -1, "(All)", employeeId);

                        odsClient.SelectParameters.Add("countryId", "-1");
                    }
                }

                odsClient.Select();
                ddlClient.SelectedIndex = 0;
                upnlClient.Update();

                ddlTeamMember.DataSource = employeeList.Table;
                ddlTeamMember.DataValueField = "EmployeeID";
                ddlTeamMember.DataTextField = "FullName";
                ddlTeamMember.DataBind();

                odsProject.SelectParameters.RemoveAt(2);
                odsProject.SelectParameters.Add("clientId", "-1");
                odsProject.Select();
                ddlProject.DataBind();
                ddlProject.SelectedIndex = 0;
                upnlProject.Update();

                projectTimeApproveTDS = this.SubmitSearch();

                // Store Datasets
                Session["projectTimeApproveTDS"] = projectTimeApproveTDS;
                projectTimeApprove = projectTimeApproveTDS.ProjectTimeApprove;
                Session["projectTimeApprove"] = projectTimeApproveTDS.ProjectTimeApprove;

                // If coming from
                // ... timesheet_edit.aspx, timesheet_summary.aspx or timesheet_delete.aspx
                if ((Request.QueryString["source_page"] == "timesheet_edit.aspx") || (Request.QueryString["source_page"] == "timesheet_summary.aspx") || (Request.QueryString["source_page"] == "timesheet_delete.aspx"))
                {
                    // ... restore top values
                    RestoreNavigatorState();

                    // ... filter grid information
                    //SetFilterByCountryIdClientIdProjectId();
                    //SetFilterByEmployeeIdDate();
                    SetFilterByClientIdProjectIdEmployeeIdDate();
                }

                ViewState["filter_expression"] = "Deleted = 0";

                SetFocus();
            }
            else
            {
                // Restore dataset
                projectTimeApproveTDS = (ProjectTimeApproveTDS)Session["projectTimeApproveTDS"];
                projectTimeApprove = projectTimeApproveTDS.ProjectTimeApprove;
                Session["projectTimeApprove"] = projectTimeApproveTDS.ProjectTimeApprove;
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                EmployeeGateway employeeGateway1 = new EmployeeGateway();
                int employeeIdNow = employeeGateway1.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"]));
                employeeGateway1.LoadByEmployeeId(employeeIdNow);

                if (!employeeGateway1.GetIsVacationsManager(employeeIdNow))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) && ((string)Request.QueryString["date_to_show"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in vacations_approve_vacation_request.aspx");
                }

                //recibe opcionalmente el employee_id
                // Tag page
                int companyId = Int32.Parse(Session["companyID"].ToString());
                hdfCompanyId.Value = companyId.ToString();

                ViewState["rejected_by_id"] = employeeGateway1.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"]));

                //recibe opcionalmente el employee_id y date_to_show
                if ((string)Request.QueryString["date_to_show"] == null)
                {
                    ViewState["date_to_show"] = DateTime.Now.ToString();
                }
                else
                {
                    ViewState["date_to_show"] = (string)Request.QueryString["date_to_show"];
                }

                if ((string)Request.QueryString["employee_id"] == null)
                {
                    hdfEmployeeId.Value = "-1";
                }
                else
                {
                    hdfEmployeeId.Value = (string)Request.QueryString["employee_id"];
                }

                EmployeeList employeeList = new EmployeeList();
                employeeList.LoadBySalariedAndAddItem(1, -1, "(All)");

                DropDownList ddlVacationsFor = (DropDownList)tkrpbLeftMenuAllVacations.FindItemByValue("nbVacationsForDDL").FindControl("ddlVacationsFor");
                ddlVacationsFor.DataSource = employeeList.Table;
                ddlVacationsFor.DataValueField = "EmployeeID";
                ddlVacationsFor.DataTextField = "FullName";
                ddlVacationsFor.DataBind();
                ddlVacationsFor.SelectedValue = Session["ddlVacationsForSelectedValue"].ToString();

                vacationsInformationTDS = new VacationsInformationTDS();
                VacationsInformationRequestsInformationGateway vacationsInformationRequestsInformationGateway = new VacationsInformationRequestsInformationGateway(vacationsInformationTDS);

                vacationsInformationRequestsInformationGateway.LoadByState("For Approval", companyId);

                grdVacations.DataSource = vacationsInformationTDS.RequestsInformation;

                Session["vacationsInformationTDS"] = vacationsInformationTDS;

                Page.DataBind();

                // Check results
                if (vacationsInformationTDS.RequestsInformation.Rows.Count > 0)
                {
                    tdNoResults.Visible = false;
                    lblTotalRows.Visible = true;
                    lblTotalRows.Text = "Total Rows: " + vacationsInformationTDS.RequestsInformation.Rows.Count;
                }
                else
                {
                    tdNoResults.Visible = true;
                    lblTotalRows.Visible = false;
                }
            }
            else
            {
                vacationsInformationTDS = (VacationsInformationTDS)Session["vacationsInformationTDS"];
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // INITIAL EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_PROJECTS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_PROJECTS_ADD"])))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Tag page
                hdfCompanyId.Value = Session["companyID"].ToString();

                // Initialize viewstate variables
                ViewState["StepFrom"] = "Out";

                // Store navigator state
                StoreNavigatorState();

                // Prepare initial data

                // ... for country
                CountryList countryList = new CountryList();
                countryList.LoadAndAddItem(-1, "(Select a country)");
                ddlCountry.DataSource = countryList.Table;
                ddlCountry.DataValueField = "CountryID";
                ddlCountry.DataTextField = "Name";
                ddlCountry.DataBind();

                // ... for office
                OfficeList officeList = new OfficeList();
                officeList.LoadByCountryIdAndAddItem(-1, "(Select an office)", -1);
                ddlOffice.DataSource = officeList.Table;
                ddlOffice.DataValueField = "OfficeID";
                ddlOffice.DataTextField = "Name";
                ddlOffice.DataBind();

                // ... for province
                ProvinceList provinceList = new ProvinceList();
                provinceList.LoadByCountryIdAndAddItem(-1, "(Select a province)", -1);
                ddlProvince.DataSource = provinceList.Table;
                ddlProvince.DataValueField = "ProvinceID";
                ddlProvince.DataTextField = "Name";
                ddlProvince.DataBind();

                // ... for county
                CountyList countyList = new CountyList();
                countyList.LoadByProvinceIdAndAddItem(-1, "(Select a county)", -1);
                ddlCounty.DataSource = countyList.Table;
                ddlCounty.DataValueField = "CountyID";
                ddlCounty.DataTextField = "Name";
                ddlCounty.DataBind();

                // ... for city
                CityList cityList = new CityList();
                cityList.LoadByCountyIdAndAddItem(-1, "(Select a city)", -1);
                ddlCity.DataSource = cityList.Table;
                ddlCity.DataValueField = "CityID";
                ddlCity.DataTextField = "Name";
                ddlCity.DataBind();

                // ... for employee
                EmployeeList employeeList = new EmployeeList();
                employeeList.LoadAndAddItem(-1, " ");
                ddlProjectLead.DataSource = employeeList.Table;
                ddlProjectLead.DataValueField = "EmployeeID";
                ddlProjectLead.DataTextField = "FullName";
                ddlProjectLead.DataBind();

                // ... for salesman
                SalesmanList salesmanList = new SalesmanList();
                salesmanList.LoadAndAddItem(-1, "(Select a salesman)");
                ddlSalesman.DataSource = salesmanList.Table;
                ddlSalesman.DataValueField = "SalesmanID";
                ddlSalesman.DataTextField = "FullName";
                ddlSalesman.DataBind();

                // StepLocationIn
                // StepSection1In
                Wizard.ActiveStepIndex = 0;
                StepTypeOfProjectIn();
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["User"] == null) Response.Redirect("Default.aspx");

        Date dt = new Date();
        SAPDB db = new SAPDB();
        SQLDB sql = new SQLDB();
        PeriodDB perdb = new PeriodDB();
        Person user = (Person)Session["User"];

        string role = "";
        string month_id = "";
        string year = "";
        string start_date = "";
        string end_date = "";

        if (Request.QueryString["rft"] != null)
        {
            EncryptedQueryString QueryString = new EncryptedQueryString(Request.QueryString["rft"]);
            if (QueryString["role"] != null) role = QueryString["role"].ToString();
            if (QueryString["month_id"] != null) month_id = QueryString["month_id"].ToString();
            if (QueryString["year"] != null) year = QueryString["year"].ToString();
            if (QueryString["start_date"] != null) start_date = QueryString["start_date"].ToString();
            if (QueryString["end_date"] != null) end_date = QueryString["end_date"].ToString();
        }

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

        EmployeeList emp_list = new EmployeeList();

        List<Employee> all_employees = db.getEmployeeListForReports(start_date, end_date, user.TabNum, role);

        if (all_employees == null)
        {
            MessageBox.Show("Невозможно сформировать отчет! Список сотрудников за период пуст!");
            return;
        }

        EmployeeComparerByFullnameASC emp_comp = new EmployeeComparerByFullnameASC();
        all_employees.Sort(emp_comp);

        Response.Clear();
        Response.Charset = "utf-8";
        Response.ContentType = "application/vnd.ms-excel";

        string str = @"<table cellspacing='0' cellpadding='0' border='1'>
                            <tr>
                                <td colspan='25' style='border: 0px; height: 30px; font-weight: bold;' align='center' valign='middle'>
                                    ОТЧЕТ
                                </td>
            <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
                            </tr>
                            <tr>
                                <td colspan='25' style='border: 0px; height: 30px;' align='center' valign='middle'>";
        str += "по фактически отработанному времени за " + per.MonthName.ToUpper() + " " + per.Year + " года</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";

        str += @"<tr>
                    <td rowspan='2' style='background-color: #99CCFF; font-weight: bold;' align='center'>
                            Таб. номер
                    </td>
                     <td rowspan='2' style='background-color: #99CCFF; font-weight: bold;' align='center'>
                            ФИО
                    </td>
                     <td rowspan='2' style='width:80px; background-color: #99CCFF; font-weight: bold;' align='center'>
                            Кол-во рабочих часов по графику (норма)
                    </td>
                    <td colspan='20' style='height: 30px;  background-color: #99CCFF; font-weight: bold;' align='center'>
                          ОТКЛОНЕНИЯ
                    </td>
                    <td rowspan='2' style='width:80px; background-color: #99CCFF; font-weight: bold;' align='center'>
                            Итого отработано часов за период (факт)
                    </td>
                     <td rowspan='2' style='width:80px; background-color: #99CCFF; font-weight: bold;' align='center'>
                            Итого отработано сверурочных часов
                    </td>
        <td rowspan='2'>&nbsp;</td><td rowspan='2'>&nbsp;</td><td rowspan='2'>&nbsp;</td>
                </tr>
                <tr>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Временная нетрудоспособность
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Выходные дни (еженедельный отпуск) и нерабочие праздничные дни
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Время простоя по вине работника
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Невыходы на время исполнения государственных или общественных обязанностей согласно законодательству
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Отпуск без сохранения заработной платы, предоставляемый работнику по разрешению работодателя
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Служебная командировка
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Неявки по невыясненным причинам (до выяснения обстоятельств)
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Время простоя по причинам, не зависящим от работодателя и работника
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Дополнительные выходные дни (оплачиваемые)
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Ежегодный дополнительный оплачиваемый отпуск
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Отпуск по уходу за ребенком до достижения им возраста трех лет
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Отпуск без сохранения заработной платы при условиях, предусмотренных действующим законодательством Российской Федерации
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Ежегодный основной оплачиваемый отпуск
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Повышение квалификации с отрывом от работы
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Прогулы (отсутствие на рабочем месте без уважительных причин в течение времени, установленного законодательством)
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Отпуск по беременности и родам (отпуск в связи с усыновлением новорожденного ребенка)
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Время простоя по вине работодателя
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Дополнительный отпуск в связи с обучением с сохранением среднего заработка работникам, совмещающим работу с обучением
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Дополнительный отпуск в связи с обучением без сохранения заработной платы
                    </td>
                    <td style='width:80px; background-color: #FFFF99; font-weight: bold;' align='center'>
                            Работа в выходные и праздничные дни
                    </td>

                </tr>
                ";

        foreach(Employee emp in all_employees)
        {
            decimal norma = 0;
            decimal overhours = 0;
            decimal def_sum = 0;

            Deflections d = new Deflections();

            List<HRHours> hr_current = sql.getHRHours(emp.EmployeeID, emp.StartPeriod, emp.BeginDate, emp.EndDate);
            List<Schedule> schedule = sql.getSchedule(emp.EmployeeID, emp.StartPeriod, emp.BeginDate, emp.EndDate);
            List<ScheduleDeflection> dschedule = sql.getScheduleDeflection(emp.EmployeeID, emp.StartPeriod, emp.BeginDate, emp.EndDate);

            foreach (Schedule sch in schedule)
            {
                // если выходной или изменение на выходной то пишем в отклонения по выходному дню
                if (((sch.DaySchedule == "FREE") && (Convert.ToInt32(sch.TimeHours) == 0)) || (sch.DayScheduleVar == "F"))
                    d.def_V += sch.TimeHours;
                else
                    norma += sch.TimeHours;
            }

            foreach (HRHours over in hr_current)
                overhours += (over.DayOverHours + over.NightOverHours);

            foreach (ScheduleDeflection sdf in dschedule)
            {

                def_sum += sdf.TimeHours;

                if (sdf.CodeT13.Equals("РВ"))
                {
                    def_sum -= sdf.TimeHours;       // убираем из поля Итого отработано по факту
                    overhours += sdf.TimeHours;          // записываем в поле Итого сверхурочных часов
                }

                switch (sdf.CodeT13)
                {
                    case "Б":
                        d.def_B += sdf.TimeHours;
                        break;
                    case "ВП":
                        d.def_VP += sdf.TimeHours;
                        break;
                    case "Г":
                        d.def_G += sdf.TimeHours;
                        break;
                    case "ДО":
                        d.def_DO += sdf.TimeHours;
                        break;
                    case "К":
                        d.def_K += sdf.TimeHours;
                        break;
                    case "НН":
                        d.def_NN += sdf.TimeHours;
                        break;
                    case "НП":
                        d.def_NP += sdf.TimeHours;
                        break;
                    case "ОВ":
                        d.def_OV += sdf.TimeHours;
                        break;
                    case "ОД":
                        d.def_OD += sdf.TimeHours;
                        break;
                    case "ОЖ":
                        d.def_OJ += sdf.TimeHours;
                        break;
                    case "ОЗ":
                        d.def_OZ += sdf.TimeHours;
                        break;
                    case "ОТ":
                        d.def_OT += sdf.TimeHours;
                        break;
                    case "ПК":
                        d.def_PK += sdf.TimeHours;
                        break;
                    case "ПР":
                        d.def_PR += sdf.TimeHours;
                        break;
                    case "Р":
                        d.def_R += sdf.TimeHours;
                        break;
                    case "РП":
                        d.def_RP += sdf.TimeHours;
                        break;
                    case "У":
                        d.def_U += sdf.TimeHours;
                        break;
                    case "УД":
                        d.def_UD += sdf.TimeHours;
                        break;
                    case "РВ":
                        d.def_RV += sdf.TimeHours;
                        break;
                    default:
                        break;

                }
            }
            str += "<tr>";
            str += "<td align='center'>" + DeleteZeroFromEmployeeID(emp.EmployeeID) + "</td>";
            str += "<td align='center'>" + emp.FullName + "</td>";

            if (norma != 0) str += "<td align='center'>" + norma.ToString() + "</td>";
            else  str += "<td>&nbsp;</td>";

            if (d.def_B != 0) str += "<td align='center'>" + d.def_B.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_V != 0) str += "<td align='center'>" + d.def_V.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_VP != 0) str += "<td align='center'>" + d.def_VP.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_G != 0) str += "<td align='center'>" + d.def_G.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_DO != 0) str += "<td align='center'>" + d.def_DO.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_K != 0) str += "<td align='center'>" + d.def_K.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_NN != 0) str += "<td align='center'>" + d.def_NN.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_NP != 0) str += "<td align='center'>" + d.def_NP.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_OV != 0) str += "<td align='center'>" + d.def_OV.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_OD != 0) str += "<td align='center'>" + d.def_OD.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_OJ != 0) str += "<td align='center'>" + d.def_OJ.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_OZ != 0) str += "<td align='center'>" + d.def_OZ.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_OT != 0) str += "<td align='center'>" + d.def_OT.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_PK != 0) str += "<td align='center'>" + d.def_PK.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_PR != 0) str += "<td align='center'>" + d.def_PR.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_R != 0) str += "<td align='center'>" + d.def_R.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_RP != 0) str += "<td align='center'>" + d.def_RP.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_U != 0) str += "<td align='center'>" + d.def_U.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_UD != 0) str += "<td align='center'>" + d.def_UD.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (d.def_RV != 0) str += "<td align='center'>" + d.def_RV.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if ((norma - def_sum) != 0) str += "<td align='center'>" + (norma - def_sum).ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            if (overhours != 0) str += "<td align='center'>" + overhours.ToString() + "</td>";
            else str += "<td>&nbsp;</td>";

            str += "<td>" + getCompany(emp.Department) + "</td><td>" + getPath(emp.Department) + "</td><td>" + getDepartment(emp.Department) + "</td>";

            str += "</tr>";

            str += "</tr>";

        }

        str += "</table>";

        Response.Write(str);
        Response.End();
    }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_VACATIONS_HOLIDAY_FULL_EDITING"])))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) && ((string)Request.QueryString["date_to_show"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in vacations_non_working_days_definition.aspx");
                }

                // Tag page
                // ... for non vacation managers
                EmployeeGateway employeeGatewayManager = new EmployeeGateway();
                int employeeIdNow = employeeGatewayManager.GetEmployeIdByLoginId(Convert.ToInt32(Session["loginID"]));
                employeeGatewayManager.LoadByEmployeeId(employeeIdNow);

                if (employeeGatewayManager.GetIsVacationsManager(employeeIdNow))
                {
                    hdfIsVacationManager.Value = "True";
                }
                else
                {
                    hdfIsVacationManager.Value = "False";
                }

                // Tag page
                ViewState["date_to_show"] = (string)Request.QueryString["date_to_show"];
                ViewState["level"] = "-1";
                int companyId = Int32.Parse(Session["companyID"].ToString());
                hdfCompanyId.Value = companyId.ToString();

                // Prepare initial data
                DropDownList ddlVacationsFor = (DropDownList)tkrpbLeftMenuAllVacations.FindItemByValue("nbVacationsForDDL").FindControl("ddlVacationsFor");
                EmployeeList employeeList = new EmployeeList();
                string employeeTypeNow = employeeGatewayManager.GetType(employeeIdNow);
                if (employeeTypeNow.Contains("CA"))
                {
                    employeeList.LoadBySalariedEmployeeTypeAndAddItem(1, "CA", -1, "(All)");
                }
                else
                {
                    employeeList.LoadBySalariedEmployeeTypeAndAddItem(1, "US", -1, "(All)");
                }
                ddlVacationsFor.DataSource = employeeList.Table;
                ddlVacationsFor.DataValueField = "EmployeeID";
                ddlVacationsFor.DataTextField = "FullName";
                ddlVacationsFor.DataBind();
                ddlVacationsFor.SelectedValue = Session["ddlVacationsForSelectedValue"].ToString();

                // ... For ddl working location
                companyLevels = new CompanyLevelsTDS();
                CompanyLevel companyLevel = new CompanyLevel(companyLevels);
                companyLevel.LoadNodes(companyId);
                GetNodeForCompanyLevel(1);
                int companyLevelId = 0;
                if (employeeTypeNow.Contains("CA"))
                {
                    ddlWorkingLocation.SelectedValue = "2";//Canada
                    companyLevelId = 2;
                }
                else
                {
                    ddlWorkingLocation.SelectedValue = "3";//Canada
                    companyLevelId = 3;
                }

                // ... Load non working days
                vacationsNonWorkingDaysInformationTDS = new VacationsNonWorkingDaysInformationTDS();
                nonWorkingDaysInformation = new VacationsNonWorkingDaysInformationTDS.NonWorkingDaysInformationDataTable();

                VacationsNonWorkingDaysInformationGateway vacationsNonWorkingDaysInformationGateway = new VacationsNonWorkingDaysInformationGateway(vacationsNonWorkingDaysInformationTDS);
                vacationsNonWorkingDaysInformationGateway.LoadByCompanyLevelId(companyLevelId, companyId);

                Session["vacationsNonWorkingDaysInformationTDS"] = vacationsNonWorkingDaysInformationTDS;
                Session["nonWorkingDaysInformation"] = vacationsNonWorkingDaysInformationTDS.NonWorkingDaysInformation;

                tkrsNonWorkingDays.SelectedDate = DateTime.Parse(ViewState["date_to_show"].ToString());

                // Databind
                Page.DataBind();
            }
            else
            {
                vacationsNonWorkingDaysInformationTDS = (VacationsNonWorkingDaysInformationTDS)Session["vacationsNonWorkingDaysInformationTDS"];
                nonWorkingDaysInformation = (VacationsNonWorkingDaysInformationTDS.NonWorkingDaysInformationDataTable)Session["nonWorkingDaysInformation"];
            }
        }
Beispiel #54
0
    // формируем html для графиков сотрудников
    public string DisplaySchedules(int count_days, int size, Employee emp, string role, bool check, bool is_closed_emp, string month, string year)
    {
        string html = "<table cellpadding='0' cellspacing='0' border='0' class='days_table_schedules' >";
        string time = "";
        string day_message = "";

        string timetable = "";
        string hr = "";
        string hrdoc = "";

        decimal sum_hour_timekeeper = 0;
        decimal sum_hour_schedule = 0;
        decimal sum_hour_hr = 0;

        string readonle = "";

        if (is_closed_emp == true) readonle = "readonly";

        int day = 1;

        EmployeeList emp_list = new EmployeeList();

        List<TimekeeperHours> current = emp_list.getEmployeesTimekeeperHours(emp.EmployeeID, emp.StartPeriod, emp.BeginDate, emp.EndDate);
        List<HRHours> hr_current = emp_list.getEmployeesHRHours(emp.EmployeeID, emp.StartPeriod, emp.BeginDate, emp.EndDate);
        List<Schedule> schedule = emp_list.getEmployeesSchedule(emp.EmployeeID, emp.StartPeriod, emp.BeginDate, emp.EndDate);
        List<ScheduleDeflection> dschedule = emp_list.getEmployeesScheduleDeflection(emp.EmployeeID, emp.StartPeriod, emp.BeginDate, emp.EndDate);

        // крутимся в цикле с основным графиком
        foreach (Schedule sch in schedule)
        {

            int d = Convert.ToInt32(sch.DayPeriod);
            // если у нас день не совпадает с днем в графике, заполняю пустым квадратом
            while (d != day)
            {
                if (day == count_days) break;
                time = "";
                timetable += "<td width='22px' style='padding-bottom: 2px;'><input type='text' class='timekeeper' readonly name='" + emp.EmployeeID + "+" + emp.PostID + "+" + emp.DepartmentID + "+" + emp.BeginDate + "+" + emp.EndDate + "+" + day.ToString() + "' value='' style='width: " + (size - 2) + "px; height: " + (size - 2) + "px; border: 1px #818181 solid; background-color:#EEEEEE' ></td>";
                hr += "<td width='22px' style='padding-bottom: 2px;'><div title='" + day.ToString() + "' style='width: " + size + "px; height: " + size + "px; border: 1px #818181 solid; background-color:#FED7AB;overflow: hidden; '><span class='day_number'>" + time + "</span></div></td>";
                hrdoc += "<td width='22px' style='padding-bottom: 2px;'><input type='text' value='' readonly maxlength='5' style='width: " + (size - 2) + "px; height: " + (size - 2) + "px; border: 1px #818181 solid; background-color:#D1E9E9; text-align: center; font-family: 'Trebuchet MS' , 'Times New Roman'; color: #000000; font-size: 8pt;'></td>";
                day++;
            }

            decimal hour_timekeeper = 0;
            decimal hour_schedule = 0;
            decimal hour_hr = 0;

            // если есть отклонение, пишем его, иначе выводим основной график
            ScheduleDeflection sd = dschedule.Find(delegate(ScheduleDeflection dsch) { return Convert.ToInt32(dsch.DayPeriod) == day; });
            if (sd != null)
            {

                decimal diversity = sch.TimeHours - sd.TimeHours;
                if (diversity == 0)
                {
                    // если отклонение с кодом 2000 или 2001 - Отзыв из отпуска, то в основной график проставляем часы. Это присутствие.
                    if (sd.AbsAttType.Equals("2000") || sd.AbsAttType.Equals("2001"))
                    {
                        time = CheckDecimalNumber(sd.TimeHours.ToString());
                        hour_schedule = Convert.ToDecimal(sd.TimeHours);
                    }
                    else
                        time = sd.CodeT13;
                }
                else
                {
                    if (diversity > 0)
                    {
                        time = CheckDecimalNumber(diversity.ToString());
                        hour_schedule = Convert.ToDecimal(diversity);
                    }
                    else
                    {
                        time = CheckDecimalNumber(sd.TimeHours.ToString());
                        hour_schedule = Convert.ToDecimal(sd.TimeHours);
                    }
                }
                hr += "<td width='22px' style='padding-bottom: 2px;'><div onmouseover='ShowFilter(\"helpsap\", event.clientX + document.body.scrollLeft, event.clientY + document.body.scrollTop);'  onmouseout='HideBlock(\"helpsap\");' style='width: " + size + "px; height: " + size + "px; border: 1px #818181 solid; background-color:#FED7AB;overflow: hidden; '><span class='day_number'>" + time + "</span></div></td>";

            }
            else
            {
                // если у нас выходной то вставляем в квадрат букву В - в русской раскладке!!!!!!!!
                if (((sch.DaySchedule == "FREE") && (Convert.ToDecimal(sch.TimeHours) == 0)) || (sch.DayScheduleVar == "F"))
                {
                    time = "В";  // В - в русской раскладке!!!!!!!!
                    hr += "<td width='22px' style='padding-bottom: 2px;'><div onmouseover='ShowFilter(\"helpsap\", event.clientX + document.body.scrollLeft, event.clientY + document.body.scrollTop);'  onmouseout='HideBlock(\"helpsap\");' style='width: " + size + "px; height: " + size + "px; border: 1px #818181 solid; background-color:#DCB589;overflow: hidden; '><span class='day_number'>" + time + "</span></div></td>";
                }
                else
                {
                    time = CheckDecimalNumber(sch.TimeHours.ToString());
                    hour_schedule = Convert.ToDecimal(sch.TimeHours);
                    hr += "<td width='22px' style='padding-bottom: 2px;'><div onmouseover='ShowFilter(\"helpsap\", event.clientX + document.body.scrollLeft, event.clientY + document.body.scrollTop);'  onmouseout='HideBlock(\"helpsap\");' style='width: " + size + "px; height: " + size + "px; border: 1px #818181 solid; background-color:#FED7AB;overflow: hidden; '><span class='day_number'>" + time + "</span></div></td>";
                }
            }

            // выводим график переработок
            string bgcolor = "#D1E9E9";
            HRHours hrh = hr_current.Find(delegate(HRHours h) { return h.Day == day.ToString(); });
            string hr_value = "";
            if (hrh != null)
            {
                hour_hr = hrh.DayOverHours + hrh.NightOverHours;
                hr_value = CheckDecimalNumber(hour_hr.ToString());
            }
            if (time == "В") bgcolor = "#A4C8B7";

            if ((hrh != null) && (hrh.NightOverHours != 0)) bgcolor = "#83abdc";
            hrdoc += "<td width='22px' style='padding-bottom: 2px;'><input type='text' value='" + hr_value + "' name='' readonly maxlength='5' style='width: " + (size - 2) + "px; height: " + (size - 2) + "px; border: 1px #818181 solid; background-color:" + bgcolor + "; text-align: center; font-family: 'Trebuchet MS' , 'Times New Roman'; color: #000000; font-size: 8pt;'></td>";

            // выводим график табельщика
            TimekeeperHours th = current.Find(delegate(TimekeeperHours h) { return h.Day == day.ToString(); });
            string value = "";
            if (th != null)
            {
                if (th.Hours >= 0)
                {
                    value = CheckDecimalNumber(th.Hours.ToString());
                    hour_timekeeper = th.Hours;
                }
                else
                {
                    value = th.Symbols;
                }
            }

            string color_check = "#EEEEEE";
            string color_check_timekeeper = "#FFFFFF";

            if (check)
            {
                decimal result = hour_timekeeper - hour_hr - hour_schedule;
                if (result != 0)
                {
                    color_check = "red";
                    color_check_timekeeper = "red";
                }

                if ((hour_timekeeper <= 0) && (!value.ToUpper().Equals(time)))
                {
                    color_check = "red";
                    color_check_timekeeper = "red";
                }
            }
            if ((role == "1") && (!is_closed_emp)) timetable += "<td width='22px' style='padding-bottom: 2px;'><span class='day_number'><input type='text' class='timekeeper' " + readonle + " value='" + value + "' name='" + emp.EmployeeID + "+" + emp.PostID + "+" + emp.DepartmentID + "+" + emp.BeginDate + "+" + emp.EndDate + "+" + day.ToString() + "' maxlength='5' style='width: " + (size - 2) + "px; height: " + (size - 2) + "px; border: 1px #818181 solid; text-align: center; background-color:" + color_check_timekeeper + "' onblur='CheckHourType(this)'></span></td>";
            else timetable += "<td width='22px' style='padding-bottom: 2px;'><input type='text' readonly value='" + value + "' name='' style='width: " + (size - 2) + "px; height: " + (size - 2) + "px; border: 1px #818181 solid; text-align: center; background-color:" + color_check + "' ></td>";

            sum_hour_timekeeper += hour_timekeeper;
            sum_hour_schedule += hour_schedule;
            sum_hour_hr += hour_hr;

            day++;
        }

        while (day <= count_days)
        {
            time = "";
            timetable += "<td width='22px' style='padding-bottom: 2px;'><input type='text' class='timekeeper' readonly name='" + emp.EmployeeID + "+" + emp.PostID + "+" + emp.DepartmentID + "+" + emp.BeginDate + "+" + emp.EndDate + "+" + day.ToString() + "' value='' style='width: " + (size - 2) + "px; height: " + (size - 2) + "px; border: 1px #818181 solid; background-color:#EEEEEE' ></td>";
            hr += "<td width='22px' style='padding-bottom: 2px;'><div title='" + day.ToString() + "' style='width: " + size + "px; height: " + size + "px; border: 1px #818181 solid; background-color:#FED7AB; overflow: hidden;'><span class='day_number'>" + time + "</span></div></td>";
            hrdoc += "<td width='22px' style='padding-bottom: 2px;'><input type='text' value='' readonly maxlength='5' style='width: " + (size - 2) + "px; height: " + (size - 2) + "px; border: 1px #818181 solid; background-color:#D1E9E9; text-align: center; font-family: 'Trebuchet MS' , 'Times New Roman'; color: #000000; font-size: 8pt;'></td>";
            day++;
        }

        html += "<tr>" + timetable + "<td style='padding-bottom: 2px;'><input type='text' value='" + CheckDecimalNumber(sum_hour_timekeeper.ToString()) + "' name='' readonly class='sum_timetable' ></td></tr>";
        html += "<tr>" + hr + "<td style='padding-bottom: 2px;'><input type='text' value='" + CheckDecimalNumber(sum_hour_schedule.ToString()) + "' name='' readonly class='sum_timetable' ></td></tr>";
        html += "<tr>" + hrdoc + "<td style='padding-bottom: 2px;'><input type='text' value='" + CheckDecimalNumber(sum_hour_hr.ToString()) + "' name='' readonly class='sum_timetable' ></td></tr>";

        html += "</table>";

        return html;
    }