Ejemplo n.º 1
0
        public MySqlDataReader GetTable(List <KeyValuePair <string, string> > condition)
        {
            MySqlDataReader data      = null;
            string          Condition = "";

            if (condition.Count > 1)
            {
                Condition = Condition + " AND " + condition[0].Key + " LIKE " + condition[0].Value;
                Condition = Condition + " ORDER BY " + condition[1].Key + " " + condition[1].Value;
            }
            else
            {
                Condition = Condition + " ORDER BY " + condition[0].Key + " " + condition[0].Value;
            }

            string Query = "SELECT * FROM (\n" +
                           "   SELECT (@NoUrut := @NoUrut+1) AS `No`, Tbl.* FROM (\n" +
                           "      SELECT " + FIELDNAME + " FROM " + TABLENAME + "\n" +
                           "   ) Tbl CROSS JOIN (SELECT @NoUrut:=0)testing\n" +
                           ") TblLuar WHERE `Hapus` = 0 " + Condition;

            if (!aspQuery.Select(Query, ref data))
            {
                ASPMsgCmp.ErrorMessage("Fail to read get data from Master Group!");
            }
            return(data);
        }
Ejemplo n.º 2
0
 protected override void Save()
 {
     LoadData();
     if (GMode == ASPConstant.ModeNew)
     {
         if (GDBMKaryawan.Insert(GMKaryawan))
         {
             ASPMsgCmp.InfoMessage("Data berhasil disimpan.");
         }
         else
         {
             ASPMsgCmp.ErrorMessage("Data gagal disimpan.");
         }
     }
     else if (GMode == ASPConstant.ModeEdit)
     {
         if (GDBMKaryawan.Update(GMKaryawan))
         {
             ASPMsgCmp.InfoMessage("Data berhasil disimpan.");
         }
         else
         {
             ASPMsgCmp.ErrorMessage("Data gagal disimpan.");
         }
     }
     GMKaryawan = GDBMKaryawan.Clear();
     ShowData();
     SetMode(ASPConstant.ModeBrowse);
     GetTable();
     dataGridView.Focus();
 }
Ejemplo n.º 3
0
        public BindingSource GetTable(string query)
        {
            BindingSource bindingSource = new BindingSource();
            string        Query         = "SELECT * FROM (\n" +
                                          query +
                                          ") TblLuar WHERE `Hapus` = 0 LIMIT 0,50";

            if (!aspQuery.Select(Query, ref bindingSource))
            {
                ASPMsgCmp.ErrorMessage("Fail to read get data from Browse Form!");
            }
            return(bindingSource);
        }
Ejemplo n.º 4
0
        protected override void DeleteRecord()
        {
            bool CanDelete = true;

            if (GMode == ASPConstant.ModeBrowse && dataGridView.SelectedRows.Count > 0)
            {
                base.DeleteRecord();
                DataGridViewRow row = dataGridView.SelectedRows[0];
                if (!GDBMKaryawan.SelectById(int.Parse(row.Cells["IdMKaryawan"].Value.ToString()), ref GMKaryawan))
                {
                    GMKaryawan = GDBMKaryawan.Clear();
                    CanDelete  = false;
                }

                if (CanDelete)
                {
                    if (ASPMsgCmp.QuestionMessage("Yakin ingin menghapus " + GMKaryawan.NmMKaryawan + "?") == DialogResult.Yes)
                    {
                        GMKaryawan.IdMUserUpdate = MainForm.FMCurrUser.IdMKaryawan;
                        GMKaryawan.TglUpdate     = GDBMJabatan.GetNow();
                        GMKaryawan.Hapus         = true;

                        if (GDBMKaryawan.Delete(GMKaryawan))
                        {
                            ASPMsgCmp.InfoMessage("Data berhasil dihapus.");
                        }
                        else
                        {
                            ASPMsgCmp.ErrorMessage("Data gagal dihapus.");
                        }
                    }
                }

                GMKaryawan = GDBMKaryawan.Clear();
                ShowData();
                SetMode(ASPConstant.ModeBrowse);
                GetTable();
            }
        }