public void onRewriteEmploy(Emp_v2 emp) { nameTBox.Text = emp.Name; groupBox.Value = emp.group; rGiveOrderChBox.Checked = emp.RuleGiveOrder; rForePersonChBox.Checked = emp.RuleForePerson; }
private void addButton_Click(object sender, EventArgs e) { if (nameTBox.Text != "" && groupBox.Value != 0) { Emp_v2 newEmp = new Emp_v2(nameTBox.Text, (int)groupBox.Value, rGiveOrderChBox.Checked, rForePersonChBox.Checked); ListEmps.Add(newEmp); onRewriteListBox(ListEmps); } }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { ListBox lb = sender as ListBox; if (lb.SelectedIndex != -1) { SelEmp = Emps[lb.SelectedIndex]; Hide(); } }
private void FrmEmploy_Load(object sender, EventArgs e) { listBox1.Items.Clear(); SelEmp = null; if (_emps != null) { for (int i = 0; i <= _emps.Count - 1; i++) { listBox1.Items.Add(_emps[i]); } } }
private void editButton_Click(object sender, EventArgs e) { if (nameTBox.Text != "" && groupBox.Value != 0) { Emp_v2 editEmp = new Emp_v2(nameTBox.Text, (int)groupBox.Value, rGiveOrderChBox.Checked, rForePersonChBox.Checked); if (listEmpLBox.SelectedIndex != -1) { ListEmps[listEmpLBox.SelectedIndex] = editEmp; onRewriteListBox(ListEmps); SaveButton.ForeColor = Color.Red; } } }
/// <summary> /// Проверка на повторяющихся работников /// </summary> /// <param name="emp">Добовляемый работник</param> /// <returns>true если уже есть</returns> public bool DublEmpOfOrder(Emp_v2 emp) { bool result = false; /* * if (emp != null) * { * * for (int i = 0; i <= Order.brigada.Count - 1; i++) * { * if (Order.brigada[i] != null) * { * if (Order.brigada[i].Name == emp.Name) * { * result = true; * break; * } * } * } * if (Order.GiveOrder.Name == emp.Name) result = true; * if (Order.ForePerson.Name == emp.Name) result = true; * }*/ return(result); }
/// <summary> /// Ввод данных в Excel /// </summary> /// <param name="giveorder">Отдающий распоряжение</param> /// <param name="foreperson">Производитель работ</param> /// <param name="Team">Бригада</param> /// <param name="date">Дата</param> /// <param name="estr">Поручается</param> /// <param name="instr">Иструктаж</param> /// <param name="dop_instr">Другие указания</param> /// <returns>true если успешно введены</returns> public bool AddOrder(Emp_v2 giveorder, Emp_v2 foreperson, List <Emp_v2> Team, string date, string estr, string instr, string dop_instr) { bool result = false; Excel excel = new Excel(); try { excel.OpenDocument(Application.StartupPath + "\\Order1.xltx"); excel.Visible = true; excel.SetValue("D6", date); if (estr.Length > 60) { string[] strArray1 = estr.Split(Convert.ToChar(" ")); int index1 = 0; string[] strArray2 = new string[4] { "", "", "", "" }; foreach (string str in strArray1) { string[] strArray3; int index2; (strArray3 = strArray2)[(int)(index2 = (int)index1)] = strArray3[index2] + str + " "; if (strArray2[index1].Length > 60) { ++index1; } } if (strArray2[0].Length != 0) { excel.SetValue("D8", strArray2[0]); } if (strArray2[1].Length != 0) { excel.SetValue("D9", strArray2[1]); } if (strArray2[2].Length != 0) { excel.SetValue("D10", strArray2[2]); } if (strArray2[3].Length != 0) { excel.SetValue("D11", strArray2[3]); } } else { excel.SetValue("D8", estr); } excel.SetValue("E15", giveorder.ToString()); excel.SetValue("I15", foreperson.ToString()); excel.SetValue("I20", foreperson.ToString()); excel.SetValue("I24", Team[0].ToString()); if (Team.Count > 1 && Team[1] != null) { excel.SetValue("I26", Team[1].ToString()); } if (Team.Count > 2 && Team[2] != null) { excel.SetValue("I28", Team[2].ToString()); } if (Team.Count > 3 && Team[3] != null) { excel.SetValue("I30", Team[3].ToString()); } if (instr.Length > 70) { string[] strArray1 = instr.Split(Convert.ToChar(" ")); int index1 = 0; string[] strArray2 = new string[4] { "", "", "", "" }; foreach (string str in strArray1) { string[] strArray3; int index2; (strArray3 = strArray2)[(int)(index2 = (int)index1)] = strArray3[index2] + str + " "; if (strArray2[index1].Length > 70) { ++index1; } } if (strArray2[0].Length != 0) { excel.SetValue("G33", strArray2[0]); } if (strArray2[1].Length != 0) { excel.SetValue("G34", strArray2[1]); } if (strArray2[2].Length != 0) { excel.SetValue("G35", strArray2[2]); } if (strArray2[3].Length == 0) { excel.SetValue("G36", strArray2[3]); } } else { excel.SetValue("G33", instr); } excel.SetValue("C45", DOP_INSTR + dop_instr); result = true; } catch (Exception ex) { new Log("Out of Excel " + ex.Message); } return(result); }