private void button1_Click(object sender, EventArgs e) { DateTime date = Convert.ToDateTime(dateTimePicker1.Value.ToString("yyyy-MM-dd HH:mm:ss")); int amount = int.Parse(numericUpDown1.Value.ToString()); string account = textBox1.Text; SqlConnection conn = SQLConnection.connect(); conn.Open(); string creditString = "INSERT INTO credits (client_id, date_of_issue, fully_repaid, credit_type_id, mother_amount, account) OUTPUT INSERTED.ID VALUES ('" + customer_id + "', '" + date + "', '" + 0 + "', '" + credit_type_id + "', '" + amount + "', '" + account + "')"; SqlCommand command = new SqlCommand(creditString, conn); int credit_id = (Int32)command.ExecuteScalar(); using (SqlCommand cmd = new SqlCommand("CalculateDay", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@credit_id", SqlDbType.Int).Value = credit_id; cmd.Parameters.Add("@credit_type_id", SqlDbType.Int).Value = credit_type_id; cmd.Parameters.Add("@credit_amount", SqlDbType.BigInt).Value = amount; cmd.Parameters.Add("@interest_rate", SqlDbType.Float).Value = interest_rate; cmd.ExecuteNonQuery(); this.Hide(); MessageBox.Show("This credit is successfully added."); Employee_Page employee = new Employee_Page(GlobalVariables.EmployeeId, GlobalVariables.EmployeeFirstName, GlobalVariables.EmployeeLastName); employee.ShowDialog(); } }
private void button1_Click(object sender, EventArgs e) { this.Hide(); Employee_Page employee = new Employee_Page(GlobalVariables.EmployeeId, GlobalVariables.EmployeeFirstName, GlobalVariables.EmployeeLastName); employee.ShowDialog(); }
private void button1_Click(object sender, EventArgs e) { string login = textBox1.Text; string password = textBox2.Text; SqlConnection conn = SQLConnection.connect(); conn.Open(); string selectString = "Select id,firstname,lastname from employee where username='******' and pass='******'"; SqlCommand command = new SqlCommand(selectString, conn); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { GlobalVariables.EmployeeId = int.Parse(reader["id"].ToString()); GlobalVariables.EmployeeFirstName = reader["firstname"].ToString(); GlobalVariables.EmployeeLastName = reader["lastname"].ToString(); Employee_Page employee = new Employee_Page(GlobalVariables.EmployeeId, GlobalVariables.EmployeeFirstName, GlobalVariables.EmployeeLastName); this.Hide(); employee.ShowDialog(); } } conn.Close(); }
private void button1_Click(object sender, EventArgs e) { int sum = int.Parse(numericUpDown1.Value.ToString()); if (int.Parse(date.Day.ToString()) <= int.Parse(payment_day.Day.ToString())) { string repayment1String = "INSERT INTO repayment (credit_payment_day_id, credit_id, date_of_repayment, paid_mother_amounth, paid_interest_amounth, paid_prew_surcharge, surcharge_mother_amount, surcharge_interest_amount) VALUES ('" + command_credit_payment_day_id + "', '" + credit_id + "', '" + date + "', '" + 1 + "', '" + 1 + "', '" + 1 + "', '" + 0 + "', '" + 0 + "')"; SqlConnection conn = SQLConnection.connect(); conn.Open(); SqlCommand command1 = new SqlCommand(repayment1String, conn); command1.ExecuteNonQuery(); } else { float percentage_of_fines_for_each_day_mother_amount = 0; float percentage_of_fines_for_each_day_interest_amount = 0; //float mother_amount_surcharge = 0; //float interest_amount_surcharge = 0; int difference = int.Parse(date.Day.ToString()) - int.Parse(payment_day.Day.ToString()); SqlConnection conn = SQLConnection.connect(); conn.Open(); string credit_typeString = "Select percentage_of_fines_for_each_day_mother_amount, percentage_of_fines_for_each_day_interest_amount from types_of_crediting where id='" + credit_type_id + "'"; SqlCommand command_credit_type = new SqlCommand(credit_typeString, conn); using (SqlDataReader reader = command_credit_type.ExecuteReader()) { if (reader.Read()) { percentage_of_fines_for_each_day_mother_amount = float.Parse(reader["percentage_of_fines_for_each_day_mother_amount"].ToString()); percentage_of_fines_for_each_day_interest_amount = float.Parse(reader["percentage_of_fines_for_each_day_interest_amount"].ToString()); } } float monthly_mother_percent = (monthly_mother_amount * percentage_of_fines_for_each_day_mother_amount) / 100; float monthly_interest_percent = (monthly_interest_amount * percentage_of_fines_for_each_day_interest_amount) / 100; mother_amount_surcharge = monthly_mother_percent * (float)difference; interest_amount_surcharge = monthly_interest_percent * difference; string sql = "Insert into repayment (credit_payment_day_id, credit_id, date_of_repayment, paid_mother_amounth, paid_interest_amounth, paid_prew_surcharge, surcharge_mother_amount, surcharge_interest_amount) " + " values (@credit_payment_day_id, @credit_id, @date_of_repayment, @paid_mother_amounth, @paid_interest_amounth, @paid_prew_surcharge, @surcharge_mother_amount, @surcharge_interest_amount) "; SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = sql; cmd.Parameters.Add("@credit_payment_day_id", SqlDbType.Int).Value = command_credit_payment_day_id; cmd.Parameters.Add("@credit_id", SqlDbType.Int).Value = credit_id; cmd.Parameters.Add("@date_of_repayment", SqlDbType.DateTime).Value = date; cmd.Parameters.Add("@paid_mother_amounth", SqlDbType.Bit).Value = 1; cmd.Parameters.Add("@paid_interest_amounth", SqlDbType.Bit).Value = 1; cmd.Parameters.Add("@paid_prew_surcharge", SqlDbType.Bit).Value = 1; cmd.Parameters.Add("@surcharge_mother_amount", SqlDbType.Float).Value = mother_amount_surcharge; cmd.Parameters.Add("@surcharge_interest_amount", SqlDbType.Float).Value = interest_amount_surcharge; // Execute Command (for Delete,Insert or Update). cmd.ExecuteNonQuery(); } this.Hide(); MessageBox.Show("This credit is successfully paid."); Employee_Page employee = new Employee_Page(GlobalVariables.EmployeeId, GlobalVariables.EmployeeFirstName, GlobalVariables.EmployeeLastName); employee.ShowDialog(); }