Esempio n. 1
0
 private void frmCheckerUpdate_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (this.DialogResult == DialogResult.OK)
     {
         if (this.Caller is frmCheckerBrowse)
         {
             frmCheckerBrowse frmCaller = (frmCheckerBrowse)this.Caller;
             frmCaller.RefreshData();
             //frmCaller.FindRow("CheckerID", checkerID);
         }
     }
 }
Esempio n. 2
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtFirstName.Text))
            {
                MessageBox.Show("Nama depan belum diisi");
                txtFirstName.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtMasuk.Text))
            {
                MessageBox.Show("Tanggal masuk belum diisi");
                txtMasuk.Focus();
                return;
            }

            if (txtKeluar.DateValue < txtMasuk.DateValue)
            {
                MessageBox.Show("Tanggal keluar tidak boleh lebih kecil dari tanggal masuk");
                txtKeluar.Focus();
                return;
            }

            try
            {
                switch (formMode)
                {
                case enumFormMode.New:
                    using (Database db = new Database())
                    {
                        db.Open();

                        checkerID = Tools.CreateFingerPrint();
                        DataTable dt = new DataTable();
                        db.Commands.Add(db.CreateCommand("usp_Checker_INSERT"));

                        db.Commands[0].Parameters.Add(new Parameter("@checkerID", SqlDbType.VarChar, checkerID));
                        db.Commands[0].Parameters.Add(new Parameter("@FirstName", SqlDbType.VarChar, txtFirstName.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@LastName", SqlDbType.VarChar, txtLastName.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Alamat", SqlDbType.VarChar, txtAlamat.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Kota", SqlDbType.VarChar, txtKota.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Masuk", SqlDbType.DateTime, txtMasuk.DateValue));
                        db.Commands[0].Parameters.Add(new Parameter("@Keluar", SqlDbType.DateTime, txtKeluar.DateValue));
                        db.Commands[0].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        dt = db.Commands[0].ExecuteDataTable();

                        db.Close();
                        db.Dispose();
                    }
                    break;

                case enumFormMode.Update:
                    using (Database db = new Database())
                    {
                        db.Open();

                        DataTable dt = new DataTable();
                        db.Commands.Add(db.CreateCommand("usp_Checker_UPDATE"));
                        db.Commands[0].Parameters.Add(new Parameter("@checkerID", SqlDbType.VarChar, _rowID));
                        db.Commands[0].Parameters.Add(new Parameter("@FirstName", SqlDbType.VarChar, txtFirstName.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@LastName", SqlDbType.VarChar, txtLastName.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Alamat", SqlDbType.VarChar, txtAlamat.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Kota", SqlDbType.VarChar, txtKota.Text));
                        db.Commands[0].Parameters.Add(new Parameter("@Masuk", SqlDbType.DateTime, txtMasuk.DateValue));
                        db.Commands[0].Parameters.Add(new Parameter("@Keluar", SqlDbType.DateTime, txtKeluar.DateValue));
                        db.Commands[0].Parameters.Add(new Parameter("@lastUpdatedBy", SqlDbType.VarChar, SecurityManager.UserID));
                        db.Commands[0].ExecuteNonQuery();

                        db.Close();
                        db.Dispose();
                    }
                    break;
                }

                this.DialogResult = DialogResult.OK;
                frmCheckerBrowse frmCaller = (frmCheckerBrowse)this.Caller;
                frmCaller.RefreshData();
                this.Close();
                frmCaller.Show();
            }
            catch (Exception ex)
            {
                Error.LogError(ex);
            }
        }