private void FormAddSellBill_Load(object sender, EventArgs e)
        {
            listCustomers = Customers.BacaData("", "");
            comboBoxPelanggan.DataSource    = listCustomers;
            comboBoxPelanggan.DisplayMember = "Nama";
            comboBoxPelanggan.DropDownStyle = ComboBoxStyle.DropDownList;


            formMenu = (FormMenu)this.Owner.MdiParent;
            labelKodePegawai.Text = formMenu.pegawaiLogin.IdPegawai.ToString();
            labelNamaPegawai.Text = formMenu.pegawaiLogin.Nama;

            textBoxNoNota.Text = NotaJual.GenerateNoNota();

            textBoxBarcode.MaxLength = 13;

            FormatDataGrid();
            dateTimePickerDate.Value = DateTime.Now;
            textBoxNoNota.Enabled    = false;
        }
示例#2
0
        private void textBoxUsername_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(Keys.Return))
            {
                try
                {
                    if (textBoxUsername.Text != "")
                    {
                        Koneksi koneksi = new Koneksi(textBoxServer.Text, textBoxDatabase.Text, textBoxUsername.Text, textBoxPassword.Text);

                        Koneksi koneksi2 = new Koneksi();

                        koneksi.Connect();
                        koneksi2.Connect();

                        MessageBox.Show("Koneksi Berhasil. Selamat menggunakan aplikasi", "Informasi");
                        this.Owner.WindowState = FormWindowState.Normal;
                        this.Owner.Enabled     = true;
                        this.Close();

                        listPegawai = Pegawai.BacaData("username", textBoxUsername.Text);
                        if (listPegawai.Count > 0)
                        {
                            FormMenu formMenu = (FormMenu)this.Owner;
                            formMenu.labelKodePegawai.Text    = listPegawai[0].IdPegawai.ToString();
                            formMenu.labelNamaPegawai.Text    = listPegawai[0].Nama;
                            formMenu.labelJabatanPegawai.Text = listPegawai[0].Jabatan.NamaJabatan;

                            formMenu.PengaturanHakAkses(listPegawai[0].Jabatan);

                            formMenu.pegawaiLogin = listPegawai[0];

                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Username dan Password tidak boleh kosong", "Kesalahan");
                        labelUsername.Visible = false;
                        textBoxUsername.Focus();
                        if (textBoxPassword.Text == "")
                        {
                            labelPassword.Visible = true;
                        }
                        else
                        {
                            labelPassword.Visible = false;
                        }
                        if (textBoxServer.Text == "")
                        {
                            labelServer.Visible = true;
                        }
                        else
                        {
                            labelServer.Visible = false;
                        }
                        if (textBoxDatabase.Text == "")
                        {
                            labelDatabase.Visible = true;
                        }
                        else
                        {
                            labelDatabase.Visible = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Koneksi Gagal. Pesan Kesalahan : " + ex.Message, "Kesalahan");
                    labelUsername.Visible = false;
                    textBoxUsername.Focus();
                    if (textBoxPassword.Text == "")
                    {
                        labelPassword.Visible = true;
                    }
                    else
                    {
                        labelPassword.Visible = false;
                    }
                    if (textBoxServer.Text == "")
                    {
                        labelServer.Visible = true;
                    }
                    else
                    {
                        labelServer.Visible = false;
                    }
                    if (textBoxDatabase.Text == "")
                    {
                        labelDatabase.Visible = true;
                    }
                    else
                    {
                        labelDatabase.Visible = false;
                    }
                }
            }
        }