Bläddra i källkod

Добавлены кнопки в главном окне программы

sanyogromov@mail.ru 2 år sedan
förälder
incheckning
6f1a7537f4
2 ändrade filer med 50 tillägg och 0 borttagningar
  1. 30 0
      project/Main.Designer.cs
  2. 20 0
      project/Main.cs

+ 30 - 0
project/Main.Designer.cs

@@ -32,6 +32,8 @@ namespace project
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
             this.dataGridView1 = new System.Windows.Forms.DataGridView();
             this.pictureBox1 = new System.Windows.Forms.PictureBox();
+            this.button1 = new System.Windows.Forms.Button();
+            this.button2 = new System.Windows.Forms.Button();
             ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
             this.SuspendLayout();
@@ -58,11 +60,37 @@ namespace project
             this.pictureBox1.TabStop = false;
             this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
             // 
+            // button1
+            // 
+            this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
+            this.button1.Location = new System.Drawing.Point(12, 10);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(123, 34);
+            this.button1.TabIndex = 13;
+            this.button1.Text = "Изменить";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Visible = false;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // button2
+            // 
+            this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
+            this.button2.Location = new System.Drawing.Point(151, 10);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(123, 34);
+            this.button2.TabIndex = 14;
+            this.button2.Text = "Удалить";
+            this.button2.UseVisualStyleBackColor = true;
+            this.button2.Visible = false;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
+            // 
             // Main
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(800, 450);
+            this.Controls.Add(this.button2);
+            this.Controls.Add(this.button1);
             this.Controls.Add(this.pictureBox1);
             this.Controls.Add(this.dataGridView1);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
@@ -81,5 +109,7 @@ namespace project
 
         private System.Windows.Forms.DataGridView dataGridView1;
         private System.Windows.Forms.PictureBox pictureBox1;
+        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.Button button2;
     }
 }

+ 20 - 0
project/Main.cs

@@ -13,6 +13,7 @@ namespace project
 {
     public partial class Main : Form
     {
+        public static string login;
         DataBase dataBase = new DataBase();
         public Main()
         {
@@ -57,6 +58,15 @@ namespace project
         {
             CreateColumns();
             RefresDataGird(dataGridView1);
+            string proverkaLogin = Login.login;
+            dataBase.openConnection();
+            SqlCommand sqlCommand2 = new SqlCommand($"SELECT administrator From Employee WHERE login = '{proverkaLogin}'", dataBase.GetConnection());
+            string admPolzovatel = sqlCommand2.ExecuteScalar().ToString();
+            if (admPolzovatel.Trim() == "true")
+            {
+                button1.Visible = true;
+                button2.Visible = true;
+            }
         }
 
         private void pictureBox1_Click(object sender, EventArgs e)
@@ -64,5 +74,15 @@ namespace project
             Profile profile = new Profile();
             profile.Show();
         }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+
+        }
+
+        private void button2_Click(object sender, EventArgs e)
+        {
+            
+        }
     }
 }