private void btn_save_supply_Click(object sender, EventArgs e)
        {
            int isDrug = (tb_dosage.Text == "") ? 0 : 1;

            DB = new FinalSanitariumMIS.Helpers.DatabaseHelper();

            DB2ResultSet rs = DB.QueryWithResultSet("SELECT ITEM_NUMBER FROM SUPPLY WHERE ITEM_NUMBER = " + tb_supply_no.Text);

            if (!rs.Read())
            {
                DB.Query("INSERT INTO SUPPLY VALUES (" +
                         tb_supply_no.Text + "," + tb_supplier.Text + ",'" + tb_supply_name.Text + "','" + tb_description.Text + "',0," +
                         tb_reorder_level.Text + ",'" + tb_unit.Text + "'," + tb_cost_per_unit.Text + "," + isDrug + ",'" + tb_dosage.Text + "','" +
                         cb_method_administration.Text + "')");
            }
            else
            {
                DB.Query("UPDATE SUPPLY SET " +
                         "SUPPLIER_NUMBER = " + tb_supplier.Text + ", ITEM_NAME = '" + tb_supply_name.Text + "', DESCRIPTION = '" + tb_description.Text +
                         "', REORDER_LEVEL = " + tb_reorder_level.Text + ", UNIT = '" + tb_unit.Text + "', COST_PER_UNIT = " + tb_cost_per_unit.Text +
                         ", ITEM_TYPE = " + isDrug + ", DOSAGE = '" + tb_dosage.Text + "', METHOD_OF_ADMINISTRATION = '" + cb_method_administration.Text +
                         "' WHERE ITEM_NUMBER = " + dgv_inventory.CurrentRow.Cells[0].Value.ToString());
            }

            RefreshMasterList();
            ClearAllFields();
        }
        private void btn_add_stock_Click(object sender, EventArgs e)
        {
            DB = new FinalSanitariumMIS.Helpers.DatabaseHelper();

            DB.Query("UPDATE SUPPLY SET QUANTITY = QUANTITY + " + tb_stock_quantity.Text + " WHERE ITEM_NUMBER = " + dgv_inventory.CurrentRow.Cells[0].Value.ToString());
            RefreshMasterList();

            tb_stock_quantity.Text  = "";
            panel_add_stock.Visible = false;
        }
Exemple #3
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            DB = new FinalSanitariumMIS.Helpers.DatabaseHelper();

            DB2ResultSet rs = DB.QueryWithResultSet("SELECT * FROM SUPPLIER WHERE supplier_number = '" + tb_supplier_number.Text + "'");

            if (rs.Read())
            {
                DB.Query("UPDATE SUPPLIER SET " +
                         "SUPPLIER_NUMBER = " + tb_supplier_number.Text + "," +
                         "SUPPLIER_NAME = '" + tb_supplier_name.Text + "'," +
                         "ADDRESS = '" + tb_address.Text + "'," +
                         "TELNUMBER = " + tb_tel_no.Text + "," +
                         "FAXNUMBER = " + tb_fax_no.Text + " WHERE SUPPLIER_NUMBER = " +
                         dgv_masterlist.CurrentRow.Cells[0].Value.ToString());
            }
            else
            {
                DB.Query("INSERT INTO SUPPLIER VALUES (" +
                         tb_supplier_number.Text + ",'" + tb_supplier_name.Text + "','" +
                         tb_address.Text + "'," + tb_tel_no.Text + "," + tb_fax_no.Text + ")");
            }
        }
Exemple #4
0
        private void btn_register_Click(object sender, EventArgs e)
        {
            // Add Code For Input Constraint Implementation

            DB.Query("INSERT INTO STAFF VALUES("
                     + Convert.ToInt32(txtstaffnumber.Text) + ",'"
                     + txtfirstname.Text + "','"
                     + txtlastname.Text + "','"
                     + txtaddress.Text + "','"
                     + txttelnumber.Text + "','"
                     + dpbirthdate.Value.ToString("yyyy-MM-dd") + "','"
                     + cbsex.Text + "',"
                     + Convert.ToInt32(txtNIN.Text) +
                     ")");


            DB2ResultSet max_posID = DB.QueryWithResultSet("SELECT MAX(POSITIONHELD_ID) as MAXID FROM POSITIONHELD");
            int          posid     = 0;

            while (max_posID.Read())
            {
                try
                {
                    posid = Convert.ToInt32(max_posID["MAXID"]) + 1;
                }
                catch (Exception er)
                {
                    posid = 1;
                }
            }

            DB.Query("INSERT INTO POSITIONHELD VALUES("
                     + posid + ","
                     + Convert.ToInt32(txtstaffnumber.Text) + ","
                     + (cbPosition.SelectedIndex + 1) + ","
                     + (cbworkshift.SelectedIndex + 1) + ","
                     + (cbSalaryPaymnetType.SelectedIndex + 1) + ",'"
                     + dtpWorkStartDate.Value.ToString("yyyy-MM-dd") + "',"
                     + (cbEmploymentType.SelectedIndex + 1) +
                     ")");

            // positionheld table insert

            int qID  = 0;
            int weID = 0;

            if (dgvQualifications.Rows.Count >= 1)
            {
                foreach (DataGridViewRow row in dgvQualifications.Rows)
                {
                    DB2ResultSet rsqualID = DB.QueryWithResultSet("SELECT MAX(QUALIFICATION_ID) as QUALMAX FROM QUALIFICATION");

                    while (rsqualID.Read())
                    {
                        try
                        {
                            qID = Convert.ToInt32(rsqualID["QUALMAX"]) + 1;
                        }
                        catch (Exception er)
                        {
                            qID = 1;
                        }
                    }
                    DB.Query("INSERT INTO QUALIFICATION VALUES(" + qID + "," + Convert.ToInt32(txtstaffnumber.Text) + ",'" + row.Cells[0].Value.ToString() + "')");
                }
            }

            if (dgvWorkExperience.Rows.Count >= 1)
            {
                foreach (DataGridViewRow row2 in dgvWorkExperience.Rows)
                {
                    DB2ResultSet rsweID = DB.QueryWithResultSet("SELECT MAX(WORKEXPERIENCE_ID) as WEMAX FROM WORKEXPERIENCE");

                    while (rsweID.Read())
                    {
                        try
                        {
                            weID = Convert.ToInt32(rsweID["WEMAX"]) + 1;
                        }
                        catch (Exception er)
                        {
                            weID = 1;
                        }
                    }
                    DB.Query("INSERT INTO WORKEXPERIENCE VALUES(" + weID + "," + Convert.ToInt32(txtstaffnumber.Text) + ",'" + row2.Cells[0].Value.ToString() + "', '" + row2.Cells[1].Value.ToString() + "', '" + row2.Cells[2].Value.ToString() + "', '" + row2.Cells[3].Value.ToString() + "')");
                }
            }


            dgvQualifications.Rows.Clear();
            dgvWorkExperience.Rows.Clear();
            emptyAllInputFields();

            DB2ResultSet max_staffID = DB.QueryWithResultSet("SELECT MAX(STAFF_NUMBER) as MAXID FROM STAFF");

            while (max_staffID.Read())
            {
                try
                {
                    txtstaffnumber.Text = (Convert.ToInt32(max_staffID["MAXID"]) + 1).ToString();
                }
                catch (Exception er)
                {
                    txtstaffnumber.Text = "10001";
                }
            }
        }