Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            dbClass   db      = new dbClass();
            DataTable dt_job  = new DataTable();
            DataTable dt_dept = new DataTable();

            dt_job  = db.dbSelect("SELECT id FROM tb_job WHERE description='" + cmbJob.Text + "'");
            dt_dept = db.dbSelect("SELECT id FROM tb_department WHERE code='" + cmbDept.Text + "'");
            DataTable parent = db.dbSelect("SELECT id from tb_department WHERE code='" + cmbParent.Text + "'");

            if (this.activeForm == "Information")
            {
                db.dbInsert("INSERT INTO tb_info (lastname, firstname, middlename, address, birthdate, birthplace, contact, department, job) VALUES ('" + txtLN.Text + "', '" + txtFN.Text + "', '" + txtMN.Text + "', '" + txtAdd.Text + "', '" + pickBday.Text + "', '" + txtBPlace.Text + "', '" + txtContact.Text + "', " + Convert.ToInt32(dt_dept.Rows[0][0]) + ", " + Convert.ToInt32(dt_job.Rows[0][0]) + ")");
            }
            if (this.activeForm == "Department")
            {
                db.dbInsert("INSERT INTO tb_department (code, description) VALUES ('" + txtCode.Text + "', '" + txtDesc.Text + "')");
            }
            if (this.activeForm == "Job")
            {
                db.dbInsert("INSERT INTO tb_job (description, parent, salary) VALUES ('" + txtJob.Text + "', " + parent.Rows[0][0] + ", " + txtSalary.Text + ")");
            }
            Main main = new Main();

            this.Hide();
            main.Show();
            MessageBox.Show("Added!");
        }
Exemple #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            dbClass   db     = new dbClass();
            DataTable jb     = db.dbSelect("SELECT id from tb_job WHERE description='" + cmbJob.Text + "'");
            DataTable dp     = db.dbSelect("SELECT id from tb_department WHERE code='" + cmbDept.Text + "'");
            DataTable parent = db.dbSelect("SELECT id from tb_department WHERE code='" + cmbParent.Text + "'");

            if (this.activeForm == "Information")
            {
                db.dbUpdate("UPDATE tb_info SET lastname='" + txtLN.Text + "', firstname='" + txtFN.Text + "', middlename='" + txtMN.Text + "', address='" + txtAdd.Text + "', birthdate='" + pickBday.Text + "', birthplace='" + txtBPlace.Text + "', contact='" + txtContact.Text + "', department=" + dp.Rows[0][0].ToString() + ", job=" + jb.Rows[0][0].ToString() + " WHERE id=" + this.activeID);
            }
            if (this.activeForm == "Department")
            {
                db.dbUpdate("UPDATE tb_department SET code='" + txtCode.Text + "', description='" + txtDesc.Text + "' WHERE id=" + this.activeID);
            }
            if (this.activeForm == "Job")
            {
                db.dbUpdate("UPDATE tb_job SET description='" + txtJob.Text + "', parent=" + parent.Rows[0][0] + ", salary=" + txtSalary.Text + " WHERE id=" + this.activeID);
            }
            Main main = new Main();

            this.Hide();
            main.Show();
            MessageBox.Show("Updated!");
        }
Exemple #3
0
        private void calcIncome(int days, double gross, double overtime, int absences, double loans, double netpay)
        {
            dbClass   db      = new dbClass();
            DataTable getJob  = db.dbSelect("SELECT job from tb_info WHERE id=" + this.del_id);
            DataTable getJobs = db.dbSelect("SELECT salary from tb_job where id=" + getJob.Rows[0][0]);

            MessageBox.Show(getJobs.Rows[0][0].ToString());
        }
Exemple #4
0
        public void getJob()
        {
            DataTable dt     = new DataTable();
            dbClass   db     = new dbClass();
            DataTable parent = db.dbSelect("SELECT id from tb_department WHERE code='" + cmbDept.Text + "'");

            try {
                dt = db.dbSelect("SELECT * FROM tb_job WHERE parent=" + parent.Rows[0][0]);
            } catch { }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbJob.Items.Add(dt.Rows[i]["description"]);
            }
        }
Exemple #5
0
        private void cmbJob_SelectedIndexChanged(object sender, EventArgs e)
        {
            dbClass   db  = new dbClass();
            DataTable sal = db.dbSelect("select salary from tb_job where description='" + cmbJob.Text + "'");

            lblSal.Text = sal.Rows[0][0].ToString();
        }
Exemple #6
0
        private void getJobData()
        {
            dbClass db = new dbClass();

            System.Data.DataTable dt = db.dbSelect("SELECT * FROM tb_job ORDER BY id DESC");
            dataGridView2.DataSource = dt;
        }
Exemple #7
0
        private void getDeptData()
        {
            dbClass db = new dbClass();

            System.Data.DataTable dt = db.dbSelect("SELECT * FROM tb_department ORDER BY id DESC");
            dataGridView3.DataSource = dt;
        }
