コード例 #1
0
        private void GetTasks(MySqlConnection conn)
        {
            if (executors.Count != 0)
            {
                MySqlDataAdapter adapter = null;

                tasksList = new ObservableCollection <TaskTable>();

                dt = new DataTable("tasks");
                dbHandler db = new dbHandler();

                foreach (KeyValuePair <int, string> keyValue in executors)
                {
                    MySqlCommand command = new MySqlCommand("SELECT id, Performer, Name, Status FROM `tasks` WHERE Performer = '" + keyValue.Key + "' AND Deleted = 0", conn);
                    command.ExecuteNonQuery();
                    adapter = new MySqlDataAdapter(command);
                    adapter.Fill(dt);
                }

                foreach (DataRow row in dt.Rows)
                {
                    var name     = Convert.ToString(row[2]);
                    var status   = Convert.ToString(row[3]);
                    var executor = db.GetUser(Convert.ToInt32(row[1]));

                    tasksList.Add(new TaskTable(name, status, executor));
                }

                TasksDG.ItemsSource = tasksList;
                adapter.Update(dt);
            }
        }
コード例 #2
0
        private void Coefficients_Loaded(object sender, RoutedEventArgs e)
        {
            MySqlConnection conn = DBUtils.GetDBConnection();

            conn.Open();
            try
            {
                dbHandler db = new dbHandler();
                coeffList = db.GetCoefficients(conn, id);
                Jun.Text  = Convert.ToString(coeffList[0]);
                Mid.Text  = Convert.ToString(coeffList[1]);
                Sen.Text  = Convert.ToString(coeffList[2]);
                Ana.Text  = Convert.ToString(coeffList[3]);
                Dep.Text  = Convert.ToString(coeffList[4]);
                Sup.Text  = Convert.ToString(coeffList[5]);
                DR.Text   = Convert.ToString(coeffList[6]);
                TR.Text   = Convert.ToString(coeffList[7]);
                CE.Text   = Convert.ToString(coeffList[8]);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
コード例 #3
0
        private void GetTasks(MySqlConnection conn)
        {
            MySqlCommand command = new MySqlCommand("SELECT id, Performer, Name, Status, NeedTime, EndTime FROM `tasks` WHERE Performer = '" + id + "'", conn);

            command.ExecuteNonQuery();

            MySqlDataAdapter adapter = new MySqlDataAdapter(command);

            tasksList = new ObservableCollection <TaskTable>();
            dt        = new DataTable("tasks");
            dbHandler db = new dbHandler();

            adapter.Fill(dt);

            foreach (DataRow row in dt.Rows)
            {
                var name      = Convert.ToString(row[2]);
                var status    = Convert.ToString(row[3]);
                var managerId = db.GetManager(Convert.ToInt32(row[1]));
                var manager   = db.GetUser(managerId);

                tasksList.Add(new TaskTable(name, status, manager));
            }

            TasksDG.ItemsSource = tasksList;
            adapter.Update(dt);
        }
コード例 #4
0
        private void AddTask_Loaded(object sender, RoutedEventArgs e)
        {
            if (taskID == 0)
            {
                typeList = new List <string>()
                {
                    "Анализ и проектирование", "Установка оборудования", "Техническое обслуживание и сопровождение"
                };
                TypeCB.ItemsSource = typeList;
                StatusTB.Text      = "Запланирована";
            }
            else
            {
                NameField.IsReadOnly       = true;
                DescTB.IsReadOnly          = true;
                ComplexityField.IsReadOnly = true;
                NeedTime.IsReadOnly        = true;
                AddBtn.IsEnabled           = false;
            }
            MySqlConnection conn = DBUtils.GetDBConnection();

            conn.Open();
            try
            {
                if (taskID == 0)
                {
                    List <string> perfList = new List <string>();
                    dbHandler     db       = new dbHandler();
                    executors = db.GetExecutors(conn, id);
                    foreach (KeyValuePair <int, string> keyValue in executors)
                    {
                        perfList.Add(keyValue.Value);
                    }
                    PerfCB.ItemsSource = perfList;
                }
                else
                {
                    GetTask(conn, taskID);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
コード例 #5
0
        private void GetExList(MySqlConnection conn)
        {
            DataTable dt = new DataTable("ex");
            dbHandler db = new dbHandler();

            MySqlCommand command = new MySqlCommand("SELECT id, FullName, Grade FROM `users` WHERE TypeUser = '******'", conn);

            command.ExecuteNonQuery();
            MySqlDataAdapter adapter = new MySqlDataAdapter(command);

            adapter.Fill(dt);

            foreach (DataRow row in dt.Rows)
            {
                var fullName  = Convert.ToString(row[1]);
                var grade     = Convert.ToString(row[2]);
                var managerId = db.GetManager(Convert.ToInt32(row[0]));
                var manager   = db.GetUser(managerId);
                exList.Add(new ExecutorTable(fullName, grade, manager));
            }
        }
コード例 #6
0
ファイル: Payroll.xaml.cs プロジェクト: TanyaTitova/EsoftApp
        private void SalaryBtn_Click(object sender, RoutedEventArgs e)
        {
            MySqlConnection conn = DBUtils.GetDBConnection();

            conn.Open();
            try
            {
                dbHandler db = new dbHandler();
                coeffList = db.GetCoefficients(conn, id);
                executors = db.GetExecutors(conn, id);
                GetSalary(conn);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
コード例 #7
0
        private void Manager_Loaded(object sender, RoutedEventArgs e)
        {
            LoginLabel.Content    = "Ваш логин: " + login;
            FullNameLabel.Content = "ФИО Менеджера: " + fullName;

            var statusList = new List <string>()
            {
                "Любой статус", "Запланирована", "Выполняется", "Завершена", "Отменена"
            };

            StatusCB.ItemsSource = statusList;


            MySqlConnection conn = DBUtils.GetDBConnection();

            conn.Open();
            try
            {
                dbHandler db = new dbHandler();
                executors = db.GetExecutors(conn, id);
                ExecutorsCB.Items.Add("Все исполнители");
                foreach (KeyValuePair <int, string> keyValue in executors)
                {
                    ExecutorsCB.Items.Add(keyValue.Value);
                }
                GetTasks(conn);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
コード例 #8
0
ファイル: Payroll.xaml.cs プロジェクト: TanyaTitova/EsoftApp
        private void GetSalary(MySqlConnection conn)
        {
            if (executors.Count != 0)
            {
                MySqlDataAdapter adapter = null;

                salaryList = new ObservableCollection <SalaryTable>();

                foreach (KeyValuePair <int, string> keyValue in executors)
                {
                    dt = new DataTable("tasks");

                    MySqlCommand command = new MySqlCommand("SELECT Complexity, TypeWork, NeedTime, EndTime FROM `tasks` WHERE Performer = '" + keyValue.Key + "' AND Deleted = 0 AND Status = 'Завершена'", conn);
                    command.ExecuteNonQuery();

                    adapter = new MySqlDataAdapter(command);
                    adapter.Fill(dt);

                    double salary = 0;


                    double typeCoeff;

                    foreach (DataRow row in dt.Rows)
                    {
                        dbHandler db = new dbHandler();

                        var grade       = 0.0;
                        var gradeString = db.GetGrade(conn, keyValue.Key);
                        if (gradeString.Equals("junior"))
                        {
                            grade = coeffList[0];
                        }
                        else if (gradeString.Equals("middle"))
                        {
                            grade = coeffList[1];
                        }
                        else
                        {
                            grade = coeffList[2];
                        }

                        var comp = Convert.ToDouble(row[0]);
                        var type = row[1].ToString();
                        if (type.Equals("Анализ и проектирование"))
                        {
                            typeCoeff = coeffList[3];
                        }
                        else if (type.Equals("Установка оборудования"))
                        {
                            typeCoeff = coeffList[4];
                        }
                        else
                        {
                            typeCoeff = coeffList[5];
                        }
                        var timeSpan = Convert.ToDateTime(row[2]) - Convert.ToDateTime(row[3]);
                        var time     = (timeSpan.Days * 24 + timeSpan.Hours) * 60 + timeSpan.Minutes;
                        var DR       = coeffList[6];
                        var TR       = coeffList[7];
                        var CE       = coeffList[8];

                        salary = (typeCoeff + comp * DR + time * TR) * CE + salary;
                        salary = grade + salary;
                        salaryList.Add(new SalaryTable(keyValue.Value, salary));
                    }

                    SalaryDG.ItemsSource = salaryList;
                }
            }
        }