コード例 #1
0
        public static bool addFinanceInsurance(FinanceInsurance fi)
        {
            DBConnector dbcon = new DBConnector();

            //try
            //{
            if (dbcon.openConnection())
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "INSERT INTO finance_insurance (type, value, begin_date, end_date, note, employee_idemployee) VALUES (N'" + fi.type + "', " + fi.value + ", '" + fi.getBegin_date().ToString("yyyy-MM-dd") + "', '" + fi.getEnd_date().ToString("yyyy-MM-dd") + "', N'" + fi.note + "', " + Employee.employee_id + ")";
                cmd.Connection = dbcon.connection;
                cmd.Prepare();
                cmd.ExecuteNonQuery();

                dbcon.closeConnection();
                return true;
            }
            else
            {
                dbcon.closeConnection();
                return false;
            }

            //}
            //catch (MySqlException e)
            //{
            //int errorcode = e.Number;
            //dbcon.closeConnection();
            //return false;
            //}
        }
コード例 #2
0
        public static FinanceInsurance getFinanceInsurance()
        {
            //try
            //{

            DBConnector dbcon = new DBConnector();

            if (dbcon.openConnection())
            {

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "SELECT * FROM finance_insurance WHERE employee_idemployee=" + Employee.employee_id;
                cmd.Connection = dbcon.connection;

                MySqlDataReader reader = cmd.ExecuteReader();

                FinanceInsurance fi = null;

                if (reader.Read())
                {
                    fi = new FinanceInsurance();

                    fi.fi_id = int.Parse(reader["idfinance_insurance"].ToString());
                    fi.type = reader["type"].ToString();
                    fi.value = double.Parse(reader["value"].ToString());
                    fi.note = reader["note"].ToString();

                    fi.setBegin_date(Convert.ToDateTime(reader["begin_date"]));
                    fi.setEnd_date(Convert.ToDateTime(reader["end_date"]));

                }

                reader.Close();

                dbcon.closeConnection();

                return fi;
            }
            else
            {

                return null;
            }

            //}
            //catch (MySqlException e)
            //{
            //int errorcode = e.Number;
            //return null;
            //}
        }
コード例 #3
0
        public void updateFinance()
        {
            //Update finance bank details
            FinanceBank fb = new FinanceBank();
            fb.fb_id = this.fb_id;
            fb.bank_name = this.bank_name.Text;
            fb.branch_name = this.bank_branch_name.Text;
            fb.account_number = this.bank_account_name.Text;
            fb.account_type = this.bank_account_type.Text;
            fb.setBegin_date(this.bank_account_started_year.Value.Date);
            fb.setEnd_date(this.bank_account_closed_year.Value.Date);
            fb.Qual_year = this.bank_qualified_year.Text;
            fb.qualification = this.bank_qualification.Text;
            bool state = FinanceBankHandler.updateFinanceBank(fb);
            Console.Write(state + "\n");

            //Update finance insurance details
            FinanceInsurance fi = new FinanceInsurance();
            fi.fi_id = this.fi_id;
            fi.type = this.insurance_type.Text;
            fi.value = Convert.ToDouble(this.insurance_value.Text);
            fi.setBegin_date(this.insurance_started_date.Value.Date);
            fi.setEnd_date(this.insurance_ended_year.Value.Date);
            fi.note = this.insurance_notes.Text;
            state = FinanceInsuranceHandler.updateFinanceInsurance(fi);
            Console.Write(state + "\n");

            //Update finance tax details
            FinanceTax ft = new FinanceTax();
            ft.ft_id = this.ft_id;
            ft.type = this.tax_type.Text;
            ft.number = this.tax_no.Text;
            ft.payment_method = this.tax_paying_method.Text;
            ft.status = this.tax_status.Text;
            ft.note = this.tax_notes.Text;
            state = FinanceTaxHandler.updateFinanceTax(ft);
            Console.Write(state + "\n");
        }
コード例 #4
0
        private void btnSave2_Click(object sender, EventArgs e)
        {
            FinanceInsurance fi = new FinanceInsurance();

            fi.type = insurance_type.Text;
            fi.value = Convert.ToDouble(insurance_value.Text);
            fi.setBegin_date(insurance_started_date.Value.Date);
            fi.setEnd_date(insurance_ended_date.Value.Date);
            fi.note = insurance_notes.Text;

            bool state = FinanceInsuranceHandler.addFinanceInsurance(fi);

            if (state)
            {
                MessageBox.Show("Employee insurance details added succesfully...!");

            }
            else
            {
                MessageBox.Show("Adding employee insurance details failed...!");
            }
        }
コード例 #5
0
        public static bool updateFinanceInsurance(FinanceInsurance fi)
        {
            //try
            //{

            DBConnector dbcon = new DBConnector();

            if (dbcon.openConnection())
            {

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "UPDATE finance_insurance SET type=N'" + fi.type + "', value=" + fi.value + ", begin_date='" + fi.getBegin_date().ToString("yyyy-MM-dd") + "', end_date='" + fi.getEnd_date().ToString("yyyy-MM-dd") + "', note=N'" + fi.note + "' WHERE employee_idemployee=" + Employee.employee_id + " AND idfinance_insurance=" + fi.fi_id;
                cmd.Connection = dbcon.connection;
                cmd.Prepare();
                cmd.ExecuteNonQuery();

                dbcon.closeConnection();

                return true;
            }
            else
            {

                return false;
            }

            //}
            //catch (MySqlException e)
            //{
            //int errorcode = e.Number;
            //return false;
            //}
        }