private void bttnAddNew_Click(object sender, EventArgs e) { FormMember_Modify.ADD_STATE = true; FormMember_Modify sForm = new FormMember_Modify(); sForm.ShowDialog(); }
private void FormMember_Modify_Load(object sender, EventArgs e) { FillComboDiscount(); if (ADD_STATE == true) { txtMemberKode.Text = "" + clsFunctions.GenerateCD("SELECT MAX(autoid) FROM tblmember", "tblmember"); cmdAddMembers = new MySqlCommand("INSERT INTO tblmember( membercode , fullname, address, telephone, status, discount)" + "VALUES (@getMemberCode,@getMemberName,@getAddress,@getTelephone,@getStatus,@getDiscount)", clsConnection.CN); this.Text = "Add New"; } else { txtMemberKode.ReadOnly = true; //Set Edit OleDbCommand cmdAddMembers = new MySqlCommand("UPDATE tblmember SET membercode=@getMemberCode, fullname=@getMemberName, address=@getAddress, telephone=@getTelephone, status=@getStatus, discount=@getDiscount WHERE membercode LIKE '" + sMemberKode + "' ", clsConnection.CN); FillFields(); this.Text = "Edit Existing"; } cmdAddMembers.Parameters.Add("@getMemberCode", MySqlDbType.VarChar); cmdAddMembers.Parameters.Add("@getMemberName", MySqlDbType.VarChar); cmdAddMembers.Parameters.Add("@getAddress", MySqlDbType.Text); cmdAddMembers.Parameters.Add("@getTelephone", MySqlDbType.VarChar); cmdAddMembers.Parameters.Add("@getStatus", MySqlDbType.VarChar); cmdAddMembers.Parameters.Add("@getDiscount", MySqlDbType.Decimal); publcFormMember_Modify = this; }
private void bttnModify_Click(object sender, EventArgs e) { if (lvMember.Items.Count > 0) { try { FormMember_Modify.ADD_STATE = false; FormMember_Modify.sMemberKode = lvMember.Items[lvMember.FocusedItem.Index].SubItems[0].Text; FormMember_Modify sForm = new FormMember_Modify(); sForm.ShowDialog(); } catch (ArgumentOutOfRangeException aooreE) {} catch (NullReferenceException nreE) { } } else { MessageBox.Show("No record to edit.", clsVariables.sMSGBOX, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }