Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool blnValid     = false;
            bool blnSuccess   = false;
            int  intMemberNum = 0;
            int  intLoanId    = 0;

            blnValid = ValidateInputs();

            if (blnValid)
            {
                string strXML = CreateInsertXML();
                try
                {
                    Member _obj         = new Member();
                    string strPaymentId = string.Empty;
                    byte[] bytes        = null;
                    if (!strPhotoName.Equals(string.Empty))
                    {
                        bytes = File.ReadAllBytes(fdPhoto.FileName);
                    }

                    blnSuccess = _obj.AddNewMember(strXML, out intMemberNum, bytes, out intLoanId, out strPaymentId);
                    if (blnSuccess)
                    {
                        ShowMesage("New member added successfully", "New member added", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MembershipForm _form = new MembershipForm(intMemberNum);
                        _form.ShowDialog();
                        if (intLoanId != 0)
                        {
                            LoanApplicationForm applicationForm = new LoanApplicationForm(intLoanId);
                            applicationForm.ShowDialog();
                        }
                        PaymentReceipt receipt = new PaymentReceipt(strPaymentId);
                        receipt.ShowDialog();
                        ClearAllControls();
                    }
                    else
                    {
                        MessageBox.Show("Transaction failed. Try again later", "Transaction failed", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Transaction failed. Try again later", "Transaction failed", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    LogError.LogEvent("Create New Member", ex.Message, "Save Button Click Event");
                }
            }
        }
 private void dgvMember_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Space)
     {
         int          intMemberId  = Convert.ToInt32(dgvMember.Rows[dgvMember.CurrentCell.RowIndex].Cells["MEMBER_ID"].Value.ToString());
         UpdateMember updateMember = new UpdateMember(intMemberId);
         updateMember.ShowDialog();
         LoadMemberList();
     }
     else if (e.KeyCode == Keys.Escape)
     {
         this.Close();
     }
     else if (e.KeyCode == Keys.F1)
     {
         int            intMemberId  = Convert.ToInt32(dgvMember.Rows[dgvMember.CurrentCell.RowIndex].Cells["MEMBER_ID"].Value.ToString());
         MembershipForm updateMember = new MembershipForm(intMemberId);
         updateMember.ShowDialog();
     }
 }