コード例 #1
0
ファイル: Form1.cs プロジェクト: DeneroDev/PayrollAssistant
        private void LoadAllWorker()
        {
            List <Worker> workers = CasheAllWorkerHelper.GetInstance().GetAllWorker();

            for (int i = 0; i < workers.Count; i++)
            {
                var lvi = new ListViewItem(workers[i].Id.ToString());
                lvi.SubItems.Add(workers[i].Name);
                lvi.SubItems.Add(workers[i].Date.ToShortDateString());
                lvi.SubItems.Add(workers[i].CurrentGroup.ToString());
                lvi.SubItems.Add("-");
                lvi.SubItems.Add(workers[i].GetCountAllSubordinate().ToString());
                if (workers[i].Chief != null)
                {
                    lvi.SubItems.Add(workers[i].Chief.Name);
                }
                else
                {
                    lvi.SubItems.Add("-");
                }

                // Add the list items to the ListView
                listView1.Items.Add(lvi);
            }
        }
コード例 #2
0
 public static CasheAllWorkerHelper GetInstance()
 {
     if (instance == null)
     {
         instance = new CasheAllWorkerHelper();
     }
     return(instance);
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: DeneroDev/PayrollAssistant
 private void DeleteBtn_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < listView1.SelectedItems.Count; i++)
     {
         var worker = CasheAllWorkerHelper.GetInstance().GetWorkerByID(int.Parse(listView1.SelectedItems[i].SubItems[0].Text));
         DBHelper.GetInstance().DeleteWorker(worker);
     }
     listView1.Items.Clear();
     DBHelper.GetInstance().LoadAllElementDB();
     LoadAllWorker();
 }
コード例 #4
0
        private void LoadAllChiefToList()
        {
            List <Worker> workers = CasheAllWorkerHelper.GetInstance().GetAllWorker();

            for (int i = 0; i < workers.Count; i++)
            {
                if (workers[i].CurrentGroup != Worker.Group.Employee)
                {
                    ChiefListBox.Items.Add(workers[i].Name);
                }
            }
        }
コード例 #5
0
        private void LoadAllChiefToList()
        {
            List <Worker> workers = CasheAllWorkerHelper.GetInstance().GetAllWorker();

            for (int i = 0; i < workers.Count; i++)
            {
                Console.WriteLine($"{workers[i].Id}/{int.Parse(IdLabel.Text)}");
                if (workers[i].CurrentGroup != Worker.Group.Employee && workers[i].Id != int.Parse(IdLabel.Text))
                {
                    ChiefListBox.Items.Add(workers[i].Name);
                }
            }
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: DeneroDev/PayrollAssistant
 private void ShowSubBtn_Click(object sender, EventArgs e)
 {
     SubListBox.Items.Clear();
     for (int i = 0; i < listView1.SelectedItems.Count; i++)
     {
         ListViewSubItemCollection subItems = listView1.SelectedItems[i].SubItems;
         Worker cw = CasheAllWorkerHelper.GetInstance()
                     .GetWorkerByID(int.Parse(subItems[0].Text));
         if (cw.Subbordinate != null)
         {
             SubListBox.Items.Add("-----------" + cw.Name + "-----------");
             for (int j = 0; j < cw.GetCountAllSubordinate(); j++)
             {
                 SubListBox.Items.Add(cw.Subbordinate[j].Name);
             }
         }
     }
 }
コード例 #7
0
        private void AddWorkerBtn_Click(object sender, EventArgs e)
        {
            if (FIOTextBox.Text != "" && GroupListBox.SelectedItem != null)
            {
                Enum.TryParse(GroupListBox.SelectedItem.ToString(), out Worker.Group currentGroup);
                var nc = new CurrentWorker(0,
                                           FIOTextBox.Text, DateTime.Parse(dateTimePicker1.Value.Date.ToShortDateString()),
                                           currentGroup);

                if (ChiefListBox.SelectedItems.Count > 0)
                {
                    nc.UpdateChief(CasheAllWorkerHelper.GetInstance().GetWorkerByName(ChiefListBox.SelectedItem.ToString()));
                }

                DBHelper.GetInstance().AddWorker(nc);
                DialogResult = DialogResult.OK;
                Hide();
            }
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: DeneroDev/PayrollAssistant
 private void CalculateSalaryBtn_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < listView1.SelectedItems.Count; i++)
     {
         ListViewSubItemCollection subItems = listView1.SelectedItems[i].SubItems;
         var cw = CasheAllWorkerHelper.GetInstance()
                  .GetWorkerByID(int.Parse(subItems[0].Text));
         //Worker cw = group.CurrentGroup.Equals(Worker.Group.Employee) ? (Employee)group
         //    : (group.CurrentGroup.Equals(Worker.Group.Manager)) ? (Manager)group
         //    : (group.CurrentGroup.Equals(Worker.Group.Salesman)) ? (Salesman)group : group;
         float salary = cw.GetPayroll(DateTime.Parse(dateTimePicker1.Value.Date.ToShortDateString()),
                                      (DateTime.Parse(dateTimePicker2.Value.Date.ToShortDateString())));
         if (salary == 0)
         {
             subItems[4].Text = "ERROR DATE";
         }
         else
         {
             subItems[4].Text = salary.ToString();
         }
     }
 }
