Exemplo n.º 1
0
        public DrugForm(string _drugName, int _drugQuantity, float _drugPrice, string _drugDescription, DateTime _drugManufactureDate,
                        DateTime _drugExpirationDate, int _drugManufacurerID, int _drugCategoryID)
        {
            InitializeComponent();

            drugName            = _drugName;
            drugQuantity        = _drugQuantity;
            drugPrice           = _drugPrice;
            drugDescription     = _drugDescription;
            drugManufactureDate = _drugManufactureDate;
            drugExpirationDate  = _drugExpirationDate;
            drugManufacurerID   = _drugManufacurerID;
            drugCategoryID      = _drugCategoryID;

            // заповнюємо manufacturerTable
            string query = "SELECT id, name FROM manufacturer";

            manufacturerTable = DBQueries.ExecuteQuery(query, new MySqlConnection(Settings.Default.connectionString));
            foreach (DataRow dr in manufacturerTable.Rows)
            {
                CB_Drug_Manufacturer.Items.Add(dr["name"]);
            }

            // заповнюємо categoryTable
            query         = "SELECT id, name FROM category";
            categoryTable = DBQueries.ExecuteQuery(query, new MySqlConnection(Settings.Default.connectionString));
            foreach (DataRow dr in categoryTable.Rows)
            {
                CB_Drug_Category.Items.Add(dr["name"]);
            }

            FillInputBoxes();
        }
Exemplo n.º 2
0
        public static DataTable SELECTQuery()
        {
            string query = "SELECT drug.*, category.name AS cname FROM drug " +
                           "LEFT JOIN category ON drug.category_id = category.id ";

            return(DBQueries.ExecuteQuery(query, new MySqlConnection(Settings.Default.connectionString)));
        }
Exemplo n.º 3
0
 public void INSERTQuery()
 {
     if (ShowDialog() == DialogResult.OK)
     {
         string query = $"INSERT INTO category (name) VALUES ('{categoryName}') ";
         DBQueries.ExecuteNonQuery(query, new MySqlConnection(Settings.Default.connectionString));
     }
 }
Exemplo n.º 4
0
 public void UPDATEQuery(int id)
 {
     if (ShowDialog() == DialogResult.OK)
     {
         string query = $"UPDATE category SET name = '{categoryName}' " +
                        $"WHERE id = {id} ";
         DBQueries.ExecuteNonQuery(query, new MySqlConnection(Settings.Default.connectionString));
     }
 }
Exemplo n.º 5
0
 public void INSERTQuery()
 {
     if (ShowDialog() == DialogResult.OK)
     {
         string query = "INSERT INTO manufacturer (name, country, address, phone_number, site) " +
                        $"VALUES ('{manufacturerName}'," +
                        $"        '{manufacturerCountry}', " +
                        $"        '{manufacturerAddress}', " +
                        $"        '{manufacturerPhoneNumber}', " +
                        $"        '{manufacturerSite}') ";
         DBQueries.ExecuteNonQuery(query, new MySqlConnection(Settings.Default.connectionString));
     }
 }
Exemplo n.º 6
0
 public void UPDATEQuery(int id)
 {
     if (ShowDialog() == DialogResult.OK)
     {
         string query = "UPDATE manufacturer " +
                        $"SET name         = '{manufacturerName}', " +
                        $"    country      = '{manufacturerCountry}', " +
                        $"    address      = '{manufacturerAddress}', " +
                        $"    phone_number = '{manufacturerPhoneNumber}', " +
                        $"    site         = '{manufacturerSite}' " +
                        $"WHERE id = {id} ";
         DBQueries.ExecuteNonQuery(query, new MySqlConnection(Settings.Default.connectionString));
     }
 }
Exemplo n.º 7
0
 public void INSERTQuery()
 {
     if (ShowDialog() == DialogResult.OK)
     {
         string query = $"INSERT INTO drug (name, quantity, price, manufacture_date, expiration_date, description, manufacturer_id, category_id) " +
                        $"VALUES ('{drugName}', " +
                        $"         {drugQuantity}, " +
                        $"         {drugPrice}, " +
                        $"        '{drugManufactureDate.Year}.{drugManufactureDate.Month}.{drugManufactureDate.Day}', " +
                        $"        '{drugExpirationDate.Year}.{drugExpirationDate.Month}.{drugExpirationDate.Day}', " +
                        $"        '{drugDescription}', " +
                        $"         {drugManufacurerID}, " +
                        $"         {drugCategoryID}) ";
         DBQueries.ExecuteNonQuery(query, new MySqlConnection(Settings.Default.connectionString));
     }
 }
Exemplo n.º 8
0
 public void UPDATEQuery(int id)
 {
     if (ShowDialog() == DialogResult.OK)
     {
         string query = $"UPDATE drug " +
                        $"SET name             = '{drugName}', " +
                        $"    quantity         =  {drugQuantity}, " +
                        $"    price            =  {drugPrice}, " +
                        $"    manufacture_date = '{drugManufactureDate.Year}.{drugManufactureDate.Month}.{drugManufactureDate.Day}', " +
                        $"    expiration_date  = '{drugExpirationDate.Year}.{drugExpirationDate.Month}.{drugExpirationDate.Day}', " +
                        $"    description      = '{drugDescription}', " +
                        $"    manufacturer_id  =  {drugManufacurerID}, " +
                        $"    category_id      =  {drugCategoryID} " +
                        $"WHERE id = {id} ";
         DBQueries.ExecuteNonQuery(query, new MySqlConnection(Settings.Default.connectionString));
     }
 }
Exemplo n.º 9
0
        public static void DELETEQuery(int id)
        {
            string query = $"DELETE FROM category WHERE id = {id} ";

            DBQueries.ExecuteNonQuery(query, new MySqlConnection(Settings.Default.connectionString));
        }
Exemplo n.º 10
0
        public static DataTable SELECTQuery()
        {
            string query = "SELECT * FROM category";

            return(DBQueries.ExecuteQuery(query, new MySqlConnection(Settings.Default.connectionString)));
        }