Пример #1
0
        public static void UpdateEmployee(CEmployee employee)
        {
            string Sql = string.Format(@"UPDATE [dbo].[Empoyee]
                                           SET [SurName] = '{0}'
                                               ,[FirstName] = '{1}'
                                              ,[Patronymic] ='{2}'
                                              ,[DateOfBirth] = convert(varchar, convert(datetime, '{3}', 104), 121)
                                              ,[DocSeries] = '{4}'
                                              ,[DocNumber] ='{5}'
                                              ,[Position] = '{6}'
                                              ,[DepartmentID] = '{7}'
                                         WHERE ID='{8}'
                                                            ",
                                       employee.FirstName,
                                       employee.SurName,
                                       employee.Patronymic,
                                       Convert.ToDateTime(employee.DateOfBirth),
                                       employee.DocSeries,
                                       employee.DocNumber,
                                       employee.Position,
                                       employee.GetDepartmentID(),
                                       employee.ID);
            CBranch Branch = new CBranch(Sql);

            Branch.ExecSql();
            Branch.Dispose();
        }
Пример #2
0
        public static void InsertIntoEmployee(CEmployee employee)
        {
            string Sql = string.Format(@"  INSERT INTO[dbo].[Empoyee]
                                                        ([FirstName]
                                                          ,[SurName]
                                                          ,[Patronymic]
                                                          ,[DateOfBirth]
                                                          ,[DocSeries]
                                                          ,[DocNumber]
                                                          ,[Position]
                                                          ,[DepartmentID])
                                                    VALUES (
                                                            '{0}',
                                                            '{1}',
                                                            '{2}',
                                                            convert(varchar, convert(datetime, '{3}', 104), 121),
                                                            '{4}',
                                                            '{5}',
                                                            '{6}',
                                                            '{7}')
                                                            ",
                                       employee.FirstName,
                                       employee.SurName,
                                       employee.Patronymic,
                                       Convert.ToDateTime(employee.DateOfBirth),
                                       employee.DocSeries,
                                       employee.DocNumber,
                                       employee.Position,
                                       employee.GetDepartmentID());
            CBranch Branch = new CBranch(Sql);

            Branch.ExecSql();
            Branch.Dispose();
        }
Пример #3
0
        public static void DeleteFromEmployee(CEmployee employee)
        {
            string  Sql    = string.Format(@"DELETE FROM [dbo].[Empoyee]
                                                        WHERE ID='{0}'
                                                        ", employee.ID);
            CBranch Branch = new CBranch(Sql);

            Branch.ExecSql();
            Branch.Dispose();
        }
Пример #4
0
        public static void UpdateDeptIDInEmployee(CEmployee employee)
        {
            string Sql = string.Format(@"UPDATE [dbo].[Empoyee]
                                           SET [DepartmentID] = '{0}'
                                         WHERE ID='{1}'
                                                            ",

                                       employee.GetDepartmentID(),
                                       employee.ID);
            CBranch Branch = new CBranch(Sql);

            Branch.ExecSql();
            Branch.Dispose();
        }
Пример #5
0
        public static List <string> GetEmployeeValues(CEmployee employee)
        {
            List <string> values = new List <string>();
            Type          t      = employee.GetType();

            PropertyInfo[] properties = t.GetProperties();
            foreach (PropertyInfo fil in properties)
            {
                if (fil.Name != "Item")
                {
                    values.Add(fil.GetValue(employee, null).ToString());
                }
            }
            return(values);
        }
Пример #6
0
        public List <CEmployee> GetEmployees()
        {
            List <CEmployee> Employees = new List <CEmployee>();

            SqlDataReader reader = mCmd.ExecuteReader();

            while (reader.Read())
            {
                CEmployee Employee = new CEmployee(reader["ID"].ToString() ?? "",
                                                   reader["DepartmentID"].ToString() ?? "",
                                                   reader["FirstName"].ToString() ?? "",
                                                   reader["SurName"].ToString() ?? "",
                                                   reader["Patronymic"].ToString() ?? "",
                                                   (Convert.ToDateTime(reader["DateOfBirth"])).ToString("dd.MM.yyyy") ?? "",
                                                   reader["DocSeries"].ToString() ?? "",
                                                   reader["DocNumber"].ToString() ?? "",
                                                   reader["Position"].ToString() ?? "",
                                                   reader["DeptName"].ToString() ?? "");
                Employees.Add(Employee);
            }
            reader.Dispose();

            return(Employees);
        }