コード例 #9
0
 private void UpdateBtn_Click(object sender, EventArgs e)
 {
     if (FIOTextBox.Text != "" && GroupListBox.SelectedItem != null)
     {
         var nc = CasheAllWorkerHelper.GetInstance().GetWorkerByID(int.Parse(IdLabel.Text));
         if (ChiefListBox.SelectedItems.Count > 0)
         {
             nc.UpdateChief(CasheAllWorkerHelper.GetInstance().GetWorkerByName(ChiefListBox.SelectedItem.ToString()));
         }
         else
         {
             nc.Chief = null;
         }
         nc.Name = FIOTextBox.Text;
         nc.Date = DateTime.Parse(dateTimePicker1.Value.Date.ToShortDateString());
         Enum.TryParse(GroupListBox.SelectedItem.ToString(), out Worker.Group group);
         nc.CurrentGroup = group;
         DBHelper.GetInstance().UpdateWorker(nc);
         DialogResult = DialogResult.OK;
         Hide();
     }
 }
コード例 #10
0
ファイル: Form1.cs プロジェクト: DeneroDev/PayrollAssistant
 private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     DBHelper.GetInstance().SaveResult(CasheAllWorkerHelper.GetInstance().GetAllWorker());
     DBHelper.GetInstance().CloseDB();
 }
コード例 #11
0
        public void LoadAllElementDB()
        {
            if (DB != null)
            {
                CasheAllWorkerHelper.GetInstance().ClearAllWorker();
                SQLiteCommand CMD = DB.CreateCommand();
                CMD.CommandText = "select * from " + TABLE_NAME;
                // SQLiteDataReader dr = CMD.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
                SQLiteDataAdapter da = new SQLiteDataAdapter(CMD.CommandText, DB);
                DataSet           ds = new System.Data.DataSet();
                da.Fill(ds);
                DataTable dtable = ds.Tables[0];
                for (int i = 0; i < dtable.Rows.Count; i++)
                {
                    DataRow drow = dtable.Rows[i];
                    if (drow.RowState != DataRowState.Deleted)
                    {
                        Enum.TryParse(drow["Группа"].ToString(), out Worker.Group currentGroup);
                        Worker worker;
                        switch (currentGroup)
                        {
                        case Worker.Group.Employee:
                            worker = new Employee(int.Parse(drow["ID"].ToString()), drow["Имя"].ToString()
                                                  , DateTime.Parse(drow["ДатаПоступления"].ToString())
                                                  , currentGroup);
                            break;

                        case Worker.Group.Manager:
                            worker = new Manager(int.Parse(drow["ID"].ToString()), drow["Имя"].ToString()
                                                 , DateTime.Parse(drow["ДатаПоступления"].ToString())
                                                 , currentGroup);
                            break;

                        case Worker.Group.Salesman:
                            worker = new Salesman(int.Parse(drow["ID"].ToString()), drow["Имя"].ToString()
                                                  , DateTime.Parse(drow["ДатаПоступления"].ToString())
                                                  , currentGroup);
                            break;

                        default:
                            worker = new Employee(int.Parse(drow["ID"].ToString()), drow["Имя"].ToString()
                                                  , DateTime.Parse(drow["ДатаПоступления"].ToString())
                                                  , currentGroup);
                            break;
                        }



                        CasheAllWorkerHelper.GetInstance().AddWorker(worker);
                        if (drow["Подчиненные"].ToString() != "")
                        {
                            string[] ids = drow["Подчиненные"].ToString().Split(',');
                            for (int j = 0; j < ids.Length; j++)
                            {
                                worker.Idssubb.Add(ids[j]);
                            }
                        }
                        if (drow["Начальник"].ToString() != "-")
                        {
                            worker.Idchief = drow["Начальник"].ToString();
                        }
                        //      Console.WriteLine("ID_ADDED:" + worker.GetID());
                    }
                }

                CasheAllWorkerHelper.GetInstance().CalculateChiefAndSub();
            }
        }