diff --git a/.vs/Diplom O/v16/.suo b/.vs/Diplom O/v16/.suo index 3157c9b..e09b209 100644 Binary files a/.vs/Diplom O/v16/.suo and b/.vs/Diplom O/v16/.suo differ diff --git a/DataBase/ConnectDB.cs b/DataBase/ConnectDB.cs index 03b2660..3a4b5fd 100644 --- a/DataBase/ConnectDB.cs +++ b/DataBase/ConnectDB.cs @@ -15,6 +15,7 @@ namespace Diplom_O.DataBase public DbSet Shtat { get; set; } public DbSet Rabotniky { get; set; } public DbSet Chely { get; set; } + public DbSet ChelToChely { get; set; } public MainDB() { @@ -71,6 +72,19 @@ namespace Diplom_O.DataBase public string Pasport { get; set; } public List Rabota { get; set; } } + public class ChelToChel + { + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int Id { get; set; } + [ForeignKey("Chel1")] + public int Chel1Id { get; set; } + public Chel Chel1 { get; set; } + [ForeignKey("Chel2")] + public int Chel2Id { get; set; } + public Chel Chel2 { get; set; } + public int Lvl { get; set; } + } + diff --git a/DataBase/FuncDB.cs b/DataBase/FuncDB.cs index 9315bfe..854c2a1 100644 --- a/DataBase/FuncDB.cs +++ b/DataBase/FuncDB.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; namespace Diplom_O.DataBase @@ -130,6 +131,20 @@ namespace Diplom_O.DataBase catch { throw; } } + public static void ChkChel(Chel chel) + { + try + { + if (string.IsNullOrEmpty(chel.FName)) throw new Exception("Фамилия не указана."); + if (string.IsNullOrEmpty(chel.SName)) throw new Exception("Имя не указано."); + if (chel.Birthday > DateTime.Now) throw new Exception("Дата рождения не верна."); + var rgx = new Regex("^[0-9]{12}$"); + if (!rgx.IsMatch(chel.INN)) throw new Exception("ИНН указан неверно."); + rgx = new Regex("^[0-9]{3}-[0-9]{3}-[0-9]{3} [0-9]{2}$"); + if (!rgx.IsMatch(chel.SNILS)) throw new Exception("СНИЛС указан неверно."); + } + catch { throw; } + } public static Chel GetChel(int id) { try @@ -170,7 +185,7 @@ namespace Diplom_O.DataBase } catch { throw; } } - public static bool HaveChelFromRabotniky(int id, bool all=false) + public static bool HaveChelRabotnik(int id, bool all=false) { try { @@ -184,6 +199,126 @@ namespace Diplom_O.DataBase } catch { throw; } } + public static void AddChel(Chel chel) + { + try + { + ChkChel(chel); + using (var db = new MainDB()) + { + db.Chely.Add(chel); + db.SaveChanges(); + } + } + catch { throw; } + } + public static void ChangeChel(Chel chel) + { + try + { + ChkChel(chel); + if (GetChel(chel.Id) == null) throw new Exception("Человека не существует."); + using (var db = new MainDB()) + { + db.Chely.Update(chel); + db.SaveChanges(); + } + } + catch { throw; } + } + public static void DelChel(Chel chel) + { + try + { + ChkChel(chel); + if (GetChel(chel.Id) == null) throw new Exception("Человека не существует."); + if (HaveChelRabotnik(chel.Id, true)) throw new Exception("Человек есть в таблице работников."); + using (var db = new MainDB()) + { + db.Chely.Remove(chel); + db.SaveChanges(); + } + } + catch { throw; } + } + public static bool HaveChelToChel(int id) + { + try + { + using (var db = new MainDB()) + { + var res = (from a in db.ChelToChely + where a.Chel1Id == id || a.Chel2Id == id + select a).Count(); + return res > 0; + } + } + catch { throw; } + } + public static bool CanBirthdayChelToChel(int id, DateTime date) + { + try + { + using (var db = new MainDB()) + { + var res = (from a in db.ChelToChely + join b in db.Chely on a.Chel2Id equals b.Id + join c in db.Chely on a.Chel1Id equals c.Id + where (a.Chel1Id == id && date > b.Birthday) || + (a.Chel2Id == id && date < c.Birthday) + select a).Count(); + return res == 0; + } + } + catch { throw; } + } + public static (int chelToChelId, Chel chel, int lvl)[] ListRodFromChel(int id) + { + try + { + var rodChel = new List<(int chelToChelId, Chel chel, int lvl)>(); + using (var db = new MainDB()) + { + var parents = new List<(Chel chel,int lvl)>() { (GetChel(id), 0) }; + var childrens = new List<(Chel chel, int lvl)>() { (GetChel(id), 0) }; + while (parents.Count > 0 || childrens.Count > 0) + { + var newParents = new List<(Chel chel, int lvl)>(); + var newChildrens = new List<(Chel chel, int lvl)>(); + for(var i = 0; i < parents.Count || i < childrens.Count; i++) + { + var parentsLinks = + (from a in db.ChelToChely + where (i < parents.Count) && a.Chel2Id == parents[i].chel.Id + select a).ToArray(); + var childrensLinks = + (from a in db.ChelToChely + where (i < childrens.Count) && a.Chel1Id == childrens[i].chel.Id + select a).ToArray(); + for (var j = 0; j < parentsLinks.Length || j < childrensLinks.Length; j++) + { + var chel = j < parentsLinks.Length ? GetChel(parentsLinks[j].Chel1Id) : null; + if (chel != null && rodChel.FindAll(x => x.chel.Id == chel.Id).Count == 0) + { + rodChel.Add((parentsLinks[j].Id, chel, parents[i].lvl - parentsLinks[j].Lvl)); + newParents.Add((chel, parents[i].lvl - parentsLinks[j].Lvl)); + } + chel = j < childrensLinks.Length ? GetChel(childrensLinks[j].Chel2Id) : null; + if (chel != null && rodChel.FindAll(x => x.chel.Id == chel.Id).Count == 0) + { + rodChel.Add((childrensLinks[j].Id, chel, childrens[i].lvl + childrensLinks[j].Lvl)); + newChildrens.Add((chel, childrens[i].lvl + childrensLinks[j].Lvl)); + } + } + } + parents = newParents; + childrens = newChildrens; + } + } + return rodChel.OrderByDescending(x => x.lvl).ToArray(); + } + catch { throw; } + } } } diff --git a/MainForms/ChelForm.Designer.cs b/MainForms/ChelForm.Designer.cs index 020c963..82bbbe6 100644 --- a/MainForms/ChelForm.Designer.cs +++ b/MainForms/ChelForm.Designer.cs @@ -37,13 +37,13 @@ namespace Diplom_O this.errorLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.button1 = new System.Windows.Forms.Button(); + this.rodGridView = new System.Windows.Forms.DataGridView(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.linkLabel1 = new System.Windows.Forms.LinkLabel(); this.delRodButton = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); this.changeRodButton = new System.Windows.Forms.Button(); this.addRodButton = new System.Windows.Forms.Button(); - this.linkLabel1 = new System.Windows.Forms.LinkLabel(); - this.comboBox1 = new System.Windows.Forms.ComboBox(); - this.rodGridView = new System.Windows.Forms.DataGridView(); this.chelGridView = new System.Windows.Forms.DataGridView(); this.selectButton = new System.Windows.Forms.Button(); this.delButton = new System.Windows.Forms.Button(); @@ -69,7 +69,7 @@ namespace Diplom_O this.chelRodMI}); this.menuStrip.Location = new System.Drawing.Point(0, 0); this.menuStrip.Name = "menuStrip"; - this.menuStrip.Size = new System.Drawing.Size(1102, 24); + this.menuStrip.Size = new System.Drawing.Size(1144, 24); this.menuStrip.TabIndex = 1; this.menuStrip.Text = "menuStrip1"; // @@ -110,16 +110,15 @@ namespace Diplom_O // this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.errorLabel}); - this.statusStrip1.Location = new System.Drawing.Point(0, 545); + this.statusStrip1.Location = new System.Drawing.Point(0, 386); this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(1102, 22); + this.statusStrip1.Size = new System.Drawing.Size(1144, 22); this.statusStrip1.TabIndex = 16; this.statusStrip1.Text = "statusStrip1"; // // groupBox1 // - this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox1.Controls.Add(this.rodGridView); this.groupBox1.Controls.Add(this.comboBox1); @@ -128,21 +127,50 @@ namespace Diplom_O this.groupBox1.Controls.Add(this.button1); this.groupBox1.Controls.Add(this.changeRodButton); this.groupBox1.Controls.Add(this.addRodButton); - this.groupBox1.Location = new System.Drawing.Point(760, 27); + this.groupBox1.Location = new System.Drawing.Point(802, 27); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(330, 515); + this.groupBox1.Size = new System.Drawing.Size(330, 356); this.groupBox1.TabIndex = 26; this.groupBox1.TabStop = false; this.groupBox1.Text = "Родственники"; // - // button1 + // rodGridView // - this.button1.Location = new System.Drawing.Point(6, 19); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(25, 23); - this.button1.TabIndex = 27; - this.button1.Text = "..."; - this.button1.UseVisualStyleBackColor = true; + this.rodGridView.AllowUserToAddRows = false; + this.rodGridView.AllowUserToDeleteRows = false; + this.rodGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.rodGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.rodGridView.Location = new System.Drawing.Point(6, 85); + this.rodGridView.MultiSelect = false; + this.rodGridView.Name = "rodGridView"; + this.rodGridView.ReadOnly = true; + this.rodGridView.RowHeadersVisible = false; + this.rodGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.rodGridView.Size = new System.Drawing.Size(318, 265); + this.rodGridView.TabIndex = 32; + // + // comboBox1 + // + this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(new object[] { + "Родственная связь"}); + this.comboBox1.Location = new System.Drawing.Point(168, 21); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(156, 21); + this.comboBox1.TabIndex = 31; + // + // linkLabel1 + // + this.linkLabel1.AutoSize = true; + this.linkLabel1.Location = new System.Drawing.Point(37, 24); + this.linkLabel1.Name = "linkLabel1"; + this.linkLabel1.Size = new System.Drawing.Size(81, 13); + this.linkLabel1.TabIndex = 30; + this.linkLabel1.TabStop = true; + this.linkLabel1.Text = "Фамилия И.О."; // // delRodButton // @@ -153,6 +181,15 @@ namespace Diplom_O this.delRodButton.Text = "Удалить"; this.delRodButton.UseVisualStyleBackColor = true; // + // button1 + // + this.button1.Location = new System.Drawing.Point(6, 19); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(25, 23); + this.button1.TabIndex = 27; + this.button1.Text = "..."; + this.button1.UseVisualStyleBackColor = true; + // // changeRodButton // this.changeRodButton.Location = new System.Drawing.Point(87, 56); @@ -171,44 +208,6 @@ namespace Diplom_O this.addRodButton.Text = "Добавить"; this.addRodButton.UseVisualStyleBackColor = true; // - // linkLabel1 - // - this.linkLabel1.AutoSize = true; - this.linkLabel1.Location = new System.Drawing.Point(37, 24); - this.linkLabel1.Name = "linkLabel1"; - this.linkLabel1.Size = new System.Drawing.Size(81, 13); - this.linkLabel1.TabIndex = 30; - this.linkLabel1.TabStop = true; - this.linkLabel1.Text = "Фамилия И.О."; - // - // comboBox1 - // - this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBox1.FormattingEnabled = true; - this.comboBox1.Items.AddRange(new object[] { - "Родственная связь"}); - this.comboBox1.Location = new System.Drawing.Point(168, 21); - this.comboBox1.Name = "comboBox1"; - this.comboBox1.Size = new System.Drawing.Size(156, 21); - this.comboBox1.TabIndex = 31; - // - // rodGridView - // - this.rodGridView.AllowUserToAddRows = false; - this.rodGridView.AllowUserToDeleteRows = false; - this.rodGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.rodGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.rodGridView.Location = new System.Drawing.Point(6, 85); - this.rodGridView.MultiSelect = false; - this.rodGridView.Name = "rodGridView"; - this.rodGridView.ReadOnly = true; - this.rodGridView.RowHeadersVisible = false; - this.rodGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.rodGridView.Size = new System.Drawing.Size(318, 424); - this.rodGridView.TabIndex = 32; - // // chelGridView // this.chelGridView.AllowUserToAddRows = false; @@ -217,13 +216,13 @@ namespace Diplom_O | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.chelGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.chelGridView.Location = new System.Drawing.Point(12, 79); + this.chelGridView.Location = new System.Drawing.Point(12, 56); this.chelGridView.MultiSelect = false; this.chelGridView.Name = "chelGridView"; this.chelGridView.ReadOnly = true; this.chelGridView.RowHeadersVisible = false; this.chelGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.chelGridView.Size = new System.Drawing.Size(742, 434); + this.chelGridView.Size = new System.Drawing.Size(784, 298); this.chelGridView.TabIndex = 35; // // selectButton @@ -244,6 +243,7 @@ namespace Diplom_O this.delButton.TabIndex = 33; this.delButton.Text = "Удалить"; this.delButton.UseVisualStyleBackColor = true; + this.delButton.Click += new System.EventHandler(this.delButton_Click); // // changeButton // @@ -253,6 +253,7 @@ namespace Diplom_O this.changeButton.TabIndex = 32; this.changeButton.Text = "Изменить"; this.changeButton.UseVisualStyleBackColor = true; + this.changeButton.Click += new System.EventHandler(this.changeButton_Click); // // addButton // @@ -262,13 +263,14 @@ namespace Diplom_O this.addButton.TabIndex = 31; this.addButton.Text = "Добавить"; this.addButton.UseVisualStyleBackColor = true; + this.addButton.Click += new System.EventHandler(this.addButton_Click); // // showWorkerCheckBox // this.showWorkerCheckBox.AutoSize = true; this.showWorkerCheckBox.Checked = true; this.showWorkerCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; - this.showWorkerCheckBox.Location = new System.Drawing.Point(12, 56); + this.showWorkerCheckBox.Location = new System.Drawing.Point(336, 31); this.showWorkerCheckBox.Name = "showWorkerCheckBox"; this.showWorkerCheckBox.Size = new System.Drawing.Size(204, 17); this.showWorkerCheckBox.TabIndex = 30; @@ -278,7 +280,7 @@ namespace Diplom_O // dropFindButton // this.dropFindButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.dropFindButton.Location = new System.Drawing.Point(679, 519); + this.dropFindButton.Location = new System.Drawing.Point(721, 360); this.dropFindButton.Name = "dropFindButton"; this.dropFindButton.Size = new System.Drawing.Size(75, 23); this.dropFindButton.TabIndex = 29; @@ -289,7 +291,7 @@ namespace Diplom_O // this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 524); + this.label1.Location = new System.Drawing.Point(12, 365); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(39, 13); this.label1.TabIndex = 28; @@ -299,16 +301,16 @@ namespace Diplom_O // this.findBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.findBox.Location = new System.Drawing.Point(57, 521); + this.findBox.Location = new System.Drawing.Point(57, 362); this.findBox.Name = "findBox"; - this.findBox.Size = new System.Drawing.Size(616, 20); + this.findBox.Size = new System.Drawing.Size(658, 20); this.findBox.TabIndex = 27; // // ChelForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1102, 567); + this.ClientSize = new System.Drawing.Size(1144, 408); this.Controls.Add(this.chelGridView); this.Controls.Add(this.selectButton); this.Controls.Add(this.delButton); diff --git a/MainForms/ChelForm.cs b/MainForms/ChelForm.cs index 04b299a..2426096 100644 --- a/MainForms/ChelForm.cs +++ b/MainForms/ChelForm.cs @@ -37,8 +37,8 @@ namespace Diplom_O var fd = filterDrop.Id; Task.Delay(1000).Wait(); if (filterDrop.Id == fd) - if (InvokeRequired) Invoke((Action)(() => { resetShatTable(); })); - else resetShatTable(); + if (InvokeRequired) Invoke((Action)(() => { resetChelTable(); })); + else resetChelTable(); }); filterDrop.Start(); } @@ -47,7 +47,7 @@ namespace Diplom_O { findBox.Text = ""; filterDrop = new Task(() => { return; }); - resetShatTable(); + resetChelTable(); } private void resetChelTable() @@ -59,7 +59,7 @@ namespace Diplom_O chelGridView.Columns.Clear(); var c = chelGridView.Columns; c.Add("Id", "№"); - c.Add("FIO", "Должность"); + c.Add("FIO", "Фамилия И.О."); c.Add("Male", "Пол"); c.Add("Birthday", "Дата рождения"); c.Add("Adress", "Адрес"); @@ -69,11 +69,11 @@ namespace Diplom_O c[0].Width = 40; c[1].Width = 120; c[2].Width = 40; - c[3].Width = 40; - c[4].Width = 120; - c[5].Width = 40; - c[6].Width = 40; - c[7].Width = 120; + c[3].Width = 80; + c[4].Width = 140; + c[5].Width = 90; + c[6].Width = 100; + c[7].Width = 140; c[4].DefaultCellStyle.WrapMode = DataGridViewTriState.True; c[7].DefaultCellStyle.WrapMode = DataGridViewTriState.True; } @@ -81,7 +81,7 @@ namespace Diplom_O var arr = FuncDB.ListChel(findBox.Text); var r = chelGridView.Rows; foreach (var chel in arr) - if (showWorkerCheckBox.Checked || !FuncDB.HaveChelFromRabotniky(chel.Id)) + if (showWorkerCheckBox.Checked || !FuncDB.HaveChelRabotnik(chel.Id)) r.Add(new object[] { chel.Id, chel.FName + @@ -148,6 +148,7 @@ namespace Diplom_O { var chel = selectedChel(); if (chel == null) { ShowError("Человек не выбран."); return; } + if (FuncDB.HaveChelToChel(chel.Id)) { ShowError("Человек есть в таблице родственников."); return; } try { FuncDB.DelChel(chel); diff --git a/SupportForms/WorkChelForm.Designer.cs b/SupportForms/WorkChelForm.Designer.cs index 0eb4b12..e80b52f 100644 --- a/SupportForms/WorkChelForm.Designer.cs +++ b/SupportForms/WorkChelForm.Designer.cs @@ -29,40 +29,52 @@ namespace Diplom_O.SupportForms /// private void InitializeComponent() { - this.doljBox = new System.Windows.Forms.TextBox(); - this.kolvoBox = new System.Windows.Forms.TextBox(); + this.fNameBox = new System.Windows.Forms.TextBox(); + this.sNameBox = new System.Windows.Forms.TextBox(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.errorLabel = new System.Windows.Forms.ToolStripStatusLabel(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); this.workButton = new System.Windows.Forms.Button(); this.canceledButton = new System.Windows.Forms.Button(); - this.busySizeLabel = new System.Windows.Forms.ToolStripStatusLabel(); + this.tNameBox = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.addressBox = new System.Windows.Forms.RichTextBox(); + this.pasportBox = new System.Windows.Forms.RichTextBox(); + this.maleBox = new System.Windows.Forms.ComboBox(); + this.birthdayBox = new System.Windows.Forms.DateTimePicker(); + this.snilsBox = new System.Windows.Forms.MaskedTextBox(); + this.innBox = new System.Windows.Forms.MaskedTextBox(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); // - // doljBox + // fNameBox // - this.doljBox.Location = new System.Drawing.Point(87, 12); - this.doljBox.Name = "doljBox"; - this.doljBox.Size = new System.Drawing.Size(162, 20); - this.doljBox.TabIndex = 0; + this.fNameBox.Location = new System.Drawing.Point(104, 12); + this.fNameBox.Name = "fNameBox"; + this.fNameBox.Size = new System.Drawing.Size(216, 20); + this.fNameBox.TabIndex = 0; // - // kolvoBox + // sNameBox // - this.kolvoBox.Location = new System.Drawing.Point(87, 38); - this.kolvoBox.Name = "kolvoBox"; - this.kolvoBox.Size = new System.Drawing.Size(162, 20); - this.kolvoBox.TabIndex = 1; + this.sNameBox.Location = new System.Drawing.Point(104, 38); + this.sNameBox.Name = "sNameBox"; + this.sNameBox.Size = new System.Drawing.Size(216, 20); + this.sNameBox.TabIndex = 1; // // statusStrip1 // this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.errorLabel, - this.busySizeLabel}); - this.statusStrip1.Location = new System.Drawing.Point(0, 90); + this.errorLabel}); + this.statusStrip1.Location = new System.Drawing.Point(0, 428); this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(262, 22); + this.statusStrip1.Size = new System.Drawing.Size(332, 22); this.statusStrip1.TabIndex = 2; this.statusStrip1.Text = "statusStrip1"; // @@ -75,27 +87,9 @@ namespace Diplom_O.SupportForms this.errorLabel.Text = "Ошибка."; this.errorLabel.Visible = false; // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(16, 15); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(65, 13); - this.label1.TabIndex = 3; - this.label1.Text = "Должность"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 41); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(69, 13); - this.label2.TabIndex = 4; - this.label2.Text = "Кол-во мест"; - // // workButton // - this.workButton.Location = new System.Drawing.Point(175, 64); + this.workButton.Location = new System.Drawing.Point(245, 402); this.workButton.Name = "workButton"; this.workButton.Size = new System.Drawing.Size(75, 23); this.workButton.TabIndex = 5; @@ -105,7 +99,7 @@ namespace Diplom_O.SupportForms // // canceledButton // - this.canceledButton.Location = new System.Drawing.Point(94, 64); + this.canceledButton.Location = new System.Drawing.Point(164, 402); this.canceledButton.Name = "canceledButton"; this.canceledButton.Size = new System.Drawing.Size(75, 23); this.canceledButton.TabIndex = 6; @@ -113,29 +107,176 @@ namespace Diplom_O.SupportForms this.canceledButton.UseVisualStyleBackColor = true; this.canceledButton.Click += new System.EventHandler(this.canceledButton_Click); // - // busySizeLabel + // tNameBox // - this.busySizeLabel.Name = "busySizeLabel"; - this.busySizeLabel.Size = new System.Drawing.Size(51, 17); - this.busySizeLabel.Text = "Занято: "; - this.busySizeLabel.Visible = false; + this.tNameBox.Location = new System.Drawing.Point(104, 64); + this.tNameBox.Name = "tNameBox"; + this.tNameBox.Size = new System.Drawing.Size(216, 20); + this.tNameBox.TabIndex = 7; // - // WorkShtatForm + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(42, 15); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(56, 13); + this.label1.TabIndex = 29; + this.label1.Text = "Фамилия"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(69, 41); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(29, 13); + this.label2.TabIndex = 30; + this.label2.Text = "Имя"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(44, 67); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(54, 13); + this.label3.TabIndex = 31; + this.label3.Text = "Отчетсво"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(71, 93); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(27, 13); + this.label4.TabIndex = 32; + this.label4.Text = "Пол"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(12, 119); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(86, 13); + this.label5.TabIndex = 33; + this.label5.Text = "Дата рождения"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(12, 145); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(38, 13); + this.label6.TabIndex = 34; + this.label6.Text = "Адрес"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(12, 249); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(31, 13); + this.label7.TabIndex = 35; + this.label7.Text = "ИНН"; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(12, 275); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(45, 13); + this.label8.TabIndex = 36; + this.label8.Text = "СНИЛС"; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(12, 301); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(50, 13); + this.label9.TabIndex = 37; + this.label9.Text = "Паспорт"; + // + // addressBox + // + this.addressBox.Location = new System.Drawing.Point(104, 142); + this.addressBox.Name = "addressBox"; + this.addressBox.Size = new System.Drawing.Size(216, 98); + this.addressBox.TabIndex = 38; + this.addressBox.Text = ""; + // + // pasportBox + // + this.pasportBox.Location = new System.Drawing.Point(104, 298); + this.pasportBox.Name = "pasportBox"; + this.pasportBox.Size = new System.Drawing.Size(216, 98); + this.pasportBox.TabIndex = 39; + this.pasportBox.Text = ""; + // + // maleBox + // + this.maleBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.maleBox.FormattingEnabled = true; + this.maleBox.Items.AddRange(new object[] { + "Мужчина", + "Женщина"}); + this.maleBox.Location = new System.Drawing.Point(104, 90); + this.maleBox.Name = "maleBox"; + this.maleBox.Size = new System.Drawing.Size(216, 21); + this.maleBox.TabIndex = 40; + // + // birthdayBox + // + this.birthdayBox.CustomFormat = "yyyy.MM.dd"; + this.birthdayBox.Location = new System.Drawing.Point(104, 116); + this.birthdayBox.Name = "birthdayBox"; + this.birthdayBox.Size = new System.Drawing.Size(216, 20); + this.birthdayBox.TabIndex = 41; + // + // snilsBox + // + this.snilsBox.Location = new System.Drawing.Point(104, 272); + this.snilsBox.Mask = "000-000-000 00"; + this.snilsBox.Name = "snilsBox"; + this.snilsBox.Size = new System.Drawing.Size(216, 20); + this.snilsBox.TabIndex = 42; + // + // innBox + // + this.innBox.Location = new System.Drawing.Point(104, 246); + this.innBox.Mask = "000000000000"; + this.innBox.Name = "innBox"; + this.innBox.Size = new System.Drawing.Size(216, 20); + this.innBox.TabIndex = 43; + // + // WorkChelForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(262, 112); + this.ClientSize = new System.Drawing.Size(332, 450); this.ControlBox = false; - this.Controls.Add(this.canceledButton); - this.Controls.Add(this.workButton); + this.Controls.Add(this.innBox); + this.Controls.Add(this.snilsBox); + this.Controls.Add(this.birthdayBox); + this.Controls.Add(this.maleBox); + this.Controls.Add(this.pasportBox); + this.Controls.Add(this.addressBox); + this.Controls.Add(this.label9); + this.Controls.Add(this.label8); + this.Controls.Add(this.label7); + this.Controls.Add(this.label6); + this.Controls.Add(this.label5); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.label1); + this.Controls.Add(this.tNameBox); + this.Controls.Add(this.canceledButton); + this.Controls.Add(this.workButton); this.Controls.Add(this.statusStrip1); - this.Controls.Add(this.kolvoBox); - this.Controls.Add(this.doljBox); + this.Controls.Add(this.sNameBox); + this.Controls.Add(this.fNameBox); this.MaximizeBox = false; this.MinimizeBox = false; - this.Name = "WorkShtatForm"; + this.Name = "WorkChelForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Штатное место"; this.statusStrip1.ResumeLayout(false); @@ -147,14 +288,27 @@ namespace Diplom_O.SupportForms #endregion - private System.Windows.Forms.TextBox doljBox; - private System.Windows.Forms.TextBox kolvoBox; + private System.Windows.Forms.TextBox fNameBox; + private System.Windows.Forms.TextBox sNameBox; private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.ToolStripStatusLabel errorLabel; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; private System.Windows.Forms.Button workButton; private System.Windows.Forms.Button canceledButton; - private System.Windows.Forms.ToolStripStatusLabel busySizeLabel; + private System.Windows.Forms.TextBox tNameBox; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.RichTextBox addressBox; + private System.Windows.Forms.RichTextBox pasportBox; + private System.Windows.Forms.ComboBox maleBox; + private System.Windows.Forms.DateTimePicker birthdayBox; + private System.Windows.Forms.MaskedTextBox snilsBox; + private System.Windows.Forms.MaskedTextBox innBox; } } \ No newline at end of file diff --git a/SupportForms/WorkChelForm.cs b/SupportForms/WorkChelForm.cs index ec0bf6a..2f40f03 100644 --- a/SupportForms/WorkChelForm.cs +++ b/SupportForms/WorkChelForm.cs @@ -34,15 +34,23 @@ namespace Diplom_O.SupportForms public WorkChelForm(Chel chel = null) { InitializeComponent(); + maleBox.SelectedIndex = 0; + birthdayBox.Value = DateTime.Now; try { - if (shtat != null) + if (chel != null) { - this.shtat = shtat; + this.chel = chel; workButton.Text = "Изменить"; - doljBox.Text = shtat.Doljnost; - kolvoBox.Text = shtat.Size.ToString(); - busySizeLabel.Text = "Занято: " + FuncDB.BusySizeShtat(shtat.Id); + fNameBox.Text = chel.FName; + sNameBox.Text = chel.SName; + tNameBox.Text = chel.TName; + maleBox.SelectedIndex = chel.Male ? 0 : 1; + birthdayBox.Value = chel.Birthday; + addressBox.Text = chel.Address; + innBox.Text = chel.INN; + snilsBox.Text = chel.SNILS; + pasportBox.Text = chel.Pasport; } } catch (Exception e) @@ -56,17 +64,35 @@ namespace Diplom_O.SupportForms { try { - if (!int.TryParse(kolvoBox.Text, out int kolvo)) throw new Exception("Ошибка указания количества."); - if (shtat == null) + if (maleBox.SelectedIndex == -1) throw new Exception("Пол не указан."); + if (chel == null) { - var s = new Shtat() { Doljnost = doljBox.Text, Size = kolvo }; - FuncDB.AddShtat(s); + var s = new Chel() + { + FName = fNameBox.Text, + SName = sNameBox.Text, + TName = tNameBox.Text, + Male = maleBox.SelectedIndex == 0, + Birthday = birthdayBox.Value, + Address = addressBox.Text, + INN = innBox.Text, + SNILS = snilsBox.Text, + Pasport = pasportBox.Text + }; + FuncDB.AddChel(s); } else { - shtat.Doljnost = doljBox.Text; - shtat.Size = kolvo; - FuncDB.ChangeShtat(shtat); + chel.FName = fNameBox.Text; + chel.SName = sNameBox.Text; + chel.TName = tNameBox.Text; + chel.Male = maleBox.SelectedIndex == 0; + chel.Birthday = birthdayBox.Value; + chel.Address = addressBox.Text; + chel.INN = innBox.Text; + chel.SNILS = snilsBox.Text; + chel.Pasport = pasportBox.Text; + FuncDB.ChangeChel(chel); } this.Close(); } diff --git a/bin/Debug/Diplom O.exe b/bin/Debug/Diplom O.exe index b1520ef..3cd7c7c 100644 Binary files a/bin/Debug/Diplom O.exe and b/bin/Debug/Diplom O.exe differ diff --git a/bin/Debug/Diplom O.pdb b/bin/Debug/Diplom O.pdb index 8b2b261..9ecf9c1 100644 Binary files a/bin/Debug/Diplom O.pdb and b/bin/Debug/Diplom O.pdb differ diff --git a/bin/Debug/Diplom_O.db b/bin/Debug/Diplom_O.db index 20cc1d7..33641e5 100644 Binary files a/bin/Debug/Diplom_O.db and b/bin/Debug/Diplom_O.db differ diff --git a/obj/Debug/Diplom O.csproj.CoreCompileInputs.cache b/obj/Debug/Diplom O.csproj.CoreCompileInputs.cache index d06f148..cb05887 100644 --- a/obj/Debug/Diplom O.csproj.CoreCompileInputs.cache +++ b/obj/Debug/Diplom O.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -0c2e425b901cf85af656ff5689d6db6933a3bb8c +204ad71c07c2e68492bf31d8fc5ca1880f83504e diff --git a/obj/Debug/Diplom O.csproj.FileListAbsolute.txt b/obj/Debug/Diplom O.csproj.FileListAbsolute.txt index f488112..d036d3b 100644 --- a/obj/Debug/Diplom O.csproj.FileListAbsolute.txt +++ b/obj/Debug/Diplom O.csproj.FileListAbsolute.txt @@ -62,3 +62,4 @@ D:\GIT\Diplom O\bin\Debug\System.Runtime.CompilerServices.Unsafe.xml D:\GIT\Diplom O\obj\Debug\Diplom O.csproj.CopyComplete D:\GIT\Diplom O\obj\Debug\Diplom_O.SupportForms.WorkShtatForm.resources D:\GIT\Diplom O\obj\Debug\Diplom_O.ChelForm.resources +D:\GIT\Diplom O\obj\Debug\Diplom_O.SupportForms.WorkChelForm.resources diff --git a/obj/Debug/Diplom O.csproj.GenerateResource.cache b/obj/Debug/Diplom O.csproj.GenerateResource.cache index 845a923..05d49ff 100644 Binary files a/obj/Debug/Diplom O.csproj.GenerateResource.cache and b/obj/Debug/Diplom O.csproj.GenerateResource.cache differ diff --git a/obj/Debug/Diplom O.exe b/obj/Debug/Diplom O.exe index b1520ef..3cd7c7c 100644 Binary files a/obj/Debug/Diplom O.exe and b/obj/Debug/Diplom O.exe differ diff --git a/obj/Debug/Diplom O.pdb b/obj/Debug/Diplom O.pdb index 8b2b261..9ecf9c1 100644 Binary files a/obj/Debug/Diplom O.pdb and b/obj/Debug/Diplom O.pdb differ diff --git a/obj/Debug/Diplom_O.SupportForms.WorkChelForm.resources b/obj/Debug/Diplom_O.SupportForms.WorkChelForm.resources new file mode 100644 index 0000000..6c05a97 Binary files /dev/null and b/obj/Debug/Diplom_O.SupportForms.WorkChelForm.resources differ