public Worker GetWorkerUseID(int id) { SQLiteCommand CMD = DB.CreateCommand(); CMD.CommandText = "select * from " + TABLE_NAME + " where ID like '%' || @id"; CMD.Parameters.Add("@id", System.Data.DbType.Int32).Value = id; SQLiteDataReader drow = CMD.ExecuteReader(); if (drow.HasRows) { while (drow.Read()) { Enum.TryParse(drow["Группа"].ToString(), out Worker.Group currentGroup); CurrentWorker worker = new CurrentWorker(int.Parse(drow["ID"].ToString()), drow["Имя"].ToString() , DateTime.Parse(drow["ДатаПоступления"].ToString()) , currentGroup); return(worker); } return(null); } else { return(null); } }
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(); } }