Exemple #1
0
        public bool AddSupplier(Supplier supp)
        {
            bool result = false;

            query = "INSERT INTO supplier VALUES('" + supp.Id_supplier + "','" + supp.Nama_supplier + "','" + supp.Alamat_supplier + "','" + supp.No_telp_supplier + "')";

            try
            {
                connect.Open();
                cmd = new MySqlCommand(query, connect);
                cmd.ExecuteNonQuery();
                result = true;
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message.ToString());
                result = false;
            }
            finally
            {
                connect.Close();
            }

            return result;
        }
Exemple #2
0
 private void btn_DeleteSupplier_Click(object sender, EventArgs e)
 {
     if (txt_NamaSupplier.TextLength > 0 && txt_AlamatSupplier.TextLength > 0 && txt_NoTelpSupplier.TextLength > 0)
     {
         s_Supplier = new Supplier(Utils.ConcatMaxID(txt_IdSupplier.Text.ToString(), txt_IdSupplierNum.Text.ToString()), txt_NamaSupplier.Text.ToString(), txt_AlamatSupplier.TextLength.ToString(), txt_NoTelpSupplier.Text.ToString());
         if (s_SupplierManager.DeleteSupplier(s_Supplier))
         {
             MessageBox.Show("Data berhasil ditambah");
             txt_IdSupplierNum.Text = Utils.DisplayMaxID(s_SupplierManager.GetMaxIDSupp().Substring(s_SupplierManager.GetMaxIDSupp().IndexOf("-") + 1));
             ClearField();
         }
         else
         {
             MessageBox.Show("Data gagal ditambah");
         }
     }
     else
     {
         MessageBox.Show("Mohon data-data dilengkapi");
     }
 }
Exemple #3
0
        public bool DeleteSupplier(Supplier supp)
        {
            bool result = false;

            query = "UPDATE supplier SET status_deleted = 1 WHERE id_supplier = '" + supp.Id_supplier + "'";
            try
            {
                connect.Open();
                cmd = new MySqlCommand(query, connect);
                cmd.ExecuteNonQuery();
                result = true;
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message.ToString());
                result = false;
            }
            finally
            {
                connect.Close();
            }

            return result;
        }
Exemple #4
0
        public bool UpdateSupplier(Supplier supp)
        {
            bool result = false;

            query = "UPDATE supplier SET nama_supplier = '" + supp.Nama_supplier + "', alamat_supplier = '" + supp.Alamat_supplier + "', no_telp_supplier = '" + supp.No_telp_supplier + "' WHERE id_supplier = '" + supp.Id_supplier + "'";

            try
            {
                connect.Open();
                cmd = new MySqlCommand(query, connect);
                cmd.ExecuteNonQuery();
                result = true;
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message.ToString());
                result = false;
            }
            finally
            {
                connect.Close();
            }

            return result;
        }
Exemple #5
0
        private void btn_HapusPermanen_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Peringatan! Anda akan menghapus semua data secara permanen. Anda yakin?", "WARNING", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                s_Supplier = new Supplier();
                s_Supplier.Id_supplier = Utils.ConcatMaxID(txt_IdSupplier.Text.ToString(), txt_IdSupplierNum.Text.ToString());

                if (s_SupplierManager.DeleteSupplierPermanen(s_Supplier))
                {
                    MessageBox.Show("Data berhasil dihapus permanen");
                    txt_IdSupplierNum.Text = Utils.DisplayMaxID(s_SupplierManager.GetMaxIDSupp().Substring(s_SupplierManager.GetMaxIDSupp().IndexOf("-") + 1));
                    ClearField();
                }
                else
                {
                    MessageBox.Show("Data gagal dihapus permanen");
                }
            }
            else
            {
                return;
            }
        }