Ejemplo n.º 1
0
        public bool insertData(mcolor k)
        {
            bool stat = false;

            try
            {
                Connection ConnG = new Connection();
                ConnG.Konek();
                strQuery             = new MySql.Data.MySqlClient.MySqlCommand();
                strQuery.Connection  = ConnG.Conn;
                strQuery.CommandType = CommandType.Text;
                //strQuery.CommandText = "INSERT INTO tKaryawan VALUES('" + k.getNIP() + "','" + k.getNama() + "','" + k.getAlamat() + "','" + k.getNotelp() + "','" + k.getHP() + "')";
                strQuery.CommandText = "INSERT INTO tblmcolor VALUES(@ColorID,@Description,@Active)";
                strQuery.Parameters.AddWithValue("@ColorID", k.ColorID);
                strQuery.Parameters.AddWithValue("@Description", k.Description);
                strQuery.Parameters.AddWithValue("@Active", k.Active);
                //strQuery.Parameters.AddWithValue("@Type", k.Type);
                strQuery.ExecuteNonQuery();
                stat = true;
                ConnG.Putus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(stat);
        }
Ejemplo n.º 2
0
        public bool updateData(string nip, mcolor k)
        {
            bool stat = false;

            try
            {
                Connection ConnG = new Connection();
                ConnG.Konek();
                strQuery             = new MySql.Data.MySqlClient.MySqlCommand();
                strQuery.Connection  = ConnG.Conn;
                strQuery.CommandType = CommandType.Text;
                strQuery.CommandText = "UPDATE tblmcolor SET DESCRIPTION=@Description,ACTIVE=@Active WHERE COLORID=@ColorID";
                strQuery.Parameters.AddWithValue("@Description", k.Description);
                strQuery.Parameters.AddWithValue("@Active", k.Active);
                //strQuery.Parameters.AddWithValue("@Type", k.Type);
                strQuery.Parameters.AddWithValue("@ColorID", k.ColorID);
                strQuery.ExecuteNonQuery();

                ConnG.Putus();
                stat = true;
            }
            catch
            {
            }
            return(stat);
        }