public bool setMemberAdvance(Advance advance) { return account_DAL.setMemberAdvance(advance); }
private void giveAdvance_button_Click(object sender, EventArgs e) { try { if (serachMembertextBox.Text != "" && signUpFirstNamemetroTextBox.Text != "") { if (advanceAmounttextBox.Text != "" && advanceCause_textBox.Text != "") { if (MessageBox.Show("Are you sure?", "Give Advance to Member", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { Advance advance = new Advance(); advance.date = advance_dateTimePicker.Text; advance.amount = advanceAmounttextBox.Text; advance.cause = advanceCause_textBox.Text; advance.userName = serachMembertextBox.Text; advance.reference = userName; if (account_Bo.setMemberAdvance(advance)) { MessageBox.Show("Advance given successfully done"); advanceAmounttextBox.Clear(); advanceCause_textBox.Clear(); } } } else { MessageBox.Show("Please enter the information fully"); } } else { MessageBox.Show("Please select a member first"); } } catch { MessageBox.Show("Error"); advanceAmounttextBox.Clear(); advanceCause_textBox.Clear(); } }
public bool setMemberAdvance(Advance advance) { try { SqlConnection conn = new SqlConnection(connString); SqlCommand cmd = new SqlCommand("SetAdvance", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Date", SqlDbType.NVarChar, 10).Value = advance.date; cmd.Parameters.Add("@UserName", SqlDbType.NVarChar, 100).Value = advance.userName; cmd.Parameters.Add("@Amount", SqlDbType.NVarChar, 20).Value = advance.amount; cmd.Parameters.Add("@Cause", SqlDbType.NVarChar, 500).Value = advance.cause; cmd.Parameters.Add("@Reference", SqlDbType.NVarChar, 100).Value = advance.reference; conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); return true; } catch (Exception) { return false; } }