コード例 #1
0
ファイル: CSQL.cs プロジェクト: ktvGIT/TestDB
        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
ファイル: CSQL.cs プロジェクト: ktvGIT/TestDB
        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
ファイル: CSQL.cs プロジェクト: ktvGIT/TestDB
        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
ファイル: CSQL.cs プロジェクト: ktvGIT/TestDB
        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);
        }