Exemple #8
0
        private void getEmployee()
        {
            dbClass db = new dbClass();

            System.Data.DataTable dt = db.dbSelect("SELECT * FROM tb_employee ORDER BY id DESC");
            dataGridView4.DataSource = dt;
        }
Exemple #9
0
        private void Income_Load(object sender, EventArgs e)
        {
            this.AcceptButton = btnAdd;
            dbClass   db = new dbClass();
            DataTable dt = db.dbSelect("SELECT * FROM tb_info");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbEmployees.Items.Add(dt.Rows[i]["firstname"].ToString() + " " + dt.Rows[i]["lastname"].ToString());
            }
        }
Exemple #10
0
        public void getDept()
        {
            DataTable dt = new DataTable();
            dbClass   db = new dbClass();

            dt = db.dbSelect("SELECT * FROM tb_department");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbDept.Items.Add(dt.Rows[i]["code"]);
                cmbParent.Items.Add(dt.Rows[i]["code"]);
            }
        }
Exemple #11
0
        private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            DialogResult result = MessageBox.Show("Click YES to edit info press NO to print.", "Action", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (result.Equals(DialogResult.No))
            {
                Print_Ind ind = new Print_Ind();
                ind.id = this.del_id;
                ind.Show();
            }
            else
            {
                dbClass   db   = new dbClass();
                DataTable jb   = db.dbSelect("SELECT description from tb_job WHERE id=" + dataGridView1.CurrentRow.Cells[9].Value.ToString());
                DataTable dp   = db.dbSelect("SELECT code from tb_department WHERE id=" + dataGridView1.CurrentRow.Cells[8].Value.ToString());
                FillForm  form = new FillForm();
                form.getDept();
                form.getJob();
                if (this.activeTab == "Information")
                {
                    form.comboBox1.Text    = "Information";
                    form.txtLN.Text        = dataGridView1.CurrentRow.Cells[1].Value.ToString();
                    form.txtFN.Text        = dataGridView1.CurrentRow.Cells[2].Value.ToString();
                    form.txtMN.Text        = dataGridView1.CurrentRow.Cells[3].Value.ToString();
                    form.txtAdd.Text       = dataGridView1.CurrentRow.Cells[4].Value.ToString();
                    form.pickBday.Text     = dataGridView1.CurrentRow.Cells[5].Value.ToString();
                    form.txtBPlace.Text    = dataGridView1.CurrentRow.Cells[6].Value.ToString();
                    form.txtContact.Text   = dataGridView1.CurrentRow.Cells[7].Value.ToString();
                    form.cmbDept.Text      = dp.Rows[0][0].ToString();
                    form.cmbJob.Text       = jb.Rows[0][0].ToString();
                    form.btnUpdate.Visible = true;
                    form.btnAdd.Visible    = false;
                    form.activeID          = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                    this.Hide();
                    form.Show();
                }
            }
        }
Exemple #12
0
        private void cmbEmployees_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataTable id, job, salary, get_job, get_dept;

            txtNetGross.Text = "";
            dbClass db = new dbClass();

            String[] name = cmbEmployees.Text.Split(' ');
            id             = db.dbSelect("select id from tb_info where firstname='" + name[0] + "' and lastname ='" + name[1] + "'");
            this.id        = Convert.ToInt32(id.Rows[0][0]);
            job            = db.dbSelect("select job from tb_info where id=" + this.id);
            get_job        = db.dbSelect("select description, parent from tb_job where id=" + job.Rows[0][0]);
            get_dept       = db.dbSelect("select description from tb_department where id=" + get_job.Rows[0][1]);
            salary         = db.dbSelect("select salary from tb_job where id=" + job.Rows[0][0]);
            this.salary    = Convert.ToDecimal(salary.Rows[0][0]);
            txtSalary.Text = salary.Rows[0][0].ToString();
            lblDept.Text   = get_dept.Rows[0][0].ToString();
            lblJob.Text    = get_job.Rows[0][0].ToString();
            try {
                calcGross(Convert.ToDecimal(salary.Rows[0][0]), Convert.ToInt32(numWorkDays.Value), Convert.ToInt32(numOT.Value));
                calcNet(Convert.ToInt32(numAbsent.Value), Convert.ToDecimal(txtLoans.Text));
            } catch { }
        }
Exemple #13
0
        private void dataGridView2_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            dbClass   db     = new dbClass();
            DataTable parent = db.dbSelect("SELECT code from tb_department WHERE id=" + dataGridView2.CurrentRow.Cells[2].Value.ToString());
            FillForm  form   = new FillForm();

            form.getDept();
            if (this.activeTab == "Job")
            {
                form.comboBox1.Text    = "Job";
                form.btnUpdate.Visible = true;
                form.btnAdd.Visible    = false;
                form.activeID          = dataGridView2.CurrentRow.Cells[0].Value.ToString();
                form.txtJob.Text       = dataGridView2.CurrentRow.Cells[1].Value.ToString();
                form.cmbParent.Text    = parent.Rows[0][0].ToString();
                form.txtSalary.Text    = dataGridView2.CurrentRow.Cells[3].Value.ToString();
                this.Hide();
                form.Show();
            }
        }