Exemplo n.º 1
0
        /// <summary>
        /// Handles the Click event of the btnDelete control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            // --- If Not EditMode
            if (_saveMode != SaveMode.EditMode) return;

            try
            {
                var r = new Keymap
                            {
                                Keyboard = txtID.Text.Trim(),
                                Action = cboAction.SelectedIndex,
                                LoketID = cboLoket.Text.Trim()
                            };

                IDataAccess<Keymap> db = new KeymapBase();

                if (Confirm("Are you sure to delete this data?") == DialogResult.Yes)
                {
                    DialogResult dlg;
                    using (var f = new LogonPresentation())
                    {
                        dlg = f.ShowDialog(this);
                    }

                    if (dlg == DialogResult.OK)
                    {
                        if ((db.Delete(r) == 1)) ResetData();
                    }
                }
            }
            catch (ArgumentNullException ex)
            {
                MessageBox.Show(ex.Message, @"Warning!",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, @"Warning!",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the KeyUp event of the MainScreen control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.KeyEventArgs"/> instance containing the event data.</param>
        private void MainScreen_KeyUp(object sender, KeyEventArgs e)
        {
            if (_stillProcessing) return;

            /* --------------------------------------
             *  keymaps
             * -------------------------------------- */
            var db = new KeymapBase();
            _keymap = db.GetById(e.KeyCode.ToString().Trim());
            db.Dispose();

            /* --------------------------------------
             *  null keymaps
             * -------------------------------------- */
            if (_keymap == null)
                return;

            // status
            _stillProcessing = true;
            Application.DoEvents();

            /* --------------------------------------
             *  get loket information
             * -------------------------------------- */
            string loketid = _keymap.LoketID.ToUpper().Trim();
            string loketDesc = "";
            foreach (Loket r in _lokets.Where(r => r.LoketID == loketid))
                loketDesc = r.LoketDescription;

            /* --------------------------------------
             *  loket switching
             * -------------------------------------- */
            switch (loketid)
            {
                case "BERKAS":

                    /* -------------------------------
                     *  if NEXT
                     * ------------------------------- */
                    if (_keymap.Action == 0)
                        _tmpBerkas.Nomor = _dbBerkas.GetNextNumber();

                    /* -------------------------------
                     *  if NOT FOUND
                     * ------------------------------- */
                    if (_tmpBerkas.Nomor == 0)
                    {
                        var tbell = new Thread(TPlayBell);
                        tbell.Start();
                        Thread.Sleep(100);

                        break;
                    }

                    /* -------------------------------
                     *  set value for calling
                     * ------------------------------- */
                    _tmpBerkas.ID = "A";
                    _tmpBerkas.NomorAntrian =
                        string.Format("{0}-{1}", _tmpBerkas.ID,
                                      _tmpBerkas.Nomor.ToString().Trim().PadLeft(3, '0'));

                    _tmpBerkas.LoketID = loketid;
                    _tmpBerkas.LoketDescription = loketDesc;

                    /* -------------------------------
                     *  calling
                     * ------------------------------- */
                    //var trBerkas = new Thread(TCallBerkas);
                    //trBerkas.Start();
                    //Thread.Sleep(100);
                    TCallBerkas();

                    /* -------------------------------
                     *  if NEXT, update called
                     *  status
                     * ------------------------------- */
                    if (_keymap.Action == 0)
                        _dbBerkas.UpdateCalled(_tmpBerkas.Nomor);

                    /* -------------------------------
                     *  show on BOX
                     * ------------------------------- */
                    lblBerkas.Text = _tmpBerkas.NomorAntrian;
                    lblBerkas.Refresh();

                    break;

                case "BAYAR":

                    /* -------------------------------
                     *  if NEXT
                     * ------------------------------- */
                    if (_keymap.Action == 0)
                    {
                        int i = 0;
                        int n = 0;

                        /* -------------------------------
                         *  FLIP FLOP
                         * ------------------------------- */
                        while (i == 0 && n <= 1)
                        {
                            /* get next number
                             * by current id */
                            _tmpBayar.Nomor = _dbKasir.GetKasirNextNumber(_tmpBayar.ID);
                            i = _tmpBayar.Nomor;
                            n++;

                            /* if not found, convert id into another
                             * and repeat the process */
                            if (i == 0) _tmpBayar.ID = ConvertID(_tmpBayar.ID);
                            _tmpBayar.ReplayID = _tmpBayar.ID;
                        }
                    }

                    /* -------------------------------
                     *  if NOT FOUND
                     * ------------------------------- */
                    if (_tmpBayar.Nomor == 0)
                    {
                        var tbell = new Thread(TPlayBell);
                        tbell.Start();
                        Thread.Sleep(100);

                        break;
                    }

                    /* -------------------------------
                     *  set value for calling
                     * ------------------------------- */
                    _tmpBayar.NomorAntrian =
                        string.Format("{0}-{1}", _tmpBayar.ReplayID,
                                      _tmpBayar.Nomor.ToString().Trim().PadLeft(3, '0'));

                    _tmpBayar.LoketID = loketid;
                    _tmpBayar.LoketDescription = loketDesc;

                    /* -------------------------------
                     *  calling
                     * ------------------------------- */
                    //var trBayar = new Thread(TCallBayar);
                    //trBayar.Start();
                    //Thread.Sleep(100);
                    TCallBayar();

                    /* -------------------------------
                     *  if NEXT, update called
                     *  status
                     * ------------------------------- */
                    if (_keymap.Action == 0)
                    {
                        _dbKasir.UpdateKasirCalled(_tmpBayar.ID, _tmpBayar.Nomor);
                        _tmpBayar.ID = ConvertID(_tmpBayar.ID);
                    }

                    /* -------------------------------
                     *  show on BOX
                     * ------------------------------- */
                    lblKasir.Text = _tmpBayar.NomorAntrian;
                    lblKasir.Refresh();

                    break;

                case "FOTO":

                    /* -------------------------------
                     *  if NEXT
                     * ------------------------------- */
                    if (_keymap.Action == 0)
                    {
                        int i = 0;
                        int n = 0;

                        /* -------------------------------
                         *  FLIP FLOP
                         * ------------------------------- */
                        while (i == 0 && n <= 1)
                        {
                            /* get next number
                             * by current id */
                            _tmpFoto.Nomor = new KasirBase().GetFotoNextNumber(_tmpFoto.ID);
                            i = _tmpFoto.Nomor;
                            n++;

                            /* if not found, convert id into another
                             * and repeat the process */
                            if (i == 0) _tmpFoto.ID = ConvertID(_tmpFoto.ID);
                            _tmpFoto.ReplayID = _tmpFoto.ID;
                        }
                    }

                    /* -------------------------------
                     *  if NOT FOUND
                     * ------------------------------- */
                    if (_tmpFoto.Nomor == 0)
                    {
                        var tbell = new Thread(TPlayBell);
                        tbell.Start();
                        Thread.Sleep(100);

                        break;
                    }

                    /* -------------------------------
                     *  set value for calling
                     * ------------------------------- */
                    _tmpFoto.NomorAntrian =
                        string.Format("{0}-{1}", _tmpFoto.ReplayID,
                                      _tmpFoto.Nomor.ToString().Trim().PadLeft(3, '0'));

                    _tmpFoto.LoketID = loketid;
                    _tmpFoto.LoketDescription = loketDesc;

                    /* -------------------------------
                     *  calling
                     * ------------------------------- */
                    //var trFoto = new Thread(TCallFoto);
                    //trFoto.Start();
                    //Thread.Sleep(100);
                    TCallFoto();

                    /* -------------------------------
                     *  if NEXT, update called
                     *  status
                     * ------------------------------- */
                    if (_keymap.Action == 0)
                    {
                        _dbKasir.UpdateFotoCalled(_tmpFoto.ID, _tmpFoto.Nomor);
                        _tmpFoto.ID = ConvertID(_tmpFoto.ID);
                    }

                    /* -------------------------------
                     *  show on BOX
                     * ------------------------------- */
                    lblFoto.Text = _tmpFoto.NomorAntrian;
                    lblFoto.Refresh();

                    break;

                case "WAWANCARA":

                    /* -------------------------------
                     *  if NEXT
                     * ------------------------------- */
                    if (_keymap.Action == 0)
                    {
                        int i = 0;
                        int n = 0;

                        /* -------------------------------
                         *  FLIP FLOP
                         * ------------------------------- */
                        while (i == 0 && n <= 1)
                        {
                            /* get next number
                             * by current id */
                            _tmpWawancara.Nomor = new KasirBase().GetWawancaraNextNumber(_tmpWawancara.ID);
                            i = _tmpWawancara.Nomor;
                            n++;

                            /* if not found, convert id into another
                             * and repeat the process */
                            if (i == 0) _tmpWawancara.ID = ConvertID(_tmpWawancara.ID);
                            _tmpWawancara.ReplayID = _tmpWawancara.ID;
                        }
                    }

                    /* -------------------------------
                     *  if NOT FOUND
                     * ------------------------------- */
                    if (_tmpWawancara.Nomor == 0)
                    {
                        var tbell = new Thread(TPlayBell);
                        tbell.Start();
                        Thread.Sleep(100);

                        break;
                    }

                    /* -------------------------------
                     *  set value for calling
                     * ------------------------------- */
                    _tmpWawancara.NomorAntrian =
                        string.Format("{0}-{1}", _tmpWawancara.ReplayID,
                                      _tmpWawancara.Nomor.ToString().Trim().PadLeft(3, '0'));

                    _tmpWawancara.LoketID = loketid;
                    _tmpWawancara.LoketDescription = loketDesc;

                    /* -------------------------------
                     *  calling
                     * ------------------------------- */
                    //var trWawancara = new Thread(TCallWawancara);
                    //trWawancara.Start();
                    //Thread.Sleep(100);
                    TCallWawancara();

                    /* -------------------------------
                     *  if NEXT, update called
                     *  status
                     * ------------------------------- */
                    if (_keymap.Action == 0)
                    {
                        _dbKasir.UpdateWawancaraCalled(_tmpWawancara.ID, _tmpWawancara.Nomor);
                        _tmpWawancara.ID = ConvertID(_tmpWawancara.ID);
                    }

                    /* -------------------------------
                     *  show on BOX
                     * ------------------------------- */
                    lblWawancara.Text = _tmpWawancara.NomorAntrian;
                    lblWawancara.Refresh();

                    break;
            }

            // end process
            _stillProcessing = false;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                var r = new Keymap
                            {
                                Keyboard = txtID.Text.Trim(),
                                Action = cboAction.SelectedIndex,
                                LoketID = cboLoket.Text.Trim()
                            };

                // --- Confirm
                if (Confirm("Do you want to save this data?") != DialogResult.Yes) return;

                DialogResult dlg;

                using (var f = new LogonPresentation())
                {
                    dlg = f.ShowDialog(this);
                }

                if (dlg == DialogResult.OK)
                {
                    var db = new KeymapBase();

                    if ((_saveMode == SaveMode.AddMode
                             ? db.Save(r) // Save New
                             : db.Update(r)) == 1) // Update
                        ResetData();

                    db.Dispose();

                }
            }
            catch (ArgumentNullException ex)
            {
                MessageBox.Show(ex.Message, @"Warning!",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, @"Warning!",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }