示例#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 (lvUser.Items[lvUser.FocusedItem.Index].SubItems[0].Text == clsVariables.sUsercode)
         //{
         if (lvUser.Items.Count > 0)
         {
             try
             {
                 FormUser_Modify.ADD_STATE = false;
                 FormUser_Modify.sUserKode = lvUser.Items[lvUser.FocusedItem.Index].SubItems[0].Text;
                 FormUser_Modify sForm = new FormUser_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);
     }
 }
示例#2
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)
     {
         FormUser_Modify.ADD_STATE = true;
         FormUser_Modify sForm = new FormUser_Modify();
         sForm.ShowDialog();
     }
     else
     {
         MessageBox.Show("Anda perlu hak akses administrator untuk menggunakan fitur ini!", clsVariables.sMSGBOX, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#3
0
        private void FormUser_Modify_Load(object sender, EventArgs e)
        {
            if (ADD_STATE == true)
            {
                txtUserKode.Text = "USR-" + clsFunctions.GenerateCD("SELECT MAX(autoid) FROM tblusers", "tblusers");
                txtUserID.Text   = txtUserKode.Text;

                cmdAddUsers = new MySqlCommand("INSERT INTO tblusers( usercode , fullname, address, email, telephone, usertype, status, username, password, datemodify, usermodifyby, dateadded, useraddedby)" +
                                               "VALUES (@getUsercode,@getFullname,@getAddress,@getEmail,@getTelephone,@getUsertype,@getStatus,@getUsername,@getPassword,@getDatemodify,@getUsermodifyby, @getDateadded, @getUseraddedby)", clsConnection.CN);
                this.Text = "Add New";
            }
            else
            {
                try
                {
                    if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\@Data\\@Image\\" + sUserKode + ".lms") == true)
                    {
                        picLibrarian.Image = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "\\@Data\\@Image\\" + sUserKode + ".lms", true);
                    }
                }
                catch (Exception ex) { }

                txtUserKode.ReadOnly = true;

                //Set Edit OleDbCommand
                cmdAddUsers = new MySqlCommand("UPDATE tblusers SET usercode=@getUsercode, fullname=@getFullname, address=@getAddress, email=@getEmail, telephone=@getTelephone, usertype=@getUsertype, status=@getStatus, username=@getUsername, password=@getPassword, datemodify=@getDatemodify, usermodifyby=@getUsermodifyby WHERE usercode LIKE '" + sUserKode + "' ", clsConnection.CN);
                FillFields();
                this.Text = "Edit Existing";
            }

            cmdAddUsers.Parameters.Add("@getUsercode", MySqlDbType.VarChar);
            cmdAddUsers.Parameters.Add("@getFullname", MySqlDbType.VarChar);
            cmdAddUsers.Parameters.Add("@getAddress", MySqlDbType.Text);
            cmdAddUsers.Parameters.Add("@getEmail", MySqlDbType.VarChar);
            cmdAddUsers.Parameters.Add("@getTelephone", MySqlDbType.VarChar);
            cmdAddUsers.Parameters.Add("@getUsertype", MySqlDbType.Int16);
            cmdAddUsers.Parameters.Add("@getStatus", MySqlDbType.VarChar);
            cmdAddUsers.Parameters.Add("@getUsername", MySqlDbType.VarChar);
            cmdAddUsers.Parameters.Add("@getPassword", MySqlDbType.VarChar);
            cmdAddUsers.Parameters.Add("@getDatemodify", MySqlDbType.Date);
            cmdAddUsers.Parameters.Add("@getUsermodifyby", MySqlDbType.Int16);
            cmdAddUsers.Parameters.Add("@getDateadded", MySqlDbType.Date);
            cmdAddUsers.Parameters.Add("@getUseraddedby", MySqlDbType.Int16);

            publcFormUser_Modify = this;
        }