Example #1
0
 private void bttnModify_Click(object sender, EventArgs e)
 {
     if (clsFunctions.recordExist("SELECT tblusers.usercode, tblusers.usertype FROM tblusers WHERE (tblusers.usertype=1 && tblusers.usercode='" + clsVariables.sUsercode + "') ORDER BY tblusers.autoid ASC", "tblusers") == true)
     {
         if (lvProduct.Items.Count > 0)
         {
             try
             {
                 FormProduct_Modify.ADD_STATE    = false;
                 FormProduct_Modify.sProductKode = lvProduct.Items[lvProduct.FocusedItem.Index].SubItems[0].Text;
                 FormProduct_Modify sForm = new FormProduct_Modify();
                 sForm.ShowDialog();
             }
             catch (ArgumentOutOfRangeException aooreE) { MessageBox.Show("" + aooreE.Message); }
             catch (NullReferenceException nreE) { }
         }
         else
         {
             MessageBox.Show("No record to edit.", clsVariables.sMSGBOX, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     else
     {
         MessageBox.Show("Anda perlu hak akses administrator untuk menggunakan fitur ini!", clsVariables.sMSGBOX, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #2
0
        private void FormProduct_Modify_Load(object sender, EventArgs e)
        {
            if (ADD_STATE == true)
            {
                //txtProductCode.Text = "PROD-" + clsFunctions.GenerateCD("SELECT MAX(autoid) FROM tblproduct", "tblproduct");

                cmdAddProduct = new MySqlCommand("INSERT INTO tblproduct( productcode , productname, categoryautoid, supplierautoid, unitprice, sellingprice, stock)" +
                                                 "VALUES (@getProductCode,@getProductName,@getCategoryId,@getSupplierID,@getUnitPrice,@getSellingPrice,@getStock)", clsConnection.CN);
                this.Text = "Add New";
            }
            else
            {
                txtProductCode.Enabled = false;

                //Set Edit OleDbCommand
                cmdAddProduct = new MySqlCommand("UPDATE tblproduct SET productcode=@getProductCode, productname=@getProductName, categoryautoid=@getCategoryId, supplierautoid=@getSupplierID, unitprice=@getUnitPrice, sellingprice=@getSellingPrice, stock=@getStock WHERE productcode LIKE '" + sProductKode + "' ", clsConnection.CN);
                FillFields();
                this.Text = "Edit Existing";
            }

            cmdAddProduct.Parameters.Add("@getProductCode", MySqlDbType.VarChar);
            cmdAddProduct.Parameters.Add("@getProductName", MySqlDbType.VarChar);
            cmdAddProduct.Parameters.Add("@getCategoryId", MySqlDbType.Int16);
            cmdAddProduct.Parameters.Add("@getSupplierID", MySqlDbType.Int16);
            cmdAddProduct.Parameters.Add("@getUnitPrice", MySqlDbType.Decimal);
            cmdAddProduct.Parameters.Add("@getSellingPrice", MySqlDbType.Decimal);
            cmdAddProduct.Parameters.Add("@getStock", MySqlDbType.Int16);


            publcFormProduct_Modify = this;
        }
Example #3
0
 private void bttnAddNew_Click(object sender, EventArgs e)
 {
     if (clsFunctions.recordExist("SELECT tblusers.usercode, tblusers.usertype FROM tblusers WHERE (tblusers.usertype=1 && tblusers.usercode='" + clsVariables.sUsercode + "') ORDER BY tblusers.autoid ASC", "tblusers") == true)
     {
         FormProduct_Modify.ADD_STATE = true;
         FormProduct_Modify sForm = new FormProduct_Modify();
         sForm.ShowDialog();
     }
     else
     {
         MessageBox.Show("Anda perlu hak akses administrator untuk menggunakan fitur ini!", clsVariables.sMSGBOX, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }