Browse Source

Окно настроек
RELEASE (BETA)

Вячеслав Терешенко 2 years ago
parent
commit
e79dc358c1

+ 1 - 0
ImpulseVision/FormAutorize.cs

@@ -65,6 +65,7 @@ values ('{LblUserID.Text.Trim()}',GETDATE())";
                 {
                     this.Hide();
                     FormMain FMain = new FormMain();
+                    FMain.BsAdministrator.Filter = BsUsers.Filter;
                     FMain.ShowDialog();
                     this.Show();
                 }

+ 40 - 0
ImpulseVision/FormMain.Designer.cs

@@ -76,6 +76,8 @@
             this.TbxNewPass = new ImpulseVision.EgoldsGoogleTextBox();
             this.TbxOldPass = new ImpulseVision.EgoldsGoogleTextBox();
             this.TbxLogin = new ImpulseVision.EgoldsGoogleTextBox();
+            this.BsAdministrator = new System.Windows.Forms.BindingSource(this.components);
+            this.impulseVisionAppDataSet1 = new ImpulseVision.ImpulseVisionAppDataSet();
             this.GbxSystemParameters = new System.Windows.Forms.GroupBox();
             this.SwSaveSizeWindow = new ImpulseVision.EgoldsToggleSwitch();
             this.SwAutoRun = new ImpulseVision.EgoldsToggleSwitch();
@@ -117,6 +119,8 @@
             this.ImList = new System.Windows.Forms.ImageList(this.components);
             this.TimerSaving = new System.Windows.Forms.Timer(this.components);
             this.TmAnim = new System.Windows.Forms.Timer(this.components);
+            this.staffsTableAdapter = new ImpulseVision.ImpulseVisionAppDataSetTableAdapters.StaffsTableAdapter();
+            this.LblAdminID = new System.Windows.Forms.Label();
             this.menuStrip1.SuspendLayout();
             this.ToolsMenu.SuspendLayout();
             this.statusStrip1.SuspendLayout();
@@ -130,6 +134,8 @@
             this.RPanelForAddUser.SuspendLayout();
             this.TbSettings.SuspendLayout();
             this.GbxUserParameters.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.BsAdministrator)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.impulseVisionAppDataSet1)).BeginInit();
             this.GbxSystemParameters.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.NumCountDaySaveLogFiles)).BeginInit();
             this.RPanelSettings.SuspendLayout();
@@ -631,6 +637,7 @@
             this.GbxUserParameters.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.GbxUserParameters.Controls.Add(this.LblAdminID);
             this.GbxUserParameters.Controls.Add(this.BtnEditUserParameters);
             this.GbxUserParameters.Controls.Add(this.TbxConfirmNewPass);
             this.GbxUserParameters.Controls.Add(this.TbxNewPass);
@@ -655,6 +662,7 @@
             this.BtnEditUserParameters.TabIndex = 11;
             this.BtnEditUserParameters.Text = "Изменить";
             this.BtnEditUserParameters.UseVisualStyleBackColor = false;
+            this.BtnEditUserParameters.Click += new System.EventHandler(this.BtnEditUserParameters_Click);
             // 
             // TbxConfirmNewPass
             // 
@@ -724,6 +732,7 @@
             this.TbxLogin.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(137)))), ((int)(((byte)(60)))), ((int)(((byte)(143)))));
             this.TbxLogin.BorderColorNotActive = System.Drawing.Color.FromArgb(((int)(((byte)(124)))), ((int)(((byte)(136)))), ((int)(((byte)(144)))));
             this.TbxLogin.Cursor = System.Windows.Forms.Cursors.IBeam;
+            this.TbxLogin.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.BsAdministrator, "Login", true));
             this.TbxLogin.Font = new System.Drawing.Font("Segoe UI Variable Small Semibol", 12F, System.Drawing.FontStyle.Bold);
             this.TbxLogin.FontTextPreview = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Bold);
             this.TbxLogin.ForeColor = System.Drawing.Color.Black;
@@ -736,6 +745,16 @@
             this.TbxLogin.TextPreview = "Логин";
             this.TbxLogin.UseSystemPasswordChar = false;
             // 
+            // BsAdministrator
+            // 
+            this.BsAdministrator.DataMember = "Staffs";
+            this.BsAdministrator.DataSource = this.impulseVisionAppDataSet1;
+            // 
+            // impulseVisionAppDataSet1
+            // 
+            this.impulseVisionAppDataSet1.DataSetName = "ImpulseVisionAppDataSet";
+            this.impulseVisionAppDataSet1.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
+            // 
             // GbxSystemParameters
             // 
             this.GbxSystemParameters.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
@@ -1299,6 +1318,20 @@
             // 
             this.TmAnim.Interval = 25;
             // 
+            // staffsTableAdapter
+            // 
+            this.staffsTableAdapter.ClearBeforeFill = true;
+            // 
+            // LblAdminID
+            // 
+            this.LblAdminID.AutoSize = true;
+            this.LblAdminID.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.BsAdministrator, "ID", true));
+            this.LblAdminID.Location = new System.Drawing.Point(6, 209);
+            this.LblAdminID.Name = "LblAdminID";
+            this.LblAdminID.Size = new System.Drawing.Size(77, 21);
+            this.LblAdminID.TabIndex = 12;
+            this.LblAdminID.Text = "AdminID";
+            // 
             // FormMain
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F);
@@ -1336,6 +1369,9 @@
             this.RPanelForAddUser.ResumeLayout(false);
             this.TbSettings.ResumeLayout(false);
             this.GbxUserParameters.ResumeLayout(false);
+            this.GbxUserParameters.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.BsAdministrator)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.impulseVisionAppDataSet1)).EndInit();
             this.GbxSystemParameters.ResumeLayout(false);
             this.GbxSystemParameters.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.NumCountDaySaveLogFiles)).EndInit();
@@ -1445,6 +1481,10 @@
         private EgoldsGoogleTextBox TbxOldPass;
         private EgoldsGoogleTextBox TbxLogin;
         private System.Windows.Forms.Button BtnEditUserParameters;
+        private ImpulseVisionAppDataSet impulseVisionAppDataSet1;
+        public System.Windows.Forms.BindingSource BsAdministrator;
+        private ImpulseVisionAppDataSetTableAdapters.StaffsTableAdapter staffsTableAdapter;
+        private System.Windows.Forms.Label LblAdminID;
     }
 }
 

+ 58 - 0
ImpulseVision/FormMain.cs

@@ -233,6 +233,8 @@ namespace ImpulseVision
 
         private void FormMain_Load(object sender, EventArgs e)
         {
+            // TODO: This line of code loads data into the 'impulseVisionAppDataSet1.Staffs' table. You can move, or remove it, as needed.
+            this.staffsTableAdapter.Fill(this.impulseVisionAppDataSet1.Staffs);
             HideAdding();
             ApplyFormParameters();
 
@@ -1102,5 +1104,61 @@ from UserTraffic ut join Users on ut.UserID = Users.ID
             }
             application.CountDay = int.Parse(NumCountDaySaveLogFiles.Value.ToString());
         }
+
+        private void BtnEditUserParameters_Click(object sender, EventArgs e)
+        {
+            if(TbxOldPass.Text.Trim() != GetOldPass(TbxLogin.Text.Trim()))
+            {
+                MessageBox.Show("Введённый пароль не совпадает со старым!", "ImpulseVision", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
+                return;
+            }
+            if(TbxNewPass.Text.Trim().Length < 4)
+            {
+                MessageBox.Show("Длина пароля должна быть не менее 4-х символов!", "ImpulseVision", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
+                return;
+            }
+            if(TbxNewPass.Text.Trim() != TbxConfirmNewPass.Text.Trim())
+            {
+                MessageBox.Show("Подтвердите новый пароль и повторите попытку!", "ImpulseVision", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
+                return;
+            }
+            ChangePassword(TbxNewPass.Text.Trim());
+            MessageBox.Show("Ваш пароль успешно изменён. Для продолжения работы с приложением необходима повторная авторизация.", "ImpulseVision", MessageBoxButtons.OK, MessageBoxIcon.Information);
+
+            Application.Restart();
+        }
+        /// <summary>
+        /// изменение пароля
+        /// </summary>
+        /// <param name="password">пароль в виде строки текста</param>
+        private void ChangePassword(string password)
+        {
+            SCon.Open();
+            string QueryChangePass = $@"update Staffs
+set [Password] = '{password}'
+where ID = '{LblAdminID.Text.Trim()}'";
+            SqlCommand Cmd = new SqlCommand(QueryChangePass, SCon);
+            Cmd.ExecuteNonQuery();
+            SCon.Close();
+        }
+
+        private string GetOldPass(string login)
+        {
+            string Pass = "**";
+            SCon.Open();
+            string QueryGetPass = $@"select [Password]
+from Staffs
+where [Login] = '{login}'";
+            SqlCommand Cmd = new SqlCommand(QueryGetPass, SCon);
+            SqlDataReader Res = Cmd.ExecuteReader();
+            if(Res.HasRows)
+            {
+                Res.Read();
+                Pass = Res["Password"].ToString();
+            }
+            SCon.Close();
+
+            return Pass;
+        }
     }
 }

+ 9 - 0
ImpulseVision/FormMain.resx

@@ -132,6 +132,12 @@
   <metadata name="TimerCheckTrain.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>485, 17</value>
   </metadata>
+  <metadata name="BsAdministrator.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>221, 25</value>
+  </metadata>
+  <metadata name="impulseVisionAppDataSet1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>22, 56</value>
+  </metadata>
   <metadata name="ImList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>627, 17</value>
   </metadata>
@@ -141,6 +147,9 @@
   <metadata name="TmAnim.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>17, 19</value>
   </metadata>
+  <metadata name="staffsTableAdapter.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>221, 56</value>
+  </metadata>
   <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>64</value>
   </metadata>

BIN
ImpulseVision/bin/Debug/ImpulseVision.exe