public static bool addFinanceBank(FinanceBank fb)
        {
            DBConnector dbcon = new DBConnector();

            //try
            //{
            if (dbcon.openConnection())
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "INSERT INTO finance_bank (bank_name, branch_name, account_number, account_type, begin_date, end_date, qualification, qual_year, employee_idemployee) VALUES (N'" + fb.bank_name + "', N'" + fb.branch_name + "', N'" + fb.account_number + "', N'" + fb.account_type + "', '" + fb.getBegin_date().ToString("yyyy-MM-dd") + "', '" + fb.getEnd_date().ToString("yyyy-MM-dd") + "', N'" + fb.qualification + "', N'" + fb.Qual_year + "', " + 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;
            //}
        }
        public static FinanceBank getFinanceBank()
        {
            //try
            //{

            DBConnector dbcon = new DBConnector();

            if (dbcon.openConnection())
            {

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

                MySqlDataReader reader = cmd.ExecuteReader();

                FinanceBank fb = null;

                if (reader.Read())
                {
                    fb = new FinanceBank();
                    fb.fb_id = int.Parse(reader["idfinance_bank"].ToString());
                    fb.bank_name = reader["bank_name"].ToString();
                    fb.branch_name = reader["branch_name"].ToString();
                    fb.account_number = reader["account_number"].ToString();
                    fb.account_type = reader["account_type"].ToString();
                    fb.qualification = reader["qualification"].ToString();
                    fb.Qual_year = reader["qual_year"].ToString();

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

                }

                reader.Close();

                dbcon.closeConnection();

                return fb;
            }
            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");
        }
        public static bool updateFinanceBank(FinanceBank fb)
        {
            //try
            //{

            DBConnector dbcon = new DBConnector();

            if (dbcon.openConnection())
            {

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "UPDATE finance_bank SET bank_name=N'" + fb.bank_name + "', branch_name=N'" + fb.branch_name + "', account_number=N'" + fb.account_number + "', account_type=N'" + fb.account_type + "', begin_date='" + fb.getBegin_date().ToString("yyyy-MM-dd") + "', end_date='" + fb.getEnd_date().ToString("yyyy-MM-dd") + "', qualification=N'" + fb.qualification + "', qual_year=N'" + fb.Qual_year + "' WHERE employee_idemployee=" + Employee.employee_id + " AND idfinance_bank=" + fb.fb_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;
            //}
        }
        private void btnSave1_Click(object sender, EventArgs e)
        {
            FinanceBank fb = new FinanceBank();

            fb.bank_name = bank_name.Text;
            fb.branch_name = bank_branch_name.Text;
            fb.account_number = bank_account_number.Text;
            fb.account_type = bank_account_type.Text;
            fb.setBegin_date(bank_account_started_date.Value.Date);
            fb.setEnd_date(bank_account_closed_date.Value.Date);
            fb.Qual_year = bank_qualified_year.Text;
            fb.qualification = bank_qualification.Text;

            bool state = FinanceBankHandler.addFinanceBank(fb);

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

            }
            else
            {
                MessageBox.Show("Adding employee personal details failed...!");
            }
        }