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 (lvCategory.Items.Count > 0) { try { FormCategory_Modify.ADD_STATE = false; FormCategory_Modify.sCategoryKode = lvCategory.Items[lvCategory.FocusedItem.Index].SubItems[0].Text; FormCategory_Modify sForm = new FormCategory_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); } }
private void FormCategory_Modify_Load(object sender, EventArgs e) { if (ADD_STATE == true) { txtCategoryCode.Text = "CAT-" + clsFunctions.GenerateCD("SELECT MAX(autoid) FROM tblcategory", "tblcategory"); cmdAddCategory = new MySqlCommand("INSERT INTO tblcategory( categorycode , categoryname, description, dateadded, addedby)" + "VALUES (@getCategoryCode,@getCategoryName,@getDescription,@getDateAdded,@getAddedBy)", clsConnection.CN); this.Text = "Add New"; } else { txtCategoryCode.ReadOnly = true; //Set Edit OleDbCommand cmdAddCategory = new MySqlCommand("UPDATE tblcategory SET categorycode=@getCategoryCode, categoryname=@getCategoryName, description=@getDescription, dateadded=@getDateAdded, addedby=@getAddedBy WHERE categorycode LIKE '" + sCategoryKode + "' ", clsConnection.CN); FillFields(); this.Text = "Edit Existing"; } cmdAddCategory.Parameters.Add("@getCategoryCode", MySqlDbType.VarChar); cmdAddCategory.Parameters.Add("@getCategoryName", MySqlDbType.VarChar); cmdAddCategory.Parameters.Add("@getDescription", MySqlDbType.Text); cmdAddCategory.Parameters.Add("@getDateAdded", MySqlDbType.Date); cmdAddCategory.Parameters.Add("@getAddedBy", MySqlDbType.Int16); publcFormCategory_Modify = this; }
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) { FormCategory_Modify.ADD_STATE = true; FormCategory_Modify sForm = new FormCategory_Modify(); sForm.ShowDialog(); } else { MessageBox.Show("Anda perlu hak akses administrator untuk menggunakan fitur ini!", clsVariables.sMSGBOX, MessageBoxButtons.OK, MessageBoxIcon.Error); } }