Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Data.SqlClient;
  11.  
  12. namespace Supermarket
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         public Form1()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.         public static string NamaSeller = "";
  21.         SqlConnection connect = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\USERS\ASUS\DOCUMENTS\SUPERMARKETDB.mdf;Integrated Security=True;Connect Timeout=30");
  22.         private void Form1_Load(object sender, EventArgs e)
  23.         {
  24.  
  25.         }
  26.  
  27.         private void label2_Click(object sender, EventArgs e)
  28.         {
  29.  
  30.         }
  31.  
  32.         private void label4_Click(object sender, EventArgs e)
  33.         {
  34.  
  35.         }
  36.  
  37.         private void label5_Click(object sender, EventArgs e)
  38.         {
  39.             Application.Exit();
  40.         }
  41.  
  42.         private void guna2CircleButton1_Click(object sender, EventArgs e)
  43.         {
  44.  
  45.         }
  46.  
  47.         private void bunifuMaterialTextbox1_OnValueChanged(object sender, EventArgs e)
  48.         {
  49.  
  50.         }
  51.  
  52.         private void bunifuMaterialTextbox2_OnValueChanged(object sender, EventArgs e)
  53.         {
  54.  
  55.         }
  56.  
  57.         private void label1_Click(object sender, EventArgs e)
  58.         {
  59.  
  60.         }
  61.  
  62.         private void label3_Click(object sender, EventArgs e)
  63.         {
  64.  
  65.         }
  66.  
  67.         private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  68.         {
  69.  
  70.         }
  71.  
  72.         private void bunifuThinButton21_Click(object sender, EventArgs e)
  73.         {
  74.             if (username.Text == "" || password.Text == "")
  75.             {
  76.  
  77.                 MessageBox.Show("Enter The Username and Password");
  78.             }
  79.             else
  80.             {
  81.                 if (RoleCat.SelectedIndex > -1)
  82.                 {
  83.                     if (RoleCat.SelectedItem.ToString() == "ADMIN")
  84.                     {
  85.                         if (username.Text == "Admin" && password.Text == "Admin")
  86.                         {
  87.                             ProdukForm produk = new ProdukForm();
  88.                             produk.Show();
  89.                             this.Hide();
  90.                         }
  91.                         else
  92.                         {
  93.                             MessageBox.Show("If You are The Admin Enter The Correct Username and Password");
  94.                         }
  95.                     }
  96.                     else
  97.                     {
  98.                         //MessageBox.Show("You are in Seller Section");
  99.                         connect.Open();
  100.                         string query = "select count(2) from Seller where NamaSeller='" + username.Text + "' and PassSeller='" + password.Text + "' ";
  101.                         SqlDataAdapter sda = new SqlDataAdapter(query, connect);
  102.                         DataTable dataset = new DataTable();
  103.                         sda.Fill(dataset);
  104.                         if(dataset.Rows[0][0].ToString() == "1")
  105.                         {
  106.                             NamaSeller = username.Text;
  107.                             SellingForm sell = new SellingForm();
  108.                             sell.Show();
  109.                             this.Hide();
  110.                             connect.Close();
  111.                         }
  112.                         else
  113.                         {
  114.                             MessageBox.Show("Wrong Username or Password");
  115.                         }
  116.                         connect.Close();
  117.                     }
  118.                 }
  119.                 else
  120.                 {
  121.                     MessageBox.Show("Select a Role");
  122.                 }
  123.             }
  124.         }
  125.  
  126.         private void button5_Click(object sender, EventArgs e)
  127.         {
  128.             username.Text = "";
  129.             password.Text = "";
  130.         }
  131.     }
  132. }
  133.