Skip to main content

Fino Bank Asp.net C# Desktop Application

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

 
namespace FinoBank_Application
{
    public partial class frmSplash : Form
    {
        public frmSplash()
        {
            InitializeComponent();
        }
 
        private void frmSplash_Load(object sender, EventArgs e)
        {
            timer1.Start();
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
 
            progressBar1.Minimum = 0;
            progressBar1.Maximum = 100;
            progressBar1.Value = progressBar1.Value + 1;
 
            //this.progressBar1.Increment(1);
 
            if (progressBar1.Value <= 0)
            {
                lblProgress.Text = "Initializing components...............";
            }
            else if (progressBar1.Value <= 10)
            {
                lblProgress.Text = "Loading fonts & Modules...............";
            }
            else if (progressBar1.Value <= 20)
            {
                lblProgress.Text = "Appliying themes and graphics...............";
            }
            else if (progressBar1.Value <= 30)
            {
                lblProgress.Text = "Collecting Information...............";
            }
            else if (progressBar1.Value <= 40)
            {
                lblProgress.Text = "Updating registry...............";
            }
            else if (progressBar1.Value <= 50)
            {
                lblProgress.Text = "Loading icons & Settings...............";
            }
            else if (progressBar1.Value <= 80)
            {
                lblProgress.Text = "Finalizing...............";
            }
            else if (progressBar1.Value <= 90)
            {
                lblProgress.Text = "Almost finished...............";
            }
            else if (progressBar1.Value >= 100)
            {
                timer1.Stop();
                this.Hide();
                frmLogin FrmLogin = new frmLogin();
                FrmLogin.Show();
            }
            else
            {
 
 
            }
 
 
 
 
            /*
            this.progressBar1.Increment(2);
            if (progressBar1.Value >= progressBar1.Maximum)
            {
                //lblProgress.Text = progressBar1.Value.ToString() + "%";
 
                timer1.Stop();
                this.Hide();
                frmLogin FrmLogin = new frmLogin();
                FrmLogin.Show();
                //frmMainWindow FrmMainwindow = new frmMainWindow();
                //FrmMainwindow.Show();
            }
            */
 
 
            //if (progressBar1.Value < 100)
            //{
            //    progressBar1.Value += 2;
            //}
            //else
            //{
            //    timer1.Stop();
            //    frmSplash FrmSplash = new frmSplash();
            //    FrmSplash.Hide();
            //    frmMainWindow FrmMainWindow = new frmMainWindow();
            //    FrmMainWindow.Show();
            //}
 
        }
    }
}

 

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
 
 
namespace FinoBank_Application
{
    public partial class frmLogin : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmLogin()
        {
            InitializeComponent();
 
        }
 
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            DialogResult d = MessageBox.Show("Do you want to close Application? ""Exit?"MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (d == DialogResult.Yes)
            {
                Application.Exit();
            }
            if (d == DialogResult.No)
            {
 
            }
        }
 
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtUserName.Text == "" || txtPassword.Text == "")
                {
                    MessageBox.Show("Username and password can't be blank""information"MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    SqlConnection conn = new SqlConnection(CS);
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("select * from Users where username=@user AND password=@pass", conn);
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@user", txtUserName.Text.Trim());
                    cmd.Parameters.AddWithValue("@pass", txtPassword.Text.Trim());
                    cmd.ExecuteNonQuery();
                    DataTable dt = new DataTable();
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    da.Fill(dt);
                    if (dt.Rows.Count > 0)
                    {
                        MessageBox.Show("Login Successfull!""information"MessageBoxButtons.OK);
                        this.Close();
                        frmMainWindow FrmMainwindow = new frmMainWindow();
                        FrmMainwindow.Show();
 
                    }
                    else
                    {
                        MessageBox.Show("Invalid credentials please try again! ""Information!"MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        // txtUserName.Focus();
                    }
                }
            }
 
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
 
            }
        }
 
        private void btnhide_Click(object sender, EventArgs e)
        {
            btnhide.Visible = false;
            btnshow.Visible = true;
            txtPassword.PasswordChar = '*';
        }
 
        private void btnshow_Click(object sender, EventArgs e)
        {
            btnshow.Visible = false;
            btnhide.Visible = true;
            txtPassword.PasswordChar = '\0';
        }
 
        private void TextBox_Leave(object sender, EventArgs e)
        {
            SqlDataReader dr;
            SqlConnection conn = new SqlConnection(CS);
            conn.Open();
            SqlCommand cmd = new SqlCommand();
            TextBox tb = (TextBox)sender;
            if (tb.Text.Trim() == String.Empty)
            {
                errorProvider1.SetError(tb, "Please Enter Value ....");
            }
            else
            {
                errorProvider1.Clear();
                cmd = new SqlCommand("select type from Users where username='" + txtUserName.Text + "'", conn);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    txtDesignation.Text = dr[0].ToString();
                    //utype = dr[0].ToString();
                }
                dr.Close();
            }
        }
 
        //private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        //{
        //    frmResetPassword FrmResetPassword = new frmResetPassword();
        //    FrmResetPassword.ShowDialog();
        //}
 
        private void frmLogin_Load(object sender, EventArgs e)
        {
            //txtUserName.Clear();
            //txtDesignation.Clear();
            //txtPassword.Clear();
            //btnhide.Dispose();
            //btnshow.Dispose();
        }
 
        private void btnshow_Click_1(object sender, EventArgs e)
        {
 
        }
 
        private void linkLabel1_LinkClicked(object sender, EventArgs e)
        {
            frmResetPassword FrmResetPassword = new frmResetPassword();
            FrmResetPassword.ShowDialog();
        }
 
        private void frmLogin_Load_1(object sender, EventArgs e)
        {
            txtUserName.Focus();
        }
    }
}

 

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using System.Data.SqlClient;

using System.Configuration;

 

namespace FinoBank_Application

{

    public partial class frmMainWindow : Form

    {

        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;

 

        SqlConnection conn;

        SqlCommand cmd;

        SqlDataReader dr;

 

        public frmMainWindow()

        {

            InitializeComponent();

        }

 

        private void exitToolStripMenuItem1_Click(object sender, EventArgs e)

        {

            DialogResult d = MessageBox.Show("Do you want to close Application? ""Exit?"MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (d == DialogResult.Yes)

            {

                Application.Exit();

            }

            if (d == DialogResult.No)

            {

 

            }

        }

 

        private void toolBarToolStripMenuItem_Click(object sender, EventArgs e)

        {

            toolStrip1.Visible = toolBarToolStripMenuItem.Checked;

        }

 

        private void statusBarToolStripMenuItem_Click(object sender, EventArgs e)

        {

            statusStrip1.Visible = statusBarToolStripMenuItem.Checked;

        }

 

        private void aboutUsToolStripMenuItem_Click(object sender, EventArgs e)

        {

            

            frmAboutUs FrmAboutUs = new frmAboutUs();

            FrmAboutUs.Show();

           // toolStripProgressBar1.Value = toolStripProgressBar1.Value + 10;

 

        }

 

        private void frmMainWindow_Load(object sender, EventArgs e)

        {

            Reminder.Enabled = true;

            Reminder.Start();

 

            lblDate.Text = DateTime.Now.ToString("dd/MM/yyyy");

            //lblTime.Text = DateTime.Now.ToString("hh:mm:ss");

 

            conn = new SqlConnection(CS);

            conn.Open();

            cmd = new SqlCommand("select * from tempuser", conn);

            cmd.CommandType = CommandType.Text;

            dr = cmd.ExecuteReader();

            while (dr.Read())

            {

                tlpUser.Text = dr[0].ToString();

                tlptype.Text = dr[1].ToString();

            }

            dr.Close();

 

 

            if (tlptype.Text == "Manager")

            {

                reportsToolStripMenuItem.Enabled = true;

                moneyDepositToolStripMenuItem.Enabled = true;

                calculatorToolStripMenuItem.Enabled = true;

                passbookStatusToolStripMenuItem.Enabled = true;

                moneyWithdrawToolStripMenuItem.Enabled = true;

                moneyTransferToolStripMenuItem.Enabled = true;

                newSavingsAccountToolStripMenuItem.Enabled = true;

 

                //Loanstrip as printpreview by mistake

                printPreviewToolStripMenuItem.Enabled = true;

                customerListToolStripMenuItem.Enabled = true;

                editCustomerDetailsToolStripMenuItem.Enabled = true;

                newCurrentAccountToolStripMenuItem.Enabled = true;

                balanceStatusToolStripMenuItem.Enabled = true;

                printToolStripMenuItem.Enabled = true;

            }

            else if (tlptype.Text == "Admin")

            {

                reportsToolStripMenuItem.Enabled = true;

                moneyDepositToolStripMenuItem.Enabled = true;

                calculatorToolStripMenuItem.Enabled = true;

                passbookStatusToolStripMenuItem.Enabled = true;

                moneyWithdrawToolStripMenuItem.Enabled = true;

                moneyTransferToolStripMenuItem.Enabled = true;

                newSavingsAccountToolStripMenuItem.Enabled = true;

 

                //Loanstrip as printpreview by mistake

                printPreviewToolStripMenuItem.Enabled = true;

                customerListToolStripMenuItem.Enabled = true;

                editCustomerDetailsToolStripMenuItem.Enabled = true;

                newCurrentAccountToolStripMenuItem.Enabled = true;

                balanceStatusToolStripMenuItem.Enabled = true;

                printToolStripMenuItem.Enabled = true;

 

            }

            else

            {

                moneyDepositToolStripMenuItem.Enabled = true;

                calculatorToolStripMenuItem.Enabled = true;

                passbookStatusToolStripMenuItem.Enabled = true;

                moneyWithdrawToolStripMenuItem.Enabled = true;

                moneyTransferToolStripMenuItem.Enabled = true;

                printPreviewToolStripMenuItem.Enabled = true;

                customerListToolStripMenuItem.Enabled = true;

                balanceStatusToolStripMenuItem.Enabled = true;

                printToolStripMenuItem.Enabled = true;

            }

 

 

            cmd = new SqlCommand("select Sum(balance) from BankBalance", conn);

            string b = cmd.ExecuteScalar().ToString();

            if (b != string.Empty)

            {

                tlpBalance.Text = b;

            }

            else

            {

                tlpBalance.Text = "0";

            }

 

 

 

        }

 

 

       // bool iscoll, islogin;

 

        private void toolStripButton22_Click(object sender, EventArgs e)

        {

            DialogResult d = MessageBox.Show("Do you want to Logout? ""Logoff?"MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (d == DialogResult.Yes)

            {

                this.Close();

                frmLogin Frmlogin = new frmLogin();

                Frmlogin.Show();

            }

            if (d == DialogResult.No)

            {

 

            }

        }

 

        private void logOutToolStripMenuItem_Click(object sender, EventArgs e)

        {

            DialogResult d = MessageBox.Show("Do you want to Logout? ""Logoff?"MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (d == DialogResult.Yes)

            {

                this.Close();

                frmLogin Frmlogin = new frmLogin();

                Frmlogin.Show();

            }

            if (d == DialogResult.No)

            {

 

            }

        }

 

        private void toolStripMenuItem1_Click(object sender, EventArgs e)

        {

 

        }

 

        private void notepadToolStripMenuItem_Click(object sender, EventArgs e)

        {

            System.Diagnostics.Process.Start("notepad.exe");

        }

 

        private void calculatorToolStripMenuItem_Click(object sender, EventArgs e)

        {

            System.Diagnostics.Process.Start("calc.exe");

        }

 

        private void systemInformationToolStripMenuItem_Click(object sender, EventArgs e)

        {

            System.Diagnostics.Process.Start("C:\\Windows\\System32\\msinfo32.exe");

        }

 

        private void taskManagerToolStripMenuItem_Click(object sender, EventArgs e)

        {

            System.Diagnostics.Process.Start("taskmgr.exe");

        }

 

        private void toolStripProgressBar1_Click(object sender, EventArgs e)

        {

 

        }

 

        private void newCurrentAccountToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmCurrentAccount FrmCurrentAccount = new frmCurrentAccount();

            FrmCurrentAccount.ShowDialog();

 

        }

 

        private void toolStripButton1_Click(object sender, EventArgs e)

        {

            frmCurrentAccount FrmCurrentAccount = new frmCurrentAccount();

            FrmCurrentAccount.ShowDialog();

        }

 

        private void newSavingsAccountToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmSavingsAccount FrmSavingsAccount = new frmSavingsAccount();

            FrmSavingsAccount.ShowDialog();

        }

 

        private void toolStripButton2_Click(object sender, EventArgs e)

        {

            frmSavingsAccount FrmSavingsAccount = new frmSavingsAccount();

            FrmSavingsAccount.ShowDialog();

        }

 

        private void toolStripButton3_Click(object sender, EventArgs e)

        {

            frmDematAccount FrmDematAccount = new frmDematAccount();

            FrmDematAccount.ShowDialog();

        }

 

        private void newDematAccountToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmDematAccount FrmDematAccount = new frmDematAccount();

            FrmDematAccount.ShowDialog();

        }

 

        private void editCustomerDetailsToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmEditCustomerDetails FrmEditCustomerDetails = new frmEditCustomerDetails();

            FrmEditCustomerDetails.ShowDialog();

        }

 

        private void toolStripButton4_Click(object sender, EventArgs e)

        {

            frmEditCustomerDetails FrmEditCustomerDetails = new frmEditCustomerDetails();

            FrmEditCustomerDetails.ShowDialog();

        }

 

        private void toolStripButton5_Click(object sender, EventArgs e)

        {

            frmCustomerList FrmCustomerList = new frmCustomerList();

            FrmCustomerList.ShowDialog();

        }

 

        private void customerListToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmCustomerList FrmCustomerList = new frmCustomerList();

            FrmCustomerList.ShowDialog();

        }

 

        private void toolStripButton23_Click(object sender, EventArgs e)

        {

            DialogResult d = MessageBox.Show("Do you want to close Application? ""Exit?"MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (d == DialogResult.Yes)

            {

                Application.Exit();

            }

            if (d == DialogResult.No)

            {

 

            }

        }

 

        private void moneyDepositToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmDeposit FrmDeposit = new frmDeposit();

            FrmDeposit.ShowDialog();

        }

 

        private void toolStripButton6_Click(object sender, EventArgs e)

        {

            frmDeposit FrmDeposit = new frmDeposit();

            FrmDeposit.ShowDialog();

        }

 

        private void toolStripButton7_Click(object sender, EventArgs e)

        {

            frmWithdrawal FrmWithdrawal = new frmWithdrawal();

            FrmWithdrawal.ShowDialog();

        }

 

        private void moneyWithdrawToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmWithdrawal FrmWithdrawal = new frmWithdrawal();

            FrmWithdrawal.ShowDialog();

        }

 

        private void toolStripButton8_Click(object sender, EventArgs e)

        {

            frmTransferMoney FrmTransferMoney = new frmTransferMoney();

            FrmTransferMoney.ShowDialog();

        }

 

        private void moneyTransferToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmTransferMoney FrmTransferMoney = new frmTransferMoney();

            FrmTransferMoney.ShowDialog();

        }

 

        private void toolStripButton10_Click(object sender, EventArgs e)

        {

            frmCheckBalance FrmCheckBalance = new frmCheckBalance();

            FrmCheckBalance.ShowDialog();

        }

 

        private void balanceEnquiryToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmCheckBalance FrmCheckBalance = new frmCheckBalance();

            FrmCheckBalance.ShowDialog();

        }

 

        private void toolStripButton19_Click(object sender, EventArgs e)

        {

            frmSetReminder FrmSetReminder = new frmSetReminder();

            FrmSetReminder.ShowDialog();

        }

 

        private void remindersToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmSetReminder FrmSetReminder = new frmSetReminder();

            FrmSetReminder.ShowDialog();

        }

 

        private void Reminder_Tick(object sender, EventArgs e)

        {

            bool rem = false;

            string msg = "", title = "", user = "";

            lblTime.Text = DateTime.Now.ToString("hh:mm:ss");

 

            conn = new SqlConnection(CS);

            conn.Open();

            cmd = new SqlCommand("select * from reminder where time='" + lblTime.Text + "' AND date='" + lblDate.Text + "'", conn);

            dr = cmd.ExecuteReader();

            while (dr.Read())

            {

                rem = true;

                msg = dr[2].ToString();

                user = dr[3].ToString();

                title = dr[4].ToString();

            }

 

            dr.Close();

            if (rem)

            {

                frmReminder r = new frmReminder();

                r.lblTitle.Text = title;

                r.lblTitle.Focus();

                r.txtMsg.Text = msg;

                r.Show();

                rem = false;

                r.ShowInTaskbar = false;

            }

 

        }

 

        private void toolStripButton18_Click(object sender, EventArgs e)

        {

            frmAllReminder FrmAllReminder = new frmAllReminder();

            FrmAllReminder.ShowDialog();

        }

 

        private void editReminderToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmAllReminder FrmAllReminder = new frmAllReminder();

            FrmAllReminder.ShowDialog();

        }

 

        private void toolStripButton16_Click(object sender, EventArgs e)

        {

            frmCreateUser FrmCreateUser = new frmCreateUser();

            FrmCreateUser.ShowDialog();

        }

 

        private void exportDataToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmCreateUser FrmCreateUser = new frmCreateUser();

            FrmCreateUser.ShowDialog();

        }

 

        private void toolStripButton13_Click(object sender, EventArgs e)

        {

            frmEditUser FrmEditUser = new frmEditUser();

            FrmEditUser.ShowDialog();

        }

 

        private void editUserToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmEditUser FrmEditUser = new frmEditUser();

            FrmEditUser.ShowDialog();

        }

 

        private void passbookStatusToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmPassbook FrmPassbook = new frmPassbook();

            FrmPassbook.ShowDialog();

        }

 

        private void toolStripButton14_Click(object sender, EventArgs e)

        {

            frmPassbook FrmPassbook = new frmPassbook();

            FrmPassbook.ShowDialog();

 

        }

 

        private void newFixedDepositToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmNewFDAccount FrmNewFDAccount = new frmNewFDAccount();

            FrmNewFDAccount.ShowDialog();

        }

 

        private void allFixedDepositAccountsToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmAllFDAccounts FrmAllFDAccounts = new frmAllFDAccounts();

            FrmAllFDAccounts.ShowDialog();

        }

 

        private void closeFDAccountToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmCloseFDAccount FrmCloseFDAccount = new frmCloseFDAccount();

            FrmCloseFDAccount.ShowDialog();

        }

 

        private void fDInterestRatesToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmFDInterestRates FrmFDInterestRates = new frmFDInterestRates();

            FrmFDInterestRates.ShowDialog();

        }

 

        private void newLoanToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmNewLoan FrmNewLoan = new frmNewLoan();

            FrmNewLoan.ShowDialog();

        }

 

        private void allLoanAccountsToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmAllLoanAccounts FrmAllLoanAccounts = new frmAllLoanAccounts();

            FrmAllLoanAccounts.ShowDialog();

        }

 

        private void eMIPaymentToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmPayLoanEMI FrmPayLoanEMI = new frmPayLoanEMI();

            FrmPayLoanEMI.ShowDialog();

        }

 

        private void eMIDetailsToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmLoanAccountInfo FrmLoanAccountInfo = new frmLoanAccountInfo();

            FrmLoanAccountInfo.ShowDialog();

        }

 

        private void loanInterestRatesToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmLoanRates FrmLoanRates = new frmLoanRates();

            FrmLoanRates.ShowDialog();

        }

 

        private void transactionToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmTransactionReport FrmTransactionReport = new frmTransactionReport();

            FrmTransactionReport.ShowDialog();

        }

 

        private void customerListToolStripMenuItem1_Click(object sender, EventArgs e)

        {

            frmCustomerReports FrmCustomerReports = new frmCustomerReports();

            FrmCustomerReports.ShowDialog();

        }

 

        private void balanceStatusToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmPassbook FrmPassbook = new frmPassbook();

            FrmPassbook.ShowDialog();

        }

 

        private void loandAccountListToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmLoanReport FrmLoanReport = new frmLoanReport();

            FrmLoanReport.ShowDialog();

        }

 

        private void printLoanAccountCopyToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmLoanAccountCopy FrmLoanAccountCopy = new frmLoanAccountCopy();

            FrmLoanAccountCopy.ShowDialog();

        }

 

        private void printLoanEMIAccountCopyToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmLoanEMICopy FrmLoanEMICopy = new frmLoanEMICopy();

            FrmLoanEMICopy.ShowDialog();

 

        }

 

        private void newCustomerAccountCopyToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmCustomerCopy FrmCustomerCopy = new frmCustomerCopy();

            FrmCustomerCopy.ShowDialog();

        }

 

        private void fixedDepositsToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmFDReports FrmFDReports = new frmFDReports();

            FrmFDReports.ShowDialog();

        }

 

        private void changePasswordToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmChangePassword FrmChangePassword = new frmChangePassword();

            FrmChangePassword.ShowDialog();

        }

 

        private void editProfileToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmEditUser FrmEditUser = new frmEditUser();

            FrmEditUser.ShowDialog();

        }

 

        private void toolStripButton15_Click(object sender, EventArgs e)

        {

            frmReportsWindow FrmReportsWindow = new frmReportsWindow();

            FrmReportsWindow.ShowDialog();

        }

 

        private void passbookToolStripMenuItem_Click(object sender, EventArgs e)

        {

            frmPassbook FrmPassbook = new frmPassbook();

            FrmPassbook.ShowDialog();

        }

    }

}

 

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Configuration;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using System.Data.SqlClient;

using System.Text.RegularExpressions;

using System.IO;

using System.Net;

using System.Net.Mail;

 

 

 

 

namespace FinoBank_Application

{

    public partial class frmCurrentAccount : Form

    {

 

        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;

 

        public frmCurrentAccount()

        {

            InitializeComponent();

        }

 

 

        frmReportForm r = new frmReportForm();

       // string time;

        int img1 = 1, img2 = 1, sign1 = 1, sign2 = 1;

 

        SqlConnection conn;

        SqlCommand cmd;

        SqlDataAdapter da;

        DataTable dt = new DataTable();

        bool single = false, joint = false;

         // bool email = true;

        string gender, gender1, marid1, marid, type, accno;

 

        private void frmCurrentAccount_Load(object sender, EventArgs e)

        {

            lblLoader.Visible = false;

            lblDate.Text = DateTime.Now.ToString("dd/MM/yyyy");

            btnFirstPerson.Enabled = false;

            cmbDistrict.SelectedIndex = 0;

            cmbNationality.SelectedIndex = 0;

            cmbQualification.SelectedIndex = 0;

            cmbState.SelectedIndex = 0;

            cmbDistrict1.SelectedIndex = 0;

            cmbNationality1.SelectedIndex = 0;

            cmbQualification1.SelectedIndex = 0;

            cmbState1.SelectedIndex = 0;

 

            autoId();

        }

 

 

        //bank baalnce

        private double BankBalance()

        {

            double bal = 0;

            conn = new SqlConnection(CS);

            conn.Open();

            cmd = new SqlCommand("select * from BankBalance", conn);

            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.Read())

            {

                bal = Convert.ToDouble(dr[0].ToString());

            }

            dr.Close();

            return bal;

        }

 

 

        private void button4_Click(object sender, EventArgs e)

        {

            this.Close();

        }

 

 

 

        private void rdoJoint_CheckedChanged(object sender, EventArgs e)

        {

            btnSecondPerson.Enabled = true;

            type = "joint";

            joint = true;

            single = false;

        }

 

        

 

        private void Mask_Enter(object sender, EventArgs e)

        {

            MaskedTextBox mt = (MaskedTextBox)sender;

            mt.BackColor = Color.Yellow;

 

 

            //MaskedTextBox mt = new MaskedTextBox();

            //mt.BackColor = Color.Yellow;

        }

 

        private void Mask_Leave(object sender, EventArgs e)

        {

            MaskedTextBox mt = (MaskedTextBox)sender;

            mt.BackColor = Color.White;

 

            //MaskedTextBox mt = new MaskedTextBox();

            //mt.BackColor = Color.White;

 

        }

 

        private void Combo_Enter(object sender, EventArgs e)

        {

            ComboBox cb = (ComboBox)sender;

            cb.BackColor = Color.Lime ;

        }

 

        private void Combo_Leave(object sender, EventArgs e)

        {

            ComboBox cb = (ComboBox)sender;

            cb.BackColor = Color.White;

        }

 

 

        //Select image of customer 1

        private void btnUploadImgae_Click(object sender, EventArgs e)

        {

            OpenFileDialog d = new OpenFileDialog();

            d.Title = "Select Image";

            d.Filter = " (*.jpg;*.png;*.jpeg) | *.jpg;*.png;*.jpeg";

 

            DialogResult dr = new DialogResult();

            dr = d.ShowDialog();

            if (dr == DialogResult.OK)

            {

                img1 = 0;

                pbImage.Image = new Bitmap(d.FileName);

            }

        }

 

        //Select sign of customer 1

        private void btnUploadSigns_Click(object sender, EventArgs e)

        {

            OpenFileDialog d = new OpenFileDialog();

            d.Title = "Select Image";

            d.Filter = " (*.jpg;*.png;*.jpeg) | *.jpg;*.png;*.jpeg";

 

            DialogResult dr = new DialogResult();

            dr = d.ShowDialog();

            if (dr == DialogResult.OK)

            {

                sign1 = 0;

                pbSignature.Image = new Bitmap(d.FileName);

 

            }

 

        }

 

        //Select image of customer 2

        private void btnUploadImgae1_Click(object sender, EventArgs e)

        {

            OpenFileDialog d = new OpenFileDialog();

            d.Title = "Select Image";

            d.Filter = " (*.jpg;*.png;*.jpeg) | *.jpg;*.png;*.jpeg";

 

            DialogResult dr = new DialogResult();

            dr = d.ShowDialog();

            if (dr == DialogResult.OK)

            {

                img2 = 0;

                pbImage1.Image = new Bitmap(d.FileName);

            }

        }

 

        //Select sign of customer 2

        private void btnUploadSigns1_Click(object sender, EventArgs e)

        {

            OpenFileDialog d = new OpenFileDialog();

            d.Title = "Select Image";

            d.Filter = " (*.jpg;*.png;*.jpeg) | *.jpg;*.png;*.jpeg";

 

            DialogResult dr = new DialogResult();

            dr = d.ShowDialog();

            if (dr == DialogResult.OK)

            {

                sign2 = 0;

                pbSignature1.Image = new Bitmap(d.FileName);

            }

        }

 

 

 

        //save image for first customer photo

        public byte[] savePhoto1(PictureBox pb)

        {

 

            MemoryStream ms = new MemoryStream();

            pbImage.Image.Save(ms, pb.Image.RawFormat);

            return ms.GetBuffer();

        }

        //save image for second customer photo

        public byte[] savePhoto2(PictureBox pb)

        {

 

            MemoryStream ms = new MemoryStream();

            pbImage1.Image.Save(ms, pb.Image.RawFormat);

            return ms.GetBuffer();

        }

 

        ////save image for first customer sign

        public byte[] saveSign1(PictureBox pb)

        {

 

            MemoryStream ms = new MemoryStream();

            pbSignature.Image.Save(ms, pb.Image.RawFormat);

            return ms.GetBuffer();

        }

        //save image for first customer sign

        public byte[] saveSign2(PictureBox pb)

        {

 

            MemoryStream ms = new MemoryStream();

            pbSignature1.Image.Save(ms, pb.Image.RawFormat);

            return ms.GetBuffer();

        }

 

        //Change back colour of textboxes when enter and leave them

        private void TextBox_Enter(object sender, EventArgs e)

        {

            TextBox tb = (TextBox)sender;

            tb.BackColor = Color.Lime;

        }

 

        private void TextBox_Leave(object sender, EventArgs e)

        {

            TextBox tb = (TextBox)sender;

            tb.BackColor = Color.White;

        }

 

 

        private void button2_Click(object sender, EventArgs e)

        {

            ClearData1();

            ClearData2();

        }

 

        private void btnSecondPerson_Click(object sender, EventArgs e)

        {

            panel1.Visible = true;

            //btnNevigation.Text = "<<---First person info";

            btnSecondPerson.Enabled = false;

            btnFirstPerson.Enabled = true;

        }

 

        private void btnFirstPerson_Click(object sender, EventArgs e)

        {

            panel1.Visible = false;

            //btnNevigation.Text = "<<---First person info";

            btnSecondPerson.Enabled = true;

            btnFirstPerson.Enabled = false;

        }

 

 

        //insert only String in Text Box

        private void TextField_KeyPress(object sender, KeyPressEventArgs e)

        {

                        

            if (e.KeyChar >= '0' && e.KeyChar <= '9')

            {

                e.Handled = true;

            }

            else

            {

                e.Handled = false;

            }

 

 

        }

 

        private void txtIncome1_KeyPress(object sender, KeyPressEventArgs e)

        {

 

        }

 

        //insert only Numbers in Text Box

        private void NumbericField_KeyPress(object sender, KeyPressEventArgs e)

        {

            

            if (e.KeyChar >= '0' && e.KeyChar <= '9' || e.KeyChar == 08)

            {

                e.Handled = false;

            }

            else

            {

                e.Handled = true;

            }

        }

 

 

        private void rdoSingle_CheckedChanged(object sender, EventArgs e)

        {

            //clearData2();

            type = "single";

            //clearData2();

            btnSecondPerson.Enabled = false;

            //btnshhowpanel.Visible = false;

            single = true;

            joint = false;

            panel1.Visible = false;

 

 

        }

        

 

        //automatic generate id (account numbers)

        double id;

 

 

 

        private void dateTimePicker2_ValueChanged(object sender, EventArgs e)

        {

            //print date in textbox

            if (checkAgeJoint() >= 10)

            {

                txtDateofBirth1.Text = dateTimePicker2.Value.ToString("dd/MM/yyyy");

            }

            else

            {

                MessageBox.Show("Age must be greater than 10 to create an account!""Information!"MessageBoxButtons.OK, MessageBoxIcon.Stop);

                //MessageBox.Show("");

            }

 

        }

 

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)

        {

            //print date in textbox

            if (checkAgeSingle() >= 10)

            {

                txtDateofBirth.Text = dateTimePicker1.Value.ToString("dd/MM/yyyy");

            }

            else

            {

                MessageBox.Show("Age must be greater than 10 to create an account!""Information!"MessageBoxButtons.OK, MessageBoxIcon.Stop);

                //MessageBox.Show("");

            }

 

 

        }

 

        private void btnSave_Click(object sender, EventArgs e)

        {

            if (single)

            {

                if (MsktxtAdharNumber.Text == string.Empty || txtAddress.Text == string.Empty || txtCity.Text == string.Empty || txtDateofBirth.Text == string.Empty || txtDiposit.Text == string.Empty || txtEmailID.Text == string.Empty || txtIncome.Text == string.Empty || txtFatherName.Text == string.Empty || txtCustomerName.Text == string.Empty || MsktxtMobileNumber.Text == string.Empty || txtMotherName.Text == string.Empty || txtPanNumber.Text == string.Empty || MsktxtPinCode.Text == string.Empty || txtReligion.Text == string.Empty || txtTaluka.Text == string.Empty || cmbDistrict.SelectedIndex == 0 || cmbNationality.SelectedIndex == 0 || cmbQualification.SelectedIndex == 0 || cmbState.SelectedIndex == 0)

                {

                    MessageBox.Show("All fields are mendetory please check again!""Error"MessageBoxButtons.OK, MessageBoxIcon.Error);

                }

                else

                {

                    if (emailValidation())

                    {

                        if (rdoMale.Checked == true || rdoFemale.Checked == true || rdoOther.Checked == true)

                        {

                            if (rdoMarried.Checked == true || rdoUnmarried.Checked == true || rdoDivorced.Checked == true || rdoAnnulated.Checked == true)

                            {

                                if (img1 == 1)

                                {

                                    MessageBox.Show("Upload Customer 1 Image ...""Warning"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                }

                                else

                                {

                                    if (sign1 == 1)

                                    {

                                        MessageBox.Show("Upload Customer 1 Signature..""Warning"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                    }

                                    else

                                    {

                                        if (MsktxtMobileNumber.MaskCompleted)

                                        {

                                            if (MsktxtPinCode.MaskCompleted)

                                            {

                                                if (MsktxtAdharNumber.MaskCompleted)

                                                {

                                                    if (txtPanNumber.Text.Length > 11)

                                                    {

                                                        conn = new SqlConnection(CS);

                                                        conn.Open();

 

                                                        //insert into bank balance

                                                        double bal = BankBalance();

                                                        double newbal = bal + Convert.ToDouble(txtDiposit.Text);

                                                        cmd = new SqlCommand("update BankBalance set balance =" + newbal + "", conn);

                                                        cmd.ExecuteNonQuery();

 

                                                        //insert into customer

                                                        cmd = new SqlCommand("insert into customer (accno,account,acctype,name_f,fname_f,mname_f,dob_f,gender_f,aadhar_f,pan_f,qualifi_f,nation_f,state_f,distic_f,taluka_f,city_f,pin_f,address,mobile_f,email_f,maritial_f,relgion_f,income_f,deposite_f,joindate_f,sign_f,photo_f,status) values(@no,@account,@type,@name,@fname,@mname,@dob,@gender,@aadhar,@pan,@quali,@nation,@state,@distic,@taluka,@city,@pin,@address,@mobile,@email,@maritial,@religion,@income,@deposite,@date,@sign,@photo,@status)", conn);

                                                        cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);

                                                        cmd.Parameters.AddWithValue("account""current");

                                                        cmd.Parameters.AddWithValue("type", type);

                                                        cmd.Parameters.AddWithValue("name", txtCustomerName.Text);

                                                        cmd.Parameters.AddWithValue("fname", txtFatherName.Text);

                                                        cmd.Parameters.AddWithValue("mname", txtMotherName.Text);

                                                        cmd.Parameters.AddWithValue("dob", txtDateofBirth.Text);

                                                        if (rdoMale.Checked)

                                                        {

                                                            cmd.Parameters.AddWithValue("gender""male");

                                                        }

                                                        else if (rdoFemale.Checked)

                                                        {

                                                            cmd.Parameters.AddWithValue("gender""female");

                                                        }

                                                        else

                                                        {

                                                            cmd.Parameters.AddWithValue("gender""other");

                                                        }

                                                        cmd.Parameters.AddWithValue("aadhar", MsktxtAdharNumber.Text);

                                                        cmd.Parameters.AddWithValue("pan", txtPanNumber.Text);

                                                        cmd.Parameters.AddWithValue("quali", cmbQualification.SelectedItem);

                                                        cmd.Parameters.AddWithValue("nation", cmbNationality.SelectedItem);

                                                        cmd.Parameters.AddWithValue("state", cmbState.SelectedItem);

                                                        cmd.Parameters.AddWithValue("distic", cmbDistrict.SelectedItem);

                                                        cmd.Parameters.AddWithValue("taluka", txtTaluka.Text);

                                                        cmd.Parameters.AddWithValue("city", txtCity.Text);

                                                        cmd.Parameters.AddWithValue("pin", MsktxtPinCode.Text);

                                                        cmd.Parameters.AddWithValue("address", txtAddress.Text);

                                                        cmd.Parameters.AddWithValue("mobile", MsktxtMobileNumber.Text);

                                                        cmd.Parameters.AddWithValue("email", txtEmailID.Text);

                                                        if (rdoMarried.Checked)

                                                        {

                                                            cmd.Parameters.AddWithValue("maritial""Maried");

                                                        }

                                                        else if (rdoUnmarried.Checked)

                                                        {

                                                            cmd.Parameters.AddWithValue("maritial""UnMaried");

                                                        }

                                                        else if (rdoDivorced.Checked)

                                                        {

                                                            cmd.Parameters.AddWithValue("maritial""Divorced");

                                                        }

                                                        else

                                                        {

                                                            cmd.Parameters.AddWithValue("maritial""Annulated");

                                                        }

 

                                                        cmd.Parameters.AddWithValue("religion", txtReligion.Text);

                                                        cmd.Parameters.AddWithValue("income", txtIncome.Text);

                                                        cmd.Parameters.AddWithValue("deposite", txtDiposit.Text);

                                                        cmd.Parameters.AddWithValue("date", lblDate.Text);

                                                        cmd.Parameters.AddWithValue("sign", saveSign1(pbSignature));

                                                        cmd.Parameters.AddWithValue("photo", savePhoto1(pbImage));

                                                        cmd.Parameters.AddWithValue("status"true);

                                                        cmd.ExecuteNonQuery();

 

                                                        //insert into passbook table

                                                        cmd = new SqlCommand("insert into passbook (accno,date,info,deposite,avlabl,time) values (@no,@date,@detail,@deposite,@avlabl,@time)", conn);

                                                        cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);

                                                        cmd.Parameters.AddWithValue("date", lblDate.Text);

                                                        cmd.Parameters.AddWithValue("detail""open Account");

                                                        cmd.Parameters.AddWithValue("deposite", txtDiposit.Text);

                                                        cmd.Parameters.AddWithValue("avlabl", txtDiposit.Text);

                                                        cmd.Parameters.AddWithValue("time"DateTime.Now.ToString("hh:mm:ss"));

                                                        cmd.ExecuteNonQuery();

 

                                                        //insert into balance

                                                        cmd = new SqlCommand("insert into balance values(@no,@type,@bal)", conn);

                                                        cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);

                                                        cmd.Parameters.AddWithValue("type""current");

                                                        cmd.Parameters.AddWithValue("bal"Convert.ToInt64(txtDiposit.Text));

                                                        cmd.ExecuteNonQuery();

 

                                                        //insert into Transaction

                                                        cmd = new SqlCommand("insert into trans_info values(@date,@time,@accno,@type,@ammount)", conn);

                                                        cmd.Parameters.AddWithValue("date", lblDate.Text);

                                                        cmd.Parameters.AddWithValue("time"DateTime.Now.ToString("hh:mm:ss"));

                                                        cmd.Parameters.AddWithValue("accno", txtAccountNumber.Text);

                                                        cmd.Parameters.AddWithValue("type""New Current Account");

                                                        cmd.Parameters.AddWithValue("ammount", txtDiposit.Text);

                                                        cmd.ExecuteNonQuery();

 

 

                                                        //send mail

                                                        try

                                                        {/*

 

                                                            gmail gmlsnd = new gmail();

                                                            gmlsnd.auth("sgbdhokadava@gmail.com", "yogesh@33@sgb");

                                                            gmlsnd.To = txtemail.Text;

                                                            gmlsnd.fromAlias = "Saurashtra Gramin Bank - Dhokadva";

                                                            gmlsnd.Subject = "Current Account Sucessfully Open";

                                                            gmlsnd.Message = "Dear " + txtfullname.Text + " Your Current Account in Saurashtra Gramin Bank Is Sucessfully Created . Your Account Number Is  " + txtacno.Text;

                                                            gmlsnd.Priority = 1;

                                                            gmlsnd.send();

                                                            */

 

                                                            /*

                                                            var fromAddress = new MailAddress("deedfile@gmail.com", "Gyan Sonwane");

                                                            var toAddress = new MailAddress("txtEmailID.text", "txtCustomerName.text");

                                                            const string fromPassword = "adobeflashcs4";

                                                            const string subject = "test";

                                                            const string body = "Account created";

 

                                                            var smtp = new SmtpClient

                                                            {

                                                                Host = "smtp.gmail.com",

                                                                Port = 587,

                                                                EnableSsl = true,

                                                                DeliveryMethod = SmtpDeliveryMethod.Network,

                                                                Credentials = new NetworkCredential(fromAddress.Address, fromPassword),

                                                                Timeout = 20000

                                                            };

                                                            using (var message = new MailMessage(fromAddress, toAddress)

                                                            {

                                                                Subject = subject,

                                                                Body = body

                                                            })

                                                            {

                                                                smtp.Send(message);

                                                            }

                                                            */

 

 

                                                        }

                                                        catch (Exception ex)

                                                        {

                                                            MessageBox.Show(ex.Message);

                                                            //   MessageBox.Show("Internet Connection Is Required ", "Not Internet", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                                        }

 

 

                                                        MessageBox.Show("Account created successfully! Please print the copy of receipt""Save"MessageBoxButtons.OK, MessageBoxIcon.Information);

 

                                                        lblLoader.Visible = true;

 

 

                                                        //print reports

                                                        r.crystalReportViewer1.ReportSource = null;

                                                        r.crystalReportViewer1.Refresh();

                                                        dt.Clear();

                                                        da = new SqlDataAdapter("select * from customer where accno='" + txtAccountNumber.Text + "'", conn);

                                                        da.Fill(dt);

                                                        Reports.crCustomer c = new Reports.crCustomer();

                                                        c.Database.Tables["customer"].SetDataSource(dt);

                                                        r.crystalReportViewer1.ReportSource = c;

                                                        r.crystalReportViewer1.Refresh();

                                                        r.ShowDialog();

                                                        autoId();

                                                        ClearData1();

 

                                                    }

                                                    else

                                                    {

                                                        MessageBox.Show("Pancard Number Is Not Valid ""Invalid Pan number"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                                    }

 

                                                }

                                                else

                                                {

                                                    MessageBox.Show("Aadhar Number Is Not Valid ""Invalid Aadhar"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                                }

                                            }

                                            else

                                            {

                                                MessageBox.Show("Pin Code Is Not Valid ""Invalid Pin"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                            }

                                        }

                                        else

                                        {

                                            MessageBox.Show("Mobile Number Is Not Valid ""Invalid Mobile"MessageBoxButtons.OK, MessageBoxIcon.Warning);

 

                                        }

 

                                    }

 

 

                                }

 

                            }

                            else

                            {

                                MessageBox.Show("Please Select Marital Status");

 

                            }

 

                        }

                        else

                        {

                            MessageBox.Show("Please Select Gender");

                        }

 

                    }

                    else

                    {

                        MessageBox.Show("InValid Email address ");

                    }

 

                }

 

 

            }

            else if (joint)

            {

                if (MsktxtAdharNumber1.Text == string.Empty || txtAddress1.Text == string.Empty || txtCity1.Text == string.Empty || txtDateofBirth1.Text == string.Empty || txtEmailID1.Text == string.Empty || txtIncome1.Text == string.Empty || txtFatherName1.Text == string.Empty || txtCustomerName1.Text == string.Empty || MsktxtMobileNumber1.Text == string.Empty || txtMotherName1.Text == string.Empty || txtPanNumber1.Text == string.Empty || MsktxtPinCode1.Text == string.Empty || txtReligion1.Text == string.Empty || txtTaluka1.Text == string.Empty || cmbDistrict1.SelectedIndex == 0 || cmbNationality1.SelectedIndex == 0 || cmbQualification1.SelectedIndex == 0 || cmbState1.SelectedIndex == 0)

                {

                    MessageBox.Show("All fields are mendetory please check again!""Error"MessageBoxButtons.OK, MessageBoxIcon.Error);

                }

                else

                {

                    if (emailValidation1())

                    {

                        if (rdoMale1.Checked == true || rdoFemale1.Checked == true || rdoOther1.Checked == true)

                        {

                            if (rdoMarried1.Checked == true || rdoUnmarried1.Checked == true || rdoDivorced1.Checked == true || rdoAnnulated1.Checked == true)

                            {

                                if (img1 == 1)

                                {

                                    MessageBox.Show("Upload Customer 1 Image ...""Warning"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                }

                                else

                                {

                                    if (sign1 == 1)

                                    {

                                        MessageBox.Show("Upload Customer 1 Signature..""Warning"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                    }

                                    else

                                    {

                                        if (img2 == 1)

                                        {

                                            MessageBox.Show("Upload Customer 2 Image""Upload Image"MessageBoxButtons.OK, MessageBoxIcon.Information);

                                        }

                                        else

                                        {

                                            if (sign2 == 1)

                                            {

                                                MessageBox.Show("Upload Customer 2 Signature""Upload Signature"MessageBoxButtons.OK, MessageBoxIcon.Information);

                                            }

                                            else

                                            {

                                                if (MsktxtMobileNumber1.MaskCompleted)

                                                {

                                                    if (MsktxtPinCode1.MaskCompleted)

                                                    {

                                                        if (MsktxtAdharNumber1.MaskCompleted)

                                                        {

                                                            if (txtPanNumber1.Text.Length > 11)

                                                            {

                                                                conn = new SqlConnection(CS);

                                                                conn.Open();

 

                                                                //insert into bank balance

                                                                double bal = BankBalance();

                                                                double newbal = bal + Convert.ToDouble(txtDiposit.Text);

                                                                cmd = new SqlCommand("update BankBalance set balance =" + newbal + "", conn);

                                                                cmd.ExecuteNonQuery();

 

                                                                //insert into customer

 

                                                                cmd = new SqlCommand("insert into customer values(@no,@account,@type,@name,@fname,@mname,@dob,@gender,@aadhar,@pan,@quali,@nation,@state,@distic,@taluka,@city,@pin,@address,@mobile,@email,@maritial,@religion,@income,@deposite,@date,@sign,@photo,@name1,@fname1,@mname1,@dob1,@gender1,@aadhar1,@pan1,@quali1,@nation1,@state1,@distic1,@taluka1,@city1,@pin1,@address1,@mobile1,@email1,@maritial1,@religion1,@income1 ,@sign1,@photo1,@status)", conn);

                                                                cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);

                                                                cmd.Parameters.AddWithValue("account""current");

                                                                cmd.Parameters.AddWithValue("type", type);

                                                                cmd.Parameters.AddWithValue("name", txtCustomerName.Text);

                                                                cmd.Parameters.AddWithValue("fname", txtFatherName.Text);

                                                                cmd.Parameters.AddWithValue("mname", txtMotherName.Text);

                                                                cmd.Parameters.AddWithValue("dob", txtDateofBirth.Text);

                                                                if (rdoMale.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("gender""male");

                                                                }

                                                                else if (rdoFemale.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("gender""female");

                                                                }

                                                                else

                                                                {

                                                                    cmd.Parameters.AddWithValue("gender""other");

                                                                }

                                                                cmd.Parameters.AddWithValue("aadhar", MsktxtAdharNumber.Text);

                                                                cmd.Parameters.AddWithValue("pan", txtPanNumber.Text);

                                                                cmd.Parameters.AddWithValue("quali", cmbQualification.SelectedItem);

                                                                cmd.Parameters.AddWithValue("nation", cmbNationality.SelectedItem);

                                                                cmd.Parameters.AddWithValue("state", cmbState.SelectedItem);

                                                                cmd.Parameters.AddWithValue("distic", cmbDistrict.SelectedItem);

                                                                cmd.Parameters.AddWithValue("taluka", txtTaluka.Text);

                                                                cmd.Parameters.AddWithValue("city", txtCity.Text);

                                                                cmd.Parameters.AddWithValue("pin", MsktxtPinCode.Text);

                                                                cmd.Parameters.AddWithValue("address", txtAddress.Text);

                                                                cmd.Parameters.AddWithValue("mobile", MsktxtMobileNumber.Text);

                                                                cmd.Parameters.AddWithValue("email", txtEmailID.Text);

                                                                if (rdoMarried.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("maritial""Maried");

                                                                }

                                                                else if (rdoUnmarried.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("maritial""UnMaried");

                                                                }

                                                                else if (rdoDivorced.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("maritial""Divorced");

                                                                }

                                                                else

                                                                {

                                                                    cmd.Parameters.AddWithValue("maritial""Annulated");

                                                                }

 

                                                                cmd.Parameters.AddWithValue("religion", txtReligion.Text);

                                                                cmd.Parameters.AddWithValue("income", txtIncome.Text);

                                                                cmd.Parameters.AddWithValue("deposite", txtDiposit.Text);

                                                                cmd.Parameters.AddWithValue("date", lblDate.Text);

                                                                cmd.Parameters.AddWithValue("sign", saveSign1(pbSignature));

                                                                cmd.Parameters.AddWithValue("photo", savePhoto1(pbImage));

                                                                cmd.Parameters.AddWithValue("status"true);

 

                                                                // Second customer details 

                                                                //cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);

                                                                //cmd.Parameters.AddWithValue("account", "current");

                                                                //cmd.Parameters.AddWithValue("type", type);

                                                                cmd.Parameters.AddWithValue("name1", txtCustomerName1.Text);

                                                                cmd.Parameters.AddWithValue("fname1", txtFatherName1.Text);

                                                                cmd.Parameters.AddWithValue("mname1", txtMotherName1.Text);

                                                                cmd.Parameters.AddWithValue("dob1", txtDateofBirth1.Text);

                                                                if (rdoMale.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("gender1""male");

                                                                }

                                                                else if (rdoFemale.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("gender1""female");

                                                                }

                                                                else

                                                                {

                                                                    cmd.Parameters.AddWithValue("gender1""other");

                                                                }

                                                                cmd.Parameters.AddWithValue("aadhar1", MsktxtAdharNumber1.Text);

                                                                cmd.Parameters.AddWithValue("pan1", txtPanNumber1.Text);

                                                                cmd.Parameters.AddWithValue("quali1", cmbQualification1.SelectedItem);

                                                                cmd.Parameters.AddWithValue("nation1", cmbNationality1.SelectedItem);

                                                                cmd.Parameters.AddWithValue("state1", cmbState1.SelectedItem);

                                                                cmd.Parameters.AddWithValue("distic1", cmbDistrict1.SelectedItem);

                                                                cmd.Parameters.AddWithValue("taluka1", txtTaluka1.Text);

                                                                cmd.Parameters.AddWithValue("city1", txtCity1.Text);

                                                                cmd.Parameters.AddWithValue("pin1", MsktxtPinCode1.Text);

                                                                cmd.Parameters.AddWithValue("address1", txtAddress1.Text);

                                                                cmd.Parameters.AddWithValue("mobile1", MsktxtMobileNumber1.Text);

                                                                cmd.Parameters.AddWithValue("email1", txtEmailID1.Text);

                                                                if (rdoMarried1.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("maritial1""Maried");

                                                                }

                                                                else if (rdoUnmarried1.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("maritial1""UnMaried");

                                                                }

                                                                else if (rdoDivorced1.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("maritial1""Divorced");

                                                                }

                                                                else

                                                                {

                                                                    cmd.Parameters.AddWithValue("maritial1""Annulated");

                                                                }

 

                                                                cmd.Parameters.AddWithValue("religion1", txtReligion1.Text);

                                                                cmd.Parameters.AddWithValue("income1", txtIncome1.Text);

                                                                //cmd.Parameters.AddWithValue("deposite", txtDiposit.Text);

                                                               // cmd.Parameters.AddWithValue("date", lblDate.Text);

                                                                cmd.Parameters.AddWithValue("sign1", saveSign2(pbSignature));

                                                                cmd.Parameters.AddWithValue("photo1", savePhoto2(pbImage));

                                                                //cmd.Parameters.AddWithValue("status", true);

                                                                cmd.ExecuteNonQuery();

 

 

                                                                //insert into passbook table

                                                                cmd = new SqlCommand("insert into passbook (accno,date,info,deposite,avlabl,time) values (@no,@date,@detail,@deposite,@avlabl,@time)", conn);

                                                                cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);

                                                                cmd.Parameters.AddWithValue("date", lblDate.Text);

                                                                cmd.Parameters.AddWithValue("detail""open Account");

                                                                cmd.Parameters.AddWithValue("deposite", txtDiposit.Text);

                                                                cmd.Parameters.AddWithValue("avlabl", txtDiposit.Text);

                                                                cmd.Parameters.AddWithValue("time"DateTime.Now.ToString("hh:mm:ss"));

                                                                cmd.ExecuteNonQuery();

 

                                                                //insert into balance

                                                                cmd = new SqlCommand("insert into balance values(@no,@type,@bal)", conn);

                                                                cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);

                                                                cmd.Parameters.AddWithValue("type""current");

                                                                cmd.Parameters.AddWithValue("bal"Convert.ToInt64(txtDiposit.Text));

                                                                cmd.ExecuteNonQuery();

 

                                                                //insert into Transaction

                                                                cmd = new SqlCommand("insert into trans_info values(@date,@time,@accno,@type,@ammount)", conn);

                                                                cmd.Parameters.AddWithValue("date", lblDate.Text);

                                                                cmd.Parameters.AddWithValue("time"DateTime.Now.ToString("hh:mm:ss"));

                                                                cmd.Parameters.AddWithValue("accno", txtAccountNumber.Text);

                                                                cmd.Parameters.AddWithValue("type""New Current Account");

                                                                cmd.Parameters.AddWithValue("ammount", txtDiposit.Text);

                                                                cmd.ExecuteNonQuery();

 

 

                                                                MessageBox.Show("Account created successfully! Please print the copy of receipt""Save"MessageBoxButtons.OK, MessageBoxIcon.Information);

 

                                                                lblLoader.Visible = true;

 

 

                                                                //print reports

                                                                r.crystalReportViewer1.ReportSource = null;

                                                                r.crystalReportViewer1.Refresh();

                                                                dt.Clear();

                                                                da = new SqlDataAdapter("select * from customer where accno='" + txtAccountNumber.Text + "'", conn);

                                                                da.Fill(dt);

                                                                Reports.crCustomer c = new Reports.crCustomer();

                                                                c.Database.Tables["customer"].SetDataSource(dt);

                                                                r.crystalReportViewer1.ReportSource = c;

                                                                r.crystalReportViewer1.Refresh();

                                                                r.ShowDialog();

                                                                autoId();

                                                                ClearData1();

                                                                ClearData2();

                                                            }

                                                            else

                                                            {

                                                                MessageBox.Show("Pancard Number Is Not Valid ""Invalid Pan number"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                                            }

                                                        }

                                                        else

                                                        {

                                                            MessageBox.Show("Aadhar Number Is Not Valid ""Invalid Aadhar"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                                        }

                                                    }

                                                    else

                                                    {

                                                        MessageBox.Show("Pin Code Is Not Valid ""Invalid Pin"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                                    }

                                                }

                                                else

                                                {

                                                    MessageBox.Show("Mobile Number Is Not Valid ""Invalid Mobile"MessageBoxButtons.OK, MessageBoxIcon.Warning);

 

                                                }

                                            }

 

                                        }

                                    }

                                }

                            }

                            else

                            {

                                MessageBox.Show("Please Select Marital Status");

                            }

                        }

                        else

                        {

                            MessageBox.Show("Please Select Gender");

                        }

                    }

                    else

                    {

                        MessageBox.Show("InValid Email address ");

                    }

                }

 

            }

            else

            {

                MessageBox.Show("Please Select Account Type First""Error"MessageBoxButtons.OK, MessageBoxIcon.Error);

            }

 

 

 

        }

 

        private void autoId()

        {

            conn = new SqlConnection(CS);

            conn.Open();

            cmd = new SqlCommand("select MAX(accno) from customer", conn);

            accno = cmd.ExecuteScalar().ToString();

            if (accno == "")

            {

                txtAccountNumber.Text = "30000000001";

            }

            else

            {

                id = Convert.ToInt64(accno);

                id = id + 1;

                txtAccountNumber.Text = id.ToString();

            }

        }

 

        //validations

        private bool emailValidation()

        {

            if (Regex.IsMatch(txtEmailID.Text, "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$"))

            {

                return true;

            }

            else

            {

                return false;

            }

        }

 

        private bool emailValidation1()

        {

            if (Regex.IsMatch(txtEmailID1.Text, "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$"))

            {

                return true;

            }

            else

            {

                return false;

            }

        }

 

        //check first account holder gender

        private string CheckGen1()

        {

            if (rdoMale.Checked)

            {

                gender = "male";

            }

            else if (rdoFemale.Checked)

            {

                gender = "female";

            }

            else

            {

                gender = "Other";

            }

            return gender;

        }

 

        //check Second account holder gender

        private string CheckGen2()

        {

            if (rdoMale1.Checked)

            {

                gender1 = "male";

            }

            else if (rdoFemale1.Checked)

            {

                gender1 = "female";

            }

            else

            {

                gender1 = "Other";

            }

            return gender1;

        }

 

 

        //check Maritial Status of Customer 1

        private string checkMar1()

        {

            if (rdoMarried.Checked)

            {

                marid = "maried";

            }

            else if(rdoUnmarried.Checked)

            {

                marid = "unmaried";

            }

            else if (rdoDivorced.Checked)

            {

                marid = "Divorced";

            }

            else

            {

                marid = "Annulated";

            }

            return marid;

        }

 

 

        //check Maritial Status of Customer 1

        private string checkMar2()

        {

            if (rdoMarried1.Checked)

            {

                marid1 = "maried";

            }

            else if (rdoUnmarried1.Checked)

            {

                marid1 = "unmaried";

            }

            else if (rdoDivorced1.Checked)

            {

                marid1 = "Divorced";

            }

            else

            {

                marid1 = "Annulated";

            }

            return marid1;

        }

 

        //check the age of customer

        public int checkAgeSingle()

        {

            int year = Convert.ToInt32(dateTimePicker1.Value.Year);

            int year1 = Convert.ToInt32(DateTime.Now.Year);

            int age = year1 - year;

            return age;

        }

        public int checkAgeJoint()

        {

            int year = Convert.ToInt32(dateTimePicker2.Value.Year);

            int year1 = Convert.ToInt32(DateTime.Now.Year);

            int age = year1 - year;

            return age;

        }

 

       /* private void NewCustomer_Load(object sender, EventArgs e)

        {

            //show date in label

            lbldate.Text = DateTime.Now.ToString("dd-MM-yyyy");

            time = DateTime.Now.ToString("hh:mm:ss");

            autoId();

            cbdis.SelectedIndex = 0;

            cbnation.SelectedIndex = 0;

            cbqualify.SelectedIndex = 0;

            cbstate.SelectedIndex = 0;

            cbstate1.SelectedIndex = 0;

            cbqualify1.SelectedIndex = 0;

            cbnatinality1.SelectedIndex = 0;

            cbdistic1.SelectedIndex = 0;

        }

        */

 

        protected void ClearData1()

        {

            rdoMale.Checked = false;

            rdoFemale.Checked = false;

            rdoOther.Checked = false;

            rdoMarried.Checked = false;

            rdoSingle.Checked = false;

            rdoJoint.Checked = false;

            rdoUnmarried.Checked = false;

            rdoAnnulated.Checked = false;

            rdoDivorced.Checked = false;

            cmbDistrict.SelectedIndex = 0;

            cmbNationality.SelectedIndex = 0;

            cmbQualification.SelectedIndex = 0;

            cmbState.SelectedIndex = 0;

            MsktxtAdharNumber.Clear();

            txtCity.Clear();

            txtCustomerName.Clear();

            txtDateofBirth.Clear();

            txtEmailID.Clear();

            txtFatherName.Clear();

            txtIncome.Clear();

            txtPanNumber.Clear();

            txtReligion.Clear();

            txtTaluka.Clear();

            txtMotherName.Clear();

            txtAddress.Clear();

            txtDiposit.Clear();

            MsktxtPinCode.Clear();

            MsktxtMobileNumber.Clear();

            pbImage.Image = null;

            pbSignature.Image = null;

        }

 

 

        protected void ClearData2()

        {

            rdoMale1.Checked = false;

            rdoFemale1.Checked = false;

            rdoOther1.Checked = false;

            rdoMarried1.Checked = false;

           // rdoSingle1.Checked = false;

            //rdoJoint1.Checked = false;

            rdoUnmarried1.Checked = false;

            rdoAnnulated1.Checked = false;

            rdoDivorced1.Checked = false;

            cmbDistrict1.SelectedIndex = 0;

            cmbNationality1.SelectedIndex = 0;

            cmbQualification1.SelectedIndex = 0;

            cmbState1.SelectedIndex = 0;

            MsktxtAdharNumber1.Clear();

            txtCity1.Clear();

            txtCustomerName1.Clear();

            txtDateofBirth1.Clear();

            txtEmailID1.Clear();

            txtFatherName1.Clear();

            txtIncome1.Clear();

            txtPanNumber1.Clear();

            txtReligion1.Clear();

            txtTaluka1.Clear();

            txtMotherName1.Clear();

            txtAddress1.Clear();

            MsktxtPinCode1.Clear();

            MsktxtMobileNumber1.Clear();

            // txtDiposit1.Clear();

            pbImage1.Image = null;

            pbSignature1.Image = null;

        }

     }

}

 

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Configuration;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using System.Data.SqlClient;

using System.Text.RegularExpressions;

using System.IO;

using System.Net;

using System.Net.Mail;

 

 

 

 

namespace FinoBank_Application

{

    public partial class frmSavingsAccount : Form

    {

 

        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;

 

        public frmSavingsAccount()

        {

            InitializeComponent();

        }

 

        frmReportForm r = new frmReportForm();

        // string time;

        int img1 = 1, img2 = 1, sign1 = 1, sign2 = 1;

 

        SqlConnection conn;

        SqlCommand cmd;

        SqlDataAdapter da;

        DataTable dt = new DataTable();

        bool single = false, joint = false;

        // bool email = true;

        string gender, gender1, marid1, marid, type, accno;

 

        private void frmSavingsAccount_Load(object sender, EventArgs e)

        {

            lblloader.Visible = false;

            lblDate.Text = DateTime.Now.ToString("dd/MM/yyyy");

            btnFirstPerson.Enabled = false;

            cmbDistrict.SelectedIndex = 0;

            cmbNationality.SelectedIndex = 0;

            cmbQualification.SelectedIndex = 0;

            cmbState.SelectedIndex = 0;

            cmbDistrict1.SelectedIndex = 0;

            cmbNationality1.SelectedIndex = 0;

            cmbQualification1.SelectedIndex = 0;

            cmbState1.SelectedIndex = 0;

 

            autoId();

        }

 

 

        //bank baalnce

        private double BankBalance()

        {

            double bal = 0;

            conn = new SqlConnection(CS);

            conn.Open();

            cmd = new SqlCommand("select * from BankBalance", conn);

            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.Read())

            {

                bal = Convert.ToDouble(dr[0].ToString());

            }

            dr.Close();

            return bal;

        }

 

 

        private void button4_Click(object sender, EventArgs e)

        {

            this.Close();

        }

 

 

 

        private void rdoJoint_CheckedChanged(object sender, EventArgs e)

        {

            btnSecondPerson.Enabled = true;

            type = "joint";

            joint = true;

            single = false;

        }

 

        

 

        private void Mask_Enter(object sender, EventArgs e)

        {

            MaskedTextBox mt = (MaskedTextBox)sender;

            mt.BackColor = Color.Yellow;

 

 

            //MaskedTextBox mt = new MaskedTextBox();

            //mt.BackColor = Color.Yellow;

        }

 

        private void Mask_Leave(object sender, EventArgs e)

        {

            MaskedTextBox mt = (MaskedTextBox)sender;

            mt.BackColor = Color.White;

 

            //MaskedTextBox mt = new MaskedTextBox();

            //mt.BackColor = Color.White;

 

        }

 

        private void Combo_Enter(object sender, EventArgs e)

        {

            ComboBox cb = (ComboBox)sender;

            cb.BackColor = Color.Lime ;

        }

 

        private void Combo_Leave(object sender, EventArgs e)

        {

            ComboBox cb = (ComboBox)sender;

            cb.BackColor = Color.White;

        }

 

 

        //Select image of customer 1

        private void btnUploadImgae_Click(object sender, EventArgs e)

        {

            OpenFileDialog d = new OpenFileDialog();

            d.Title = "Select Image";

            d.Filter = " (*.jpg;*.png;*.jpeg) | *.jpg;*.png;*.jpeg";

 

            DialogResult dr = new DialogResult();

            dr = d.ShowDialog();

            if (dr == DialogResult.OK)

            {

                img1 = 0;

                pbImage.Image = new Bitmap(d.FileName);

            }

        }

 

        //Select sign of customer 1

        private void btnUploadSigns_Click(object sender, EventArgs e)

        {

            OpenFileDialog d = new OpenFileDialog();

            d.Title = "Select Image";

            d.Filter = " (*.jpg;*.png;*.jpeg) | *.jpg;*.png;*.jpeg";

 

            DialogResult dr = new DialogResult();

            dr = d.ShowDialog();

            if (dr == DialogResult.OK)

            {

                sign1 = 0;

                pbSignature.Image = new Bitmap(d.FileName);

 

            }

 

        }

 

        //Select image of customer 2

        private void btnUploadImgae1_Click(object sender, EventArgs e)

        {

            OpenFileDialog d = new OpenFileDialog();

            d.Title = "Select Image";

            d.Filter = " (*.jpg;*.png;*.jpeg) | *.jpg;*.png;*.jpeg";

 

            DialogResult dr = new DialogResult();

            dr = d.ShowDialog();

            if (dr == DialogResult.OK)

            {

                img2 = 0;

                pbImage1.Image = new Bitmap(d.FileName);

            }

        }

 

        //Select sign of customer 2

        private void btnUploadSigns1_Click(object sender, EventArgs e)

        {

            OpenFileDialog d = new OpenFileDialog();

            d.Title = "Select Image";

            d.Filter = " (*.jpg;*.png;*.jpeg) | *.jpg;*.png;*.jpeg";

 

            DialogResult dr = new DialogResult();

            dr = d.ShowDialog();

            if (dr == DialogResult.OK)

            {

                sign2 = 0;

                pbSignature1.Image = new Bitmap(d.FileName);

            }

        }

 

 

 

        //save image for first customer photo

        public byte[] savePhoto1(PictureBox pb)

        {

 

            MemoryStream ms = new MemoryStream();

            pbImage.Image.Save(ms, pb.Image.RawFormat);

            return ms.GetBuffer();

        }

        //save image for second customer photo

        public byte[] savePhoto2(PictureBox pb)

        {

 

            MemoryStream ms = new MemoryStream();

            pbImage1.Image.Save(ms, pb.Image.RawFormat);

            return ms.GetBuffer();

        }

 

        ////save image for first customer sign

        public byte[] saveSign1(PictureBox pb)

        {

 

            MemoryStream ms = new MemoryStream();

            pbSignature.Image.Save(ms, pb.Image.RawFormat);

            return ms.GetBuffer();

        }

        //save image for first customer sign

        public byte[] saveSign2(PictureBox pb)

        {

 

            MemoryStream ms = new MemoryStream();

            pbSignature1.Image.Save(ms, pb.Image.RawFormat);

            return ms.GetBuffer();

        }

 

        //Change back colour of textboxes when enter and leave them

        private void TextBox_Enter(object sender, EventArgs e)

        {

            TextBox tb = (TextBox)sender;

            tb.BackColor = Color.Lime;

        }

 

        private void TextBox_Leave(object sender, EventArgs e)

        {

            TextBox tb = (TextBox)sender;

            tb.BackColor = Color.White;

        }

 

 

        private void button2_Click(object sender, EventArgs e)

        {

            ClearData1();

            ClearData2();

        }

 

        private void btnSecondPerson_Click(object sender, EventArgs e)

        {

            panel1.Visible = true;

            //btnNevigation.Text = "<<---First person info";

            btnSecondPerson.Enabled = false;

            btnFirstPerson.Enabled = true;

        }

 

        private void btnFirstPerson_Click(object sender, EventArgs e)

        {

            panel1.Visible = false;

            //btnNevigation.Text = "<<---First person info";

            btnSecondPerson.Enabled = true;

            btnFirstPerson.Enabled = false;

        }

 

 

        //insert only String in Text Box

        private void TextField_KeyPress(object sender, KeyPressEventArgs e)

        {

                        

            if (e.KeyChar >= '0' && e.KeyChar <= '9')

            {

                e.Handled = true;

            }

            else

            {

                e.Handled = false;

            }

 

 

        }

 

        private void txtIncome1_KeyPress(object sender, KeyPressEventArgs e)

        {

 

        }

 

        //insert only Numbers in Text Box

        private void NumbericField_KeyPress(object sender, KeyPressEventArgs e)

        {

            

            if (e.KeyChar >= '0' && e.KeyChar <= '9' || e.KeyChar == 08)

            {

                e.Handled = false;

            }

            else

            {

                e.Handled = true;

            }

        }

 

 

        private void rdoSingle_CheckedChanged(object sender, EventArgs e)

        {

            //clearData2();

            type = "single";

            //clearData2();

            btnSecondPerson.Enabled = false;

            //btnshhowpanel.Visible = false;

            single = true;

            joint = false;

            panel1.Visible = false;

 

 

        }

        

 

        //automatic generate id (account numbers)

        double id;

 

 

 

        private void dateTimePicker2_ValueChanged(object sender, EventArgs e)

        {

            //print date in textbox

            if (checkAgeJoint() >= 10)

            {

                txtDateofBirth1.Text = dateTimePicker2.Value.ToString("dd/MM/yyyy");

            }

            else

            {

                MessageBox.Show("Age must be greater than 10 to create an account!""Information!"MessageBoxButtons.OK, MessageBoxIcon.Stop);

                //MessageBox.Show("");

            }

 

        }

 

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)

        {

            //print date in textbox

            if (checkAgeSingle() >= 10)

            {

                txtDateofBirth.Text = dateTimePicker1.Value.ToString("dd/MM/yyyy");

            }

            else

            {

                MessageBox.Show("Age must be greater than 10 to create an account!""Information!"MessageBoxButtons.OK, MessageBoxIcon.Stop);

                //MessageBox.Show("");

            }

 

 

        }

 

        private void btnSave_Click(object sender, EventArgs e)

        {

            if (single)

            {

                if (MsktxtAdharNumber.Text == string.Empty || txtAddress.Text == string.Empty || txtCity.Text == string.Empty || txtDateofBirth.Text == string.Empty || txtDiposit.Text == string.Empty || txtEmailID.Text == string.Empty || txtIncome.Text == string.Empty || txtFatherName.Text == string.Empty || txtCustomerName.Text == string.Empty || MsktxtMobileNumber.Text == string.Empty || txtMotherName.Text == string.Empty || txtPanNumber.Text == string.Empty || MsktxtPinCode.Text == string.Empty || txtReligion.Text == string.Empty || txtTaluka.Text == string.Empty || cmbDistrict.SelectedIndex == 0 || cmbNationality.SelectedIndex == 0 || cmbQualification.SelectedIndex == 0 || cmbState.SelectedIndex == 0)

                {

                    MessageBox.Show("All fields are mendetory please check again!""Error"MessageBoxButtons.OK, MessageBoxIcon.Error);

                }

                else

                {

                    if (emailValidation())

                    {

                        if (rdoMale.Checked == true || rdoFemale.Checked == true || rdoOther.Checked == true)

                        {

                            if (rdoMarried.Checked == true || rdoUnmarried.Checked == true || rdoDivorced.Checked == true || rdoAnnulated.Checked == true)

                            {

                                if (img1 == 1)

                                {

                                    MessageBox.Show("Upload Customer 1 Image ...""Warning"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                }

                                else

                                {

                                    if (sign1 == 1)

                                    {

                                        MessageBox.Show("Upload Customer 1 Signature..""Warning"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                    }

                                    else

                                    {

                                        if (MsktxtMobileNumber.MaskCompleted)

                                        {

                                            if (MsktxtPinCode.MaskCompleted)

                                            {

                                                if (MsktxtAdharNumber.MaskCompleted)

                                                {

                                                    if (txtPanNumber.Text.Length > 11)

                                                    {

                                                        conn = new SqlConnection(CS);

                                                        conn.Open();

 

                                                        //insert into bank balance

                                                        double bal = BankBalance();

                                                        double newbal = bal + Convert.ToDouble(txtDiposit.Text);

                                                        cmd = new SqlCommand("update BankBalance set balance =" + newbal + "", conn);

                                                        cmd.ExecuteNonQuery();

 

                                                        //insert into customer

                                                        cmd = new SqlCommand("insert into customer (accno,account,acctype,name_f,fname_f,mname_f,dob_f,gender_f,aadhar_f,pan_f,qualifi_f,nation_f,state_f,distic_f,taluka_f,city_f,pin_f,address,mobile_f,email_f,maritial_f,relgion_f,income_f,deposite_f,joindate_f,sign_f,photo_f,status) values(@no,@account,@type,@name,@fname,@mname,@dob,@gender,@aadhar,@pan,@quali,@nation,@state,@distic,@taluka,@city,@pin,@address,@mobile,@email,@maritial,@religion,@income,@deposite,@date,@sign,@photo,@status)", conn);

                                                        cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);

                                                        cmd.Parameters.AddWithValue("account""saving");

                                                        cmd.Parameters.AddWithValue("type", type);

                                                        cmd.Parameters.AddWithValue("name", txtCustomerName.Text);

                                                        cmd.Parameters.AddWithValue("fname", txtFatherName.Text);

                                                        cmd.Parameters.AddWithValue("mname", txtMotherName.Text);

                                                        cmd.Parameters.AddWithValue("dob", txtDateofBirth.Text);

                                                        if (rdoMale.Checked)

                                                        {

                                                            cmd.Parameters.AddWithValue("gender""male");

                                                        }

                                                        else if (rdoFemale.Checked)

                                                        {

                                                            cmd.Parameters.AddWithValue("gender""female");

                                                        }

                                                        else

                                                        {

                                                            cmd.Parameters.AddWithValue("gender""other");

                                                        }

                                                        cmd.Parameters.AddWithValue("aadhar", MsktxtAdharNumber.Text);

                                                        cmd.Parameters.AddWithValue("pan", txtPanNumber.Text);

                                                        cmd.Parameters.AddWithValue("quali", cmbQualification.SelectedItem);

                                                        cmd.Parameters.AddWithValue("nation", cmbNationality.SelectedItem);

                                                        cmd.Parameters.AddWithValue("state", cmbState.SelectedItem);

                                                        cmd.Parameters.AddWithValue("distic", cmbDistrict.SelectedItem);

                                                        cmd.Parameters.AddWithValue("taluka", txtTaluka.Text);

                                                        cmd.Parameters.AddWithValue("city", txtCity.Text);

                                                        cmd.Parameters.AddWithValue("pin", MsktxtPinCode.Text);

                                                        cmd.Parameters.AddWithValue("address", txtAddress.Text);

                                                        cmd.Parameters.AddWithValue("mobile", MsktxtMobileNumber.Text);

                                                        cmd.Parameters.AddWithValue("email", txtEmailID.Text);

                                                        if (rdoMarried.Checked)

                                                        {

                                                            cmd.Parameters.AddWithValue("maritial""Maried");

                                                        }

                                                        else if (rdoUnmarried.Checked)

                                                        {

                                                            cmd.Parameters.AddWithValue("maritial""UnMaried");

                                                        }

                                                        else if (rdoDivorced.Checked)

                                                        {

                                                            cmd.Parameters.AddWithValue("maritial""Divorced");

                                                        }

                                                        else

                                                        {

                                                            cmd.Parameters.AddWithValue("maritial""Annulated");

                                                        }

 

                                                        cmd.Parameters.AddWithValue("religion", txtReligion.Text);

                                                        cmd.Parameters.AddWithValue("income", txtIncome.Text);

                                                        cmd.Parameters.AddWithValue("deposite", txtDiposit.Text);

                                                        cmd.Parameters.AddWithValue("date", lblDate.Text);

                                                        cmd.Parameters.AddWithValue("sign", saveSign1(pbSignature));

                                                        cmd.Parameters.AddWithValue("photo", savePhoto1(pbImage));

                                                        cmd.Parameters.AddWithValue("status"true);

                                                        cmd.ExecuteNonQuery();

 

                                                        //insert into passbook table

                                                        cmd = new SqlCommand("insert into passbook (accno,date,info,deposite,avlabl,time) values (@no,@date,@detail,@deposite,@avlabl,@time)", conn);

                                                        cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);

                                                        cmd.Parameters.AddWithValue("date", lblDate.Text);

                                                        cmd.Parameters.AddWithValue("detail""open Account");

                                                        cmd.Parameters.AddWithValue("deposite", txtDiposit.Text);

                                                        cmd.Parameters.AddWithValue("avlabl", txtDiposit.Text);

                                                        cmd.Parameters.AddWithValue("time"DateTime.Now.ToString("hh:mm:ss"));

                                                        cmd.ExecuteNonQuery();

 

                                                        //insert into balance

                                                        cmd = new SqlCommand("insert into balance values(@no,@type,@bal)", conn);

                                                        cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);

                                                        cmd.Parameters.AddWithValue("type""saving");

                                                        cmd.Parameters.AddWithValue("bal"Convert.ToInt64(txtDiposit.Text));

                                                        cmd.ExecuteNonQuery();

 

                                                        //insert into Transaction

                                                        cmd = new SqlCommand("insert into trans_info values(@date,@time,@accno,@type,@ammount)", conn);

                                                        cmd.Parameters.AddWithValue("date", lblDate.Text);

                                                        cmd.Parameters.AddWithValue("time"DateTime.Now.ToString("hh:mm:ss"));

                                                        cmd.Parameters.AddWithValue("accno", txtAccountNumber.Text);

                                                        cmd.Parameters.AddWithValue("type""New Saving Account");

                                                        cmd.Parameters.AddWithValue("ammount", txtDiposit.Text);

                                                        cmd.ExecuteNonQuery();

 

 

                                                        //send mail

                                                        try

                                                        {/*

 

                                                            gmail gmlsnd = new gmail();

                                                            gmlsnd.auth("sgbdhokadava@gmail.com", "yogesh@33@sgb");

                                                            gmlsnd.To = txtemail.Text;

                                                            gmlsnd.fromAlias = "Saurashtra Gramin Bank - Dhokadva";

                                                            gmlsnd.Subject = "Current Account Sucessfully Open";

                                                            gmlsnd.Message = "Dear " + txtfullname.Text + " Your Current Account in Saurashtra Gramin Bank Is Sucessfully Created . Your Account Number Is  " + txtacno.Text;

                                                            gmlsnd.Priority = 1;

                                                            gmlsnd.send();

                                                            */

 

                                                            /*

                                                            var fromAddress = new MailAddress("deedfile@gmail.com", "Gyan Sonwane");

                                                            var toAddress = new MailAddress("txtEmailID.text", "txtCustomerName.text");

                                                            const string fromPassword = "adobeflashcs4";

                                                            const string subject = "test";

                                                            const string body = "Account created";

 

                                                            var smtp = new SmtpClient

                                                            {

                                                                Host = "smtp.gmail.com",

                                                                Port = 587,

                                                                EnableSsl = true,

                                                                DeliveryMethod = SmtpDeliveryMethod.Network,

                                                                Credentials = new NetworkCredential(fromAddress.Address, fromPassword),

                                                                Timeout = 20000

                                                            };

                                                            using (var message = new MailMessage(fromAddress, toAddress)

                                                            {

                                                                Subject = subject,

                                                                Body = body

                                                            })

                                                            {

                                                                smtp.Send(message);

                                                            }

                                                            */

 

 

                                                        }

                                                        catch (Exception ex)

                                                        {

                                                            MessageBox.Show(ex.Message);

                                                            //   MessageBox.Show("Internet Connection Is Required ", "Not Internet", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                                        }

 

 

                                                        MessageBox.Show("Account created successfully! Please print the copy of receipt""Save"MessageBoxButtons.OK, MessageBoxIcon.Information);

 

                                                        lblloader.Visible = true;

 

                                                        //print reports

                                                        r.crystalReportViewer1.ReportSource = null;

                                                        r.crystalReportViewer1.Refresh();

                                                        dt.Clear();

                                                        da = new SqlDataAdapter("select * from customer where accno='" + txtAccountNumber.Text + "'", conn);

                                                        da.Fill(dt);

                                                        Reports.crCustomer c = new Reports.crCustomer();

                                                        c.Database.Tables["customer"].SetDataSource(dt);

                                                        r.crystalReportViewer1.ReportSource = c;

                                                        r.crystalReportViewer1.Refresh();

                                                        r.ShowDialog();

                                                        autoId();

                                                        ClearData1();

 

                                                    }

                                                    else

                                                    {

                                                        MessageBox.Show("Pancard Number Is Not Valid ""Invalid Pan number"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                                    }

 

                                                }

                                                else

                                                {

                                                    MessageBox.Show("Aadhar Number Is Not Valid ""Invalid Aadhar"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                                }

                                            }

                                            else

                                            {

                                                MessageBox.Show("Pin Code Is Not Valid ""Invalid Pin"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                            }

                                        }

                                        else

                                        {

                                            MessageBox.Show("Mobile Number Is Not Valid ""Invalid Mobile"MessageBoxButtons.OK, MessageBoxIcon.Warning);

 

                                        }

 

                                    }

 

 

                                }

 

                            }

                            else

                            {

                                MessageBox.Show("Please Select Marital Status");

 

                            }

 

                        }

                        else

                        {

                            MessageBox.Show("Please Select Gender");

                        }

 

                    }

                    else

                    {

                        MessageBox.Show("InValid Email address ");

                    }

 

                }

 

 

            }

            else if (joint)

            {

                if (MsktxtAdharNumber1.Text == string.Empty || txtAddress1.Text == string.Empty || txtCity1.Text == string.Empty || txtDateofBirth1.Text == string.Empty || txtEmailID1.Text == string.Empty || txtIncome1.Text == string.Empty || txtFatherName1.Text == string.Empty || txtCustomerName1.Text == string.Empty || MsktxtMobileNumber1.Text == string.Empty || txtMotherName1.Text == string.Empty || txtPanNumber1.Text == string.Empty || MsktxtPinCode1.Text == string.Empty || txtReligion1.Text == string.Empty || txtTaluka1.Text == string.Empty || cmbDistrict1.SelectedIndex == 0 || cmbNationality1.SelectedIndex == 0 || cmbQualification1.SelectedIndex == 0 || cmbState1.SelectedIndex == 0)

                {

                    MessageBox.Show("All fields are mendetory please check again!""Error"MessageBoxButtons.OK, MessageBoxIcon.Error);

                }

                else

                {

                    if (emailValidation1())

                    {

                        if (rdoMale1.Checked == true || rdoFemale1.Checked == true || rdoOther1.Checked == true)

                        {

                            if (rdoMarried1.Checked == true || rdoUnmarried1.Checked == true || rdoDivorced1.Checked == true || rdoAnnulated1.Checked == true)

                            {

                                if (img1 == 1)

                                {

                                    MessageBox.Show("Upload Customer 1 Image ...""Warning"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                }

                                else

                                {

                                    if (sign1 == 1)

                                    {

                                        MessageBox.Show("Upload Customer 1 Signature..""Warning"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                    }

                                    else

                                    {

                                        if (img2 == 1)

                                        {

                                            MessageBox.Show("Upload Customer 2 Image""Upload Image"MessageBoxButtons.OK, MessageBoxIcon.Information);

                                        }

                                        else

                                        {

                                            if (sign2 == 1)

                                            {

                                                MessageBox.Show("Upload Customer 2 Signature""Upload Signature"MessageBoxButtons.OK, MessageBoxIcon.Information);

                                            }

                                            else

                                            {

                                                if (MsktxtMobileNumber1.MaskCompleted)

                                                {

                                                    if (MsktxtPinCode1.MaskCompleted)

                                                    {

                                                        if (MsktxtAdharNumber1.MaskCompleted)

                                                        {

                                                            if (txtPanNumber1.Text.Length > 11)

                                                            {

                                                                conn = new SqlConnection(CS);

                                                                conn.Open();

 

                                                                //insert into bank balance

                                                                double bal = BankBalance();

                                                                double newbal = bal + Convert.ToDouble(txtDiposit.Text);

                                                                cmd = new SqlCommand("update BankBalance set balance =" + newbal + "", conn);

                                                                cmd.ExecuteNonQuery();

 

                                                                //insert into customer

 

                                                                cmd = new SqlCommand("insert into customer values(@no,@account,@type,@name,@fname,@mname,@dob,@gender,@aadhar,@pan,@quali,@nation,@state,@distic,@taluka,@city,@pin,@address,@mobile,@email,@maritial,@religion,@income,@deposite,@date,@sign,@photo,@name1,@fname1,@mname1,@dob1,@gender1,@aadhar1,@pan1,@quali1,@nation1,@state1,@distic1,@taluka1,@city1,@pin1,@address1,@mobile1,@email1,@maritial1,@religion1,@income1 ,@sign1,@photo1,@status)", conn);

                                                                cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);

                                                                cmd.Parameters.AddWithValue("account""saving");

                                                                cmd.Parameters.AddWithValue("type", type);

                                                                cmd.Parameters.AddWithValue("name", txtCustomerName.Text);

                                                                cmd.Parameters.AddWithValue("fname", txtFatherName.Text);

                                                                cmd.Parameters.AddWithValue("mname", txtMotherName.Text);

                                                                cmd.Parameters.AddWithValue("dob", txtDateofBirth.Text);

                                                                if (rdoMale.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("gender""male");

                                                                }

                                                                else if (rdoFemale.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("gender""female");

                                                                }

                                                                else

                                                                {

                                                                    cmd.Parameters.AddWithValue("gender""other");

                                                                }

                                                                cmd.Parameters.AddWithValue("aadhar", MsktxtAdharNumber.Text);

                                                                cmd.Parameters.AddWithValue("pan", txtPanNumber.Text);

                                                                cmd.Parameters.AddWithValue("quali", cmbQualification.SelectedItem);

                                                                cmd.Parameters.AddWithValue("nation", cmbNationality.SelectedItem);

                                                                cmd.Parameters.AddWithValue("state", cmbState.SelectedItem);

                                                                cmd.Parameters.AddWithValue("distic", cmbDistrict.SelectedItem);

                                                                cmd.Parameters.AddWithValue("taluka", txtTaluka.Text);

                                                                cmd.Parameters.AddWithValue("city", txtCity.Text);

                                                                cmd.Parameters.AddWithValue("pin", MsktxtPinCode.Text);

                                                                cmd.Parameters.AddWithValue("address", txtAddress.Text);

                                                                cmd.Parameters.AddWithValue("mobile", MsktxtMobileNumber.Text);

                                                                cmd.Parameters.AddWithValue("email", txtEmailID.Text);

                                                                if (rdoMarried.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("maritial""Maried");

                                                                }

                                                                else if (rdoUnmarried.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("maritial""UnMaried");

                                                                }

                                                                else if (rdoDivorced.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("maritial""Divorced");

                                                                }

                                                                else

                                                                {

                                                                    cmd.Parameters.AddWithValue("maritial""Annulated");

                                                                }

 

                                                                cmd.Parameters.AddWithValue("religion", txtReligion.Text);

                                                                cmd.Parameters.AddWithValue("income", txtIncome.Text);

                                                                cmd.Parameters.AddWithValue("deposite", txtDiposit.Text);

                                                                cmd.Parameters.AddWithValue("date", lblDate.Text);

                                                                cmd.Parameters.AddWithValue("sign", saveSign1(pbSignature));

                                                                cmd.Parameters.AddWithValue("photo", savePhoto1(pbImage));

                                                                cmd.Parameters.AddWithValue("status"true);

 

                                                                // Second customer details 

                                                                //cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);

                                                                //cmd.Parameters.AddWithValue("account", "current");

                                                                //cmd.Parameters.AddWithValue("type", type);

                                                                cmd.Parameters.AddWithValue("name1", txtCustomerName1.Text);

                                                                cmd.Parameters.AddWithValue("fname1", txtFatherName1.Text);

                                                                cmd.Parameters.AddWithValue("mname1", txtMotherName1.Text);

                                                                cmd.Parameters.AddWithValue("dob1", txtDateofBirth1.Text);

                                                                if (rdoMale.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("gender1""male");

                                                                }

                                                                else if (rdoFemale.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("gender1""female");

                                                                }

                                                                else

                                                                {

                                                                    cmd.Parameters.AddWithValue("gender1""other");

                                                                }

                                                                cmd.Parameters.AddWithValue("aadhar1", MsktxtAdharNumber1.Text);

                                                                cmd.Parameters.AddWithValue("pan1", txtPanNumber1.Text);

                                                                cmd.Parameters.AddWithValue("quali1", cmbQualification1.SelectedItem);

                                                                cmd.Parameters.AddWithValue("nation1", cmbNationality1.SelectedItem);

                                                                cmd.Parameters.AddWithValue("state1", cmbState1.SelectedItem);

                                                                cmd.Parameters.AddWithValue("distic1", cmbDistrict1.SelectedItem);

                                                                cmd.Parameters.AddWithValue("taluka1", txtTaluka1.Text);

                                                                cmd.Parameters.AddWithValue("city1", txtCity1.Text);

                                                                cmd.Parameters.AddWithValue("pin1", MsktxtPinCode1.Text);

                                                                cmd.Parameters.AddWithValue("address1", txtAddress1.Text);

                                                                cmd.Parameters.AddWithValue("mobile1", MsktxtMobileNumber1.Text);

                                                                cmd.Parameters.AddWithValue("email1", txtEmailID1.Text);

                                                                if (rdoMarried1.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("maritial1""Maried");

                                                                }

                                                                else if (rdoUnmarried1.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("maritial1""UnMaried");

                                                                }

                                                                else if (rdoDivorced1.Checked)

                                                                {

                                                                    cmd.Parameters.AddWithValue("maritial1""Divorced");

                                                                }

                                                                else

                                                                {

                                                                    cmd.Parameters.AddWithValue("maritial1""Annulated");

                                                                }

 

                                                                cmd.Parameters.AddWithValue("religion1", txtReligion1.Text);

                                                                cmd.Parameters.AddWithValue("income1", txtIncome1.Text);

                                                                //cmd.Parameters.AddWithValue("deposite", txtDiposit.Text);

                                                               // cmd.Parameters.AddWithValue("date", lblDate.Text);

                                                                cmd.Parameters.AddWithValue("sign1", saveSign2(pbSignature));

                                                                cmd.Parameters.AddWithValue("photo1", savePhoto2(pbImage));

                                                                //cmd.Parameters.AddWithValue("status", true);

                                                                cmd.ExecuteNonQuery();

 

 

                                                                //insert into passbook table

                                                                cmd = new SqlCommand("insert into passbook (accno,date,info,deposite,avlabl,time) values (@no,@date,@detail,@deposite,@avlabl,@time)", conn);

                                                                cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);

                                                                cmd.Parameters.AddWithValue("date", lblDate.Text);

                                                                cmd.Parameters.AddWithValue("detail""open Account");

                                                                cmd.Parameters.AddWithValue("deposite", txtDiposit.Text);

                                                                cmd.Parameters.AddWithValue("avlabl", txtDiposit.Text);

                                                                cmd.Parameters.AddWithValue("time"DateTime.Now.ToString("hh:mm:ss"));

                                                                cmd.ExecuteNonQuery();

 

                                                                //insert into balance

                                                                cmd = new SqlCommand("insert into balance values(@no,@type,@bal)", conn);

                                                                cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);

                                                                cmd.Parameters.AddWithValue("type""saving");

                                                                cmd.Parameters.AddWithValue("bal"Convert.ToInt64(txtDiposit.Text));

                                                                cmd.ExecuteNonQuery();

 

                                                                //insert into Transaction

                                                                cmd = new SqlCommand("insert into trans_info values(@date,@time,@accno,@type,@ammount)", conn);

                                                                cmd.Parameters.AddWithValue("date", lblDate.Text);

                                                                cmd.Parameters.AddWithValue("time"DateTime.Now.ToString("hh:mm:ss"));

                                                                cmd.Parameters.AddWithValue("accno", txtAccountNumber.Text);

                                                                cmd.Parameters.AddWithValue("type""New Saving Account");

                                                                cmd.Parameters.AddWithValue("ammount", txtDiposit.Text);

                                                                cmd.ExecuteNonQuery();

 

 

                                                                MessageBox.Show("Account created successfully! Please print the copy of receipt""Save"MessageBoxButtons.OK, MessageBoxIcon.Information);

 

                                                                lblloader.Visible = true;

 

                                                                //print reports

                                                                r.crystalReportViewer1.ReportSource = null;

                                                                r.crystalReportViewer1.Refresh();

                                                                dt.Clear();

                                                                da = new SqlDataAdapter("select * from customer where accno='" + txtAccountNumber.Text + "'", conn);

                                                                da.Fill(dt);

                                                                Reports.crCustomer c = new Reports.crCustomer();

                                                                c.Database.Tables["customer"].SetDataSource(dt);

                                                                r.crystalReportViewer1.ReportSource = c;

                                                                r.crystalReportViewer1.Refresh();

                                                                r.ShowDialog();

                                                                autoId();

                                                                ClearData1();

                                                                ClearData2();

                                                            }

                                                            else

                                                            {

                                                                MessageBox.Show("Pancard Number Is Not Valid ""Invalid Pan number"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                                            }

                                                        }

                                                        else

                                                        {

                                                            MessageBox.Show("Aadhar Number Is Not Valid ""Invalid Aadhar"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                                        }

                                                    }

                                                    else

                                                    {

                                                        MessageBox.Show("Pin Code Is Not Valid ""Invalid Pin"MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                                    }

                                                }

                                                else

                                                {

                                                    MessageBox.Show("Mobile Number Is Not Valid ""Invalid Mobile"MessageBoxButtons.OK, MessageBoxIcon.Warning);

 

                                                }

                                            }

 

                                        }

                                    }

                                }

                            }

                            else

                            {

                                MessageBox.Show("Please Select Marital Status");

                            }

                        }

                        else

                        {

                            MessageBox.Show("Please Select Gender");

                        }

                    }

                    else

                    {

                        MessageBox.Show("InValid Email address ");

                    }

                }

 

            }

            else

            {

                MessageBox.Show("Please Select Account Type First""Error"MessageBoxButtons.OK, MessageBoxIcon.Error);

            }

 

 

 

        }

 

        private void autoId()

        {

            conn = new SqlConnection(CS);

            conn.Open();

            cmd = new SqlCommand("select MAX(accno) from customer", conn);

            accno = cmd.ExecuteScalar().ToString();

            if (accno == "")

            {

                txtAccountNumber.Text = "30000000001";

            }

            else

            {

                id = Convert.ToInt64(accno);

                id = id + 1;

                txtAccountNumber.Text = id.ToString();

            }

        }

 

        //validations

        private bool emailValidation()

        {

            if (Regex.IsMatch(txtEmailID.Text, "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$"))

            {

                return true;

            }

            else

            {

                return false;

            }

        }

 

        private bool emailValidation1()

        {

            if (Regex.IsMatch(txtEmailID1.Text, "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$"))

            {

                return true;

            }

            else

            {

                return false;

            }

        }

 

        //check first account holder gender

        private string CheckGen1()

        {

            if (rdoMale.Checked)

            {

                gender = "male";

            }

            else if (rdoFemale.Checked)

            {

                gender = "female";

            }

            else

            {

                gender = "Other";

            }

            return gender;

        }

 

        //check Second account holder gender

        private string CheckGen2()

        {

            if (rdoMale1.Checked)

            {

                gender1 = "male";

            }

            else if (rdoFemale1.Checked)

            {

                gender1 = "female";

            }

            else

            {

                gender1 = "Other";

            }

            return gender1;

        }

 

 

        //check Maritial Status of Customer 1

        private string checkMar1()

        {

            if (rdoMarried.Checked)

            {

                marid = "maried";

            }

            else if(rdoUnmarried.Checked)

            {

                marid = "unmaried";

            }

            else if (rdoDivorced.Checked)

            {

                marid = "Divorced";

            }

            else

            {

                marid = "Annulated";

            }

            return marid;

        }

 

 

        //check Maritial Status of Customer 1

        private string checkMar2()

        {

            if (rdoMarried1.Checked)

            {

                marid1 = "maried";

            }

            else if (rdoUnmarried1.Checked)

            {

                marid1 = "unmaried";

            }

            else if (rdoDivorced1.Checked)

            {

                marid1 = "Divorced";

            }

            else

            {

                marid1 = "Annulated";

            }

            return marid1;

        }

 

        //check the age of customer

        public int checkAgeSingle()

        {

            int year = Convert.ToInt32(dateTimePicker1.Value.Year);

            int year1 = Convert.ToInt32(DateTime.Now.Year);

            int age = year1 - year;

            return age;

        }

        public int checkAgeJoint()

        {

            int year = Convert.ToInt32(dateTimePicker2.Value.Year);

            int year1 = Convert.ToInt32(DateTime.Now.Year);

            int age = year1 - year;

            return age;

        }

 

       /* private void NewCustomer_Load(object sender, EventArgs e)

        {

            //show date in label

            lbldate.Text = DateTime.Now.ToString("dd-MM-yyyy");

            time = DateTime.Now.ToString("hh:mm:ss");

            autoId();

            cbdis.SelectedIndex = 0;

            cbnation.SelectedIndex = 0;

            cbqualify.SelectedIndex = 0;

            cbstate.SelectedIndex = 0;

            cbstate1.SelectedIndex = 0;

            cbqualify1.SelectedIndex = 0;

            cbnatinality1.SelectedIndex = 0;

            cbdistic1.SelectedIndex = 0;

        }

        */

 

        protected void ClearData1()

        {

            rdoMale.Checked = false;

            rdoFemale.Checked = false;

            rdoOther.Checked = false;

            rdoMarried.Checked = false;

            rdoSingle.Checked = false;

            rdoJoint.Checked = false;

            rdoUnmarried.Checked = false;

            rdoAnnulated.Checked = false;

            rdoDivorced.Checked = false;

            cmbDistrict.SelectedIndex = 0;

            cmbNationality.SelectedIndex = 0;

            cmbQualification.SelectedIndex = 0;

            cmbState.SelectedIndex = 0;

            MsktxtAdharNumber.Clear();

            txtCity.Clear();

            txtCustomerName.Clear();

            txtDateofBirth.Clear();

            txtEmailID.Clear();

            txtFatherName.Clear();

            txtIncome.Clear();

            txtPanNumber.Clear();

            txtReligion.Clear();

            txtTaluka.Clear();

            txtMotherName.Clear();

            txtAddress.Clear();

            txtDiposit.Clear();

            MsktxtPinCode.Clear();

            MsktxtMobileNumber.Clear();

            pbImage.Image = null;

            pbSignature.Image = null;

        }

 

 

        protected void ClearData2()

        {

            rdoMale1.Checked = false;

            rdoFemale1.Checked = false;

            rdoOther1.Checked = false;

            rdoMarried1.Checked = false;

           // rdoSingle1.Checked = false;

            //rdoJoint1.Checked = false;

            rdoUnmarried1.Checked = false;

            rdoAnnulated1.Checked = false;

            rdoDivorced1.Checked = false;

            cmbDistrict1.SelectedIndex = 0;

            cmbNationality1.SelectedIndex = 0;

            cmbQualification1.SelectedIndex = 0;

            cmbState1.SelectedIndex = 0;

            MsktxtAdharNumber1.Clear();

            txtCity1.Clear();

            txtCustomerName1.Clear();

            txtDateofBirth1.Clear();

            txtEmailID1.Clear();

            txtFatherName1.Clear();

            txtIncome1.Clear();

            txtPanNumber1.Clear();

            txtReligion1.Clear();

            txtTaluka1.Clear();

            txtMotherName1.Clear();

            txtAddress1.Clear();

            MsktxtPinCode1.Clear();

            MsktxtMobileNumber1.Clear();

            // txtDiposit1.Clear();

            pbImage1.Image = null;

            pbSignature1.Image = null;

        }

  

    }

}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace FinoBank_Application
{
    public partial class frmAboutUs : Form
    {
        public frmAboutUs()
        {
            InitializeComponent();
        }
 
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("https://zee-yan.blogspot.com/");
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
                System.Diagnostics.Process.Start("C:\\Windows\\System32\\msinfo32.exe");
        }
 
        private void frmAboutUs_Load(object sender, EventArgs e)
        {
            //toolStripProgressBar1 p
 
         //frmMainWindow FrmMainWindow = new frmMainWindow();
 
            
            //FrmMainWindow.toolStripProgressBar1.Value = toolStripProgressBar1.Value + 10;
 
 
        }
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
namespace FinoBank_Application
{
    public partial class frmAllFDAccounts : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmAllFDAccounts()
        {
            InitializeComponent();
        }
 
        SqlDataAdapter da;
        DataTable dt = new DataTable();
        SqlConnection conn;
 
        private void frmAllFDAccounts_Load(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
            while (dataGridView1.Rows.Count >= 1)
            {
                dataGridView1.Rows.RemoveAt(0);
            }
 
            da = new SqlDataAdapter("select id as 'FD ID' , accno as 'Account Number',custtype as 'Customer Type',name as 'Customer Name',amount as 'FD Ammount',duration as 'FD Duration',interest as 'FD Interest',sdate as 'Starting Date',edate as 'Ending Date' from fd", conn);
            da.Fill(dt);
            dataGridView1.DataSource = dt;
 
            cmbCategory.SelectedIndex = 0;
        }
 
        private void cmbCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbCategory.SelectedIndex == 4)
            {
                cmbDuration.Visible = true;
                txtSearch.Visible = false;
 
            }
            else
            {
                cmbDuration.Visible = false;
                txtSearch.Visible = true;
 
            }
        }
 
        private void btnSearch_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            if (txtSearch.Text == string.Empty)
            {
                     MessageBox.Show("Please enter category to search! ""Enter catagory Name"MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (cmbCategory.SelectedIndex == 0)
                {
                    while (dataGridView1.Rows.Count >= 1)
                    {
                        dataGridView1.Rows.RemoveAt(0);
                    }
 
                    da = new SqlDataAdapter("select id as 'FD ID' , accno as 'Account Number',custtype as 'Customer Type',name as 'Customer Name',amount as 'FD Ammount',duration as 'FD Duration',interest as 'FD Interest',sdate as 'Starting Date',edate as 'Ending Date' from fd ", conn);
                    da.Fill(dt);
                    dataGridView1.DataSource = dt;
                }
                if (cmbCategory.SelectedIndex == 1)
                {
                    while (dataGridView1.Rows.Count >= 1)
                    {
                        dataGridView1.Rows.RemoveAt(0);
                    }
 
                    da = new SqlDataAdapter("select id as 'FD ID' , accno as 'Account Number',custtype as 'Customer Type',name as 'Customer Name',amount as 'FD Ammount',duration as 'FD Duration',interest as 'FD Interest',sdate as 'Starting Date',edate as 'Ending Date' from fd where id='" + txtSearch.Text + "'", conn);
                    da.Fill(dt);
                    dataGridView1.DataSource = dt;
                }
                if (cmbCategory.SelectedIndex == 2)
                {
                    while (dataGridView1.Rows.Count >= 1)
                    {
                        dataGridView1.Rows.RemoveAt(0);
                    }
 
                    da = new SqlDataAdapter("select id as 'FD ID' , accno as 'Account Number',custtype as 'Customer Type',name as 'Customer Name',amount as 'FD Ammount',duration as 'FD Duration',interest as 'FD Interest',sdate as 'Starting Date',edate as 'Ending Date' from fd where accno='" + txtSearch.Text + "'", conn);
                    da.Fill(dt);
                    dataGridView1.DataSource = dt;
                }
                if (cmbCategory.SelectedIndex == 3)
                {
                    while (dataGridView1.Rows.Count >= 1)
                    {
                        dataGridView1.Rows.RemoveAt(0);
                    }
 
                    da = new SqlDataAdapter("select id as 'FD ID' , accno as 'Account Number',custtype as 'Customer Type',name as 'Customer Name',amount as 'FD Ammount',duration as 'FD Duration',interest as 'FD Interest',sdate as 'Starting Date',edate as 'Ending Date' from fd where name='" + txtSearch.Text + "'", conn);
                    da.Fill(dt);
                    dataGridView1.DataSource = dt;
                }
                if (cmbCategory.SelectedIndex == 4)
                {
                    while (dataGridView1.Rows.Count >= 1)
                    {
                        dataGridView1.Rows.RemoveAt(0);
                    }
 
                    da = new SqlDataAdapter("select id as 'FD ID' , accno as 'Account Number',custtype as 'Customer Type',name as 'Customer Name',amount as 'FD Ammount',duration as 'FD Duration',interest as 'FD Interest',sdate as 'Starting Date',edate as 'Ending Date' from fd where duration='" + cmbDuration.SelectedItem + "'", conn);
                    da.Fill(dt);
                    dataGridView1.DataSource = dt;
                }
                if (cmbCategory.SelectedIndex == 5)
                {
                    while (dataGridView1.Rows.Count >= 1)
                    {
                        dataGridView1.Rows.RemoveAt(0);
                    }
 
                    da = new SqlDataAdapter("select id as 'FD ID' , accno as 'Account Number',custtype as 'Customer Type',name as 'Customer Name',amount as 'FD Ammount',duration as 'FD Duration',interest as 'FD Interest',sdate as 'Starting Date',edate as 'Ending Date' from fd where  status='" + false + "'", conn);
                    da.Fill(dt);
                    dataGridView1.DataSource = dt;
                }
                if (cmbCategory.SelectedIndex == 6)
                {
                    while (dataGridView1.Rows.Count >= 1)
                    {
                        dataGridView1.Rows.RemoveAt(0);
                    }
 
                    da = new SqlDataAdapter("select id as 'FD ID' , accno as 'Account Number',custtype as 'Customer Type',name as 'Customer Name',amount as 'FD Ammount',duration as 'FD Duration',interest as 'FD Interest',sdate as 'Starting Date',edate as 'Ending Date' from fd where  status='" + true + "'", conn);
                    da.Fill(dt);
                    dataGridView1.DataSource = dt;
                }
 
            }
 
         }
 
    }
}

 

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
 
namespace FinoBank_Application
{
    public partial class frmAllLoanAccounts : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmAllLoanAccounts()
        {
            InitializeComponent();
        }
 
 
        SqlDataAdapter da;
        SqlConnection conn;
        DataTable dt = new DataTable();
 
        private void frmAllLoanAccounts_Load(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            comboBox1.SelectedIndex = 0;
            while (dataGridView1.Rows.Count > 0)
            {
                dataGridView1.Rows.RemoveAt(0);
            }
 
            da = new SqlDataAdapter("select id as 'Loan Id',type as 'Loan Type',amount as 'Loan Ammount', accno as 'Account Number', name as 'Customer Name',interest as 'Loan Interest',startdate as 'Loan Starting Date',enddate as 'Loan Ending Date',duration as 'Loan Duration',interval as 'EMI Interval',noofemi as 'Total EMI',emiammount as 'Total EMI Ammount',totalinterest as 'Total Interest Ammount',totalamount as 'Total Ammount', firstemi as 'First Emi', waccno as 'Witness Account Number',wname as 'Witness Name' from loan", conn);
            da.Fill(dt);
            dataGridView1.DataSource = dt;
        }
 
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == 6 || comboBox1.SelectedIndex == 7 || comboBox1.SelectedIndex == 8)
            {
                textBox1.Visible = true;
                btnSearch2.Visible = true;
            }
            else
            {
                textBox1.Visible = false;
                btnSearch2.Visible = false;
            }
        }
 
 
        //Search button code for both the search buttons
        private void btnserach_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            if (comboBox1.SelectedIndex == 1)
            {
                while (dataGridView1.Rows.Count > 0)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                da = new SqlDataAdapter("select id as 'Loan Id',type as 'Loan Type',amount as 'Loan Ammount', accno as 'Account Number', name as 'Customer Name',interest as 'Loan Interest',startdate as 'Loan Starting Date',enddate as 'Loan Ending Date',duration as 'Loan Duration',interval as 'EMI Interval',noofemi as 'Total EMI',emiammount as 'Total EMI Ammount',totalinterest as 'Total Interest Ammount',totalamount as 'Total Ammount', firstemi as 'First Emi', waccno as 'Witness Account Number',wname as 'Witness Name' from loan where type='Home Loan'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (comboBox1.SelectedIndex == 2)
            {
                while (dataGridView1.Rows.Count > 0)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                da = new SqlDataAdapter("select id as 'Loan Id',type as 'Loan Type',amount as 'Loan Ammount', accno as 'Account Number', name as 'Customer Name',interest as 'Loan Interest',startdate as 'Loan Starting Date',enddate as 'Loan Ending Date',duration as 'Loan Duration',interval as 'EMI Interval',noofemi as 'Total EMI',emiammount as 'Total EMI Ammount',totalinterest as 'Total Interest Ammount',totalamount as 'Total Ammount', firstemi as 'First Emi', waccno as 'Witness Account Number',wname as 'Witness Name' from loan where  type='Education Loan'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (comboBox1.SelectedIndex == 3)
            {
                while (dataGridView1.Rows.Count > 0)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                da = new SqlDataAdapter("select id as 'Loan Id',type as 'Loan Type',amount as 'Loan Ammount', accno as 'Account Number', name as 'Customer Name',interest as 'Loan Interest',startdate as 'Loan Starting Date',enddate as 'Loan Ending Date',duration as 'Loan Duration',interval as 'EMI Interval',noofemi as 'Total EMI',emiammount as 'Total EMI Ammount',totalinterest as 'Total Interest Ammount',totalamount as 'Total Ammount', firstemi as 'First Emi', waccno as 'Witness Account Number',wname as 'Witness Name' from loan where  type='Farm Loan'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (comboBox1.SelectedIndex == 4)
            {
                while (dataGridView1.Rows.Count > 0)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                da = new SqlDataAdapter("select id as 'Loan Id',type as 'Loan Type',amount as 'Loan Ammount', accno as 'Account Number', name as 'Customer Name',interest as 'Loan Interest',startdate as 'Loan Starting Date',enddate as 'Loan Ending Date',duration as 'Loan Duration',interval as 'EMI Interval',noofemi as 'Total EMI',emiammount as 'Total EMI Ammount',totalinterest as 'Total Interest Ammount',totalamount as 'Total Ammount', firstemi as 'First Emi', waccno as 'Witness Account Number',wname as 'Witness Name' from loan where  type='Car Loan'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (comboBox1.SelectedIndex == 5)
            {
                while (dataGridView1.Rows.Count > 0)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                da = new SqlDataAdapter("select id as 'Loan Id',type as 'Loan Type',amount as 'Loan Ammount', accno as 'Account Number', name as 'Customer Name',interest as 'Loan Interest',startdate as 'Loan Starting Date',enddate as 'Loan Ending Date',duration as 'Loan Duration',interval as 'EMI Interval',noofemi as 'Total EMI',emiammount as 'Total EMI Ammount',totalinterest as 'Total Interest Ammount',totalamount as 'Total Ammount', firstemi as 'First Emi', waccno as 'Witness Account Number',wname as 'Witness Name' from loan where  type='Personal Loan'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (comboBox1.SelectedIndex == 6)
            {
                while (dataGridView1.Rows.Count > 0)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                da = new SqlDataAdapter("select id as 'Loan Id',type as 'Loan Type',amount as 'Loan Ammount', accno as 'Account Number', name as 'Customer Name',interest as 'Loan Interest',startdate as 'Loan Starting Date',enddate as 'Loan Ending Date',duration as 'Loan Duration',interval as 'EMI Interval',noofemi as 'Total EMI',emiammount as 'Total EMI Ammount',totalinterest as 'Total Interest Ammount',totalamount as 'Total Ammount', firstemi as 'First Emi', waccno as 'Witness Account Number',wname as 'Witness Name' from loan where  id='" + textBox1.Text + "'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (comboBox1.SelectedIndex == 7)
            {
                while (dataGridView1.Rows.Count > 0)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                da = new SqlDataAdapter("select id as 'Loan Id',type as 'Loan Type',amount as 'Loan Ammount', accno as 'Account Number', name as 'Customer Name',interest as 'Loan Interest',startdate as 'Loan Starting Date',enddate as 'Loan Ending Date',duration as 'Loan Duration',interval as 'EMI Interval',noofemi as 'Total EMI',emiammount as 'Total EMI Ammount',totalinterest as 'Total Interest Ammount',totalamount as 'Total Ammount', firstemi as 'First Emi', waccno as 'Witness Account Number',wname as 'Witness Name' from loan where  accno='" + textBox1.Text + "'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (comboBox1.SelectedIndex == 8)
            {
                while (dataGridView1.Rows.Count > 0)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                da = new SqlDataAdapter("select id as 'Loan Id',type as 'Loan Type',amount as 'Loan Ammount', accno as 'Account Number', name as 'Customer Name',interest as 'Loan Interest',startdate as 'Loan Starting Date',enddate as 'Loan Ending Date',duration as 'Loan Duration',interval as 'EMI Interval',noofemi as 'Total EMI',emiammount as 'Total EMI Ammount',totalinterest as 'Total Interest Ammount',totalamount as 'Total Ammount', firstemi as 'First Emi', waccno as 'Witness Account Number',wname as 'Witness Name' from loan where  name='" + textBox1.Text + "'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
 
        }
 
 
        private void btnRefresh_Click_1(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            textBox1.Clear();
            comboBox1.SelectedIndex = 0;
            while (dataGridView1.Rows.Count > 0)
            {
                dataGridView1.Rows.RemoveAt(0);
            }
 
            da = new SqlDataAdapter("select id as 'Loan Id',type as 'Loan Type',amount as 'Loan Ammount', accno as 'Account Number', name as 'Customer Name',interest as 'Loan Interest',startdate as 'Loan Starting Date',enddate as 'Loan Ending Date',duration as 'Loan Duration',interval as 'EMI Interval',noofemi as 'Total EMI',emiammount as 'Total EMI Ammount',totalinterest as 'Total Interest Ammount',totalamount as 'Total Ammount', firstemi as 'First Emi', waccno as 'Witness Account Number',wname as 'Witness Name' from loan", conn);
            da.Fill(dt);
            dataGridView1.DataSource = dt;
        }
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
 
 
namespace FinoBank_Application
{
    public partial class frmAllReminder : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmAllReminder()
        {
            InitializeComponent();
        }
 
        SqlCommand cmd;
        SqlDataReader dr;
        SqlConnection conn;
        //string user;
 
        private void frmAllReminder_Load(object sender, EventArgs e)
        {
            view();
            this.dateTimePicker1.CustomFormat = "hh:mm:ss";
            this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
            //this.dateTimePicker1.ShowUpDown = true;
        }
 
 
        private void view()
        {
            conn = new SqlConnection(CS);
            conn.Open();
            comboBox1.Items.Clear();
            comboBox1.Items.Add("-----Select Title-----");
            comboBox1.SelectedIndex = 0;
            cmd = new SqlCommand("select title from reminder", conn);
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                comboBox1.Items.Add(dr[0].ToString());
            }
            dr.Close();
        }
 
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("select * from reminder where title='" + comboBox1.SelectedItem + "'", conn);
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                txtDate.Text = dr[0].ToString();
                dateTimePicker1.Value= Convert.ToDateTime(dr[1].ToString());
                txtMsg.Text = dr[2].ToString();
 
            }
            dr.Close();
        }
        private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
        {
            txtDate.Text = dateTimePicker2.Value.ToString("dd/MM/yyyy");
        }
 
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("update reminder set date='" + txtDate.Text + "',time='" + dateTimePicker1.Value.ToString("hh:mm:ss") + "',message='" + txtMsg.Text + "'", conn);
            cmd.ExecuteNonQuery();
            MessageBox.Show("Reminder Updated! ..");
            txtMsg.Clear();
            txtDate.Clear();
            view();
            comboBox1.SelectedIndex = 0;
        }
 
        private void btnDelete_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("delete from reminder where title='" + comboBox1.SelectedItem + "'", conn);
            cmd.ExecuteNonQuery();
            MessageBox.Show("Reminder Delete");
            txtMsg.Clear();
            txtDate.Clear();
            view();
            comboBox1.SelectedIndex = 0;
        }
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
namespace FinoBank_Application
{
    public partial class frmChangePassword : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmChangePassword()
        {
            InitializeComponent();
        }
 
        SqlCommand cmd;
        SqlDataReader dr;
        SqlConnection conn;
        int err = 1, err1 = 1;
        string ans;
        bool show = false;
 
        private void txtpass_TextChanged(object sender, EventArgs e)
        {
            if (txtpass.Text.Length < 8)
            {
                lblmsg1.Visible = true;
                lblmsg1.Text = "Password Must Be Atleast 8 Character";
                err1 = 0;
            }
            else
            {
                lblmsg1.Visible = false;
                err1 = 1;
            }
        }
 
        private void txtconfpass_TextChanged(object sender, EventArgs e)
        {
            lblmsg.Visible = true;
            if (txtconfpass.Text == txtpass.Text)
            {
                lblmsg.Text = "Password Match";
                err = 1;
            }
            else
            {
                lblmsg.Text = "Password Not Match";
                err = 0;
            }
        }
 
        private void frmChangePassword_Load(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            txtanswer.Focus();
            cmd = new SqlCommand("select username from tempuser", conn);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                txtusername.Text = dr[0].ToString();
            }
            dr.Close();
 
            //display value in textbox
            cmd = new SqlCommand("select question,answer from Users where username='" + txtusername.Text + "'", conn);
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                lblquestion.Text = dr[0].ToString();
                ans = dr[1].ToString();
            }
            dr.Close();
        }
 
        private void btnreset_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            if (txtpass.Text != string.Empty || txtconfpass.Text != string.Empty)
            {
                if (txtpass.Text.Length >= 8)
                {
                    if (txtpass.Text == txtconfpass.Text)
                    {
                        cmd = new SqlCommand("update Users set password=@pass where username=@user", conn);
                        cmd.Parameters.AddWithValue("user", txtusername.Text);
                        cmd.Parameters.AddWithValue("pass", txtpass.Text);
 
                        cmd.ExecuteNonQuery();
                        MessageBox.Show("Password Sucessfully Changed""Sucessfull"MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtconfpass.Clear();
                        txtpass.Clear();
                        txtanswer.Clear();
                        txtusername.Clear();
                        this.Size = new Size(634, 480);
                    }
                    else
                    {
                        MessageBox.Show("Both Password Must Be Same!");
                    }
                }
                else
                {
                    MessageBox.Show("Password Must Be 8 Character Or More!");
                }
            }
            else
            {
                MessageBox.Show("Enter Password In Both Fields!""Error"MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 
        private void btnverify_Click(object sender, EventArgs e)
        {
            if (txtanswer.Text == ans)
            {
                this.Size = new Size(634, 480);
 
            }
            else
            {
                MessageBox.Show("Enter Correct Answer Of Security Question");
            }
        }
 
        private void btnshow1_Click(object sender, EventArgs e)
        {
            btnshow2.Visible = true;
            btnshow1.Visible = false;
            txtpass.PasswordChar = '\0';
        }
 
        private void btnshow3_Click(object sender, EventArgs e)
        {
            btnshow4.Visible = true;
            btnshow3.Visible = false;
            txtconfpass.PasswordChar = '\0';
        }
 
        private void btnshow4_Click(object sender, EventArgs e)
        {
            btnshow3.Visible = true;
            btnshow4.Visible = false;
            txtconfpass.PasswordChar = '*';
        }
 
        private void btnshow2_Click(object sender, EventArgs e)
        {
            btnshow1.Visible = true;
            btnshow2.Visible = false;
            txtpass.PasswordChar = '*';
        }
 
        private void txtpass_Leave(object sender, EventArgs e)
        {
            TextBox t = (TextBox)sender;
            if (t.Text.Trim() == String.Empty)
            {
                errorProvider1.SetError(t, "Please Enter Password");
                err1 = 0;
            }
            else
            {
                err1 = 1;
            }
 
        }
 
    }
}

 

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
namespace FinoBank_Application
{
    public partial class frmCheckBalance : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
 
        public frmCheckBalance()
        {
            InitializeComponent();
        }
 
        private void frmCheckBalance_Load(object sender, EventArgs e)
        {
            txtSecondAcHolder.Visible = false;
 
        }
 
 
        SqlCommand cmd;
        SqlDataReader dr;
        SqlConnection conn;
        //string time;
 
        private void btnSearch_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();  
 
            if (txtAccountNumber.Text == string.Empty)
            {
                MessageBox.Show("Please enter the account number!""Error"MessageBoxButtons.OK, MessageBoxIcon.Information);
 
            }
            else
            {
                try
                {
                    cmd = new SqlCommand("select accno,account,acctype,name_f,name_s from customer where accno='" + txtAccountNumber.Text + "'", conn);
                    dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        //txt.Text = dr[0].ToString();
                        txtAccountType.Text = dr[1].ToString();
                        txtCustomerType.Text = dr[2].ToString();
                        if (dr[2].ToString() == "single")
                        {
                            txtFirstAcHolder.Text = dr[3].ToString();
                        }
                        if (dr[2].ToString() == "joint")
                        {
                            txtSecondAcHolder.Visible = true;
                            txtFirstAcHolder.Text = dr[3].ToString();
                            txtSecondAcHolder.Text = dr[4].ToString();
                        }
                    }
                    dr.Close();
 
                    cmd = new SqlCommand("select balance from balance where accno='" + txtAccountNumber.Text + "'", conn);
                    dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        txtAvailableBlnce.Text = dr[0].ToString();
                    }
                    dr.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
 
 
 
 
            }
 
        }
 
        private void txtAccountNumber_Leave(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            if (txtAccountNumber.Text != string.Empty)
            {
                cmd = new SqlCommand("select account from customer where accno='" + txtAccountNumber.Text + "'", conn);
                dr = cmd.ExecuteReader();
                {
                    if (dr.Read())
                    {
                    }
                    else
                    {
                        MessageBox.Show("Account Not Exist""Error"MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtAccountNumber.Focus();
                        txtAccountNumber.Clear();
                    }
                }
                dr.Close();
            }
        }
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
 
namespace FinoBank_Application
{
    public partial class frmCloseFDAccount : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmCloseFDAccount()
        {
            InitializeComponent();
        }
 
        SqlCommand cmd;
        SqlDataReader dr;
        SqlConnection conn;
        string accno; /*string status;*/
        private void btnsearch_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("select * from fd where id='" + txtFDID.Text + "' AND status='" + false + "'", conn);
            dr = cmd.ExecuteReader();
            if (dr.HasRows)
            {
                lblMsg.Visible = true;
                lblClose.Visible = true;
                lblClose.BringToFront();
                lblMsg.BringToFront();
 
            }
 
            dr.Close();
 
            cmd = new SqlCommand("select * from fd where id='" + txtFDID.Text + "'", conn);
            dr = cmd.ExecuteReader();
            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    accno = dr[1].ToString();
                    txtFDAmount.Text = dr[4].ToString();
                    txtDuration.Text = dr[5].ToString();
                    txtInterest.Text = dr[6].ToString();
                    txtTotalInterest.Text = dr[7].ToString();
                    txtTotalAmt.Text = dr[8].ToString();
                    txtStartDate.Text = dr[9].ToString();
                    txtEndDate.Text = dr[10].ToString();
                    txtCustomerName.Text = dr[11].ToString();
                }
            }
            else
            {
                MessageBox.Show("FD Account doesn't Exist""Not Exist"MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtFDID.Focus();
            }
            dr.Close();
        }
 
 
 
        private void Clear()
        {
            //accno = dr[1].ToString();
            txtFDAmount.Clear();
            txtDuration.Clear();
            txtInterest.Clear();
            txtTotalInterest.Clear();
            txtTotalAmt.Clear();
            txtStartDate.Clear();
            txtEndDate.Clear();
            txtCustomerName.Clear();
 
        }
 
 
 
        //bank baalnce
        private double BankBalance()
        {
            conn = new SqlConnection(CS);
            conn.Open();
            double bal = 0;
            cmd = new SqlCommand("select * from BankBalance", conn);
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                bal = Convert.ToDouble(dr[0].ToString());
            }
            dr.Close();
            return bal;
        }
 
        private void btnCloseFD_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
            if (txtFDAmount.Text == string.Empty)
            {
                MessageBox.Show("Please Enter FD Account ID""Warning"MessageBoxButtons.OK, MessageBoxIcon.Information);
 
            }
            else
            {
 
                //select balance from balance table
                string bal = "";
                double balance, newbal = 0, amt, amtwithin;
                cmd = new SqlCommand("select balance from balance where accno='" + accno + "' ", conn);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    bal = dr[0].ToString();
                }
                dr.Close();
 
 
                //calculate the new balance
                balance = Convert.ToInt32(bal);
                amt = Convert.ToInt32(txtFDAmount.Text);
                amtwithin = Convert.ToInt32(txtTotalAmt.Text);
 
 
                int d, d1, m, m1, y, y1;
                d = Convert.ToInt32(DateTime.Now.ToString("dd"));
                m = Convert.ToInt32(DateTime.Now.ToString("MM"));
                y = Convert.ToInt32(DateTime.Now.ToString("yyyy"));
 
                d1 = Convert.ToInt32(txtEndDate.Text.Substring(0, 2));
                m1 = Convert.ToInt32(txtEndDate.Text.Substring(3, 2));
                y1 = Convert.ToInt32(txtEndDate.Text.Substring(6, 4));
 
                if (m1 >= m && y1 >= y)
                {
                    DialogResult dl = MessageBox.Show("FD Not Mature Yet DO You Want To Close Fd?""Close? "MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dl == DialogResult.Yes)
                    {
                        DialogResult dl1 = MessageBox.Show("Do You Want To Transfer balance Into Your Account ?""Transfer/Withdraw"MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (dl1 == DialogResult.Yes)
                        {
 
                            //update fd table
                            cmd = new SqlCommand("update fd set status='" + false + "' where id='" + txtFDID.Text + "'", conn);
                            cmd.ExecuteNonQuery();
 
                            //update balance table 
                            newbal = balance + amt;
                            cmd = new SqlCommand("update balance set balance =" + newbal + " where accno='" + accno + "'", conn);
                            cmd.ExecuteNonQuery();
 
 
 
                            //insert into passbook
                            cmd = new SqlCommand("insert into passbook (accno,date,info,transfer,avlabl,time) values ('" + accno + "','" + DateTime.Now.ToString("dd/MM/yyyy") + "','Transfer FD Into Account'," + amt + "," + amt + ",'" + DateTime.Now.ToString("hh:mm:ss") + "')", conn);
                            cmd.ExecuteNonQuery();
 
                            MessageBox.Show("Your FD Account is Sucessfully Close""Close Account"MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
 
                            //insert into passbook
                            cmd = new SqlCommand("insert into passbook (accno,date,info,widraw,avlabl,time) values ('" + accno + "','" + DateTime.Now.ToString("dd/MM/yyyy") + "','Withdraw FD Account Money'," + amt + "," + newbal.ToString() + ",'" + DateTime.Now.ToString("hh:mm:ss") + "')", conn);
                            cmd.ExecuteNonQuery();
 
                            //insert into bank balance
                            double bb = BankBalance();
                            double newbb = bb - amt;
                            cmd = new SqlCommand("update BankBalance set balance =" + newbb + "", conn);
                            cmd.ExecuteNonQuery();
 
                            //update fd table
                            cmd = new SqlCommand("update fd set status='" + false + "' where id='" + txtFDID.Text + "'", conn);
                            cmd.ExecuteNonQuery();
 
                            MessageBox.Show("Your FD Account is Sucessfully Close""Close Account"MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
 
 
                }
                else
                {
                    DialogResult dl = MessageBox.Show("Do You Want To Transfer balance Into Your Account ?""Transfer/Withdraw"MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dl == DialogResult.Yes)
                    {
                        //update fd table
 
                        cmd = new SqlCommand("update fd set status='" + false + "' where id='" + txtFDID.Text + "'", conn);
                        cmd.ExecuteNonQuery();
 
                        //update balance table 
                        newbal = balance + amtwithin;
                        cmd = new SqlCommand("update balance set balance ='" + newbal + "' where accno='" + accno + "'", conn);
                        cmd.ExecuteNonQuery();
 
                        //insert into passbook
                        cmd = new SqlCommand("insert into passbook (accno,date,info,transfer,avlabl,time) values ('" + accno + "','" + DateTime.Now.ToString("dd/MM/yyyy") + "','Transfer FD Into Account'," + amtwithin + "," + newbal.ToString() + ",'" + DateTime.Now.ToString("hh:mm:ss") + "')", conn);
                        cmd.ExecuteNonQuery();
 
                        MessageBox.Show("Your FD Account is Sucessfully Close""Close Account"MessageBoxButtons.OK, MessageBoxIcon.Information);
 
                    }
                    else
                    {
                        //update fd table
                        cmd = new SqlCommand("update fd set status='" + false + "' where id='" + txtFDID.Text + "'", conn);
                        cmd.ExecuteNonQuery();
 
                        //insert into bank balance
                        double bb = BankBalance();
                        double newbb = bb - amt;
                        cmd = new SqlCommand("update BankBalance set balance =" + newbb + "", conn);
                        cmd.ExecuteNonQuery();
 
                        //insert into passbook
                        cmd = new SqlCommand("insert into passbook (accno,date,info,widraw,avlabl,time) values ('" + accno + "','" + DateTime.Now.ToString("dd/MM/yyyy") + "','Withdraw FD Account Money'," + amtwithin + "," + newbal.ToString() + ",'" + DateTime.Now.ToString("hh:mm:ss") + "')", conn);
                        cmd.ExecuteNonQuery();
 
                        MessageBox.Show("Your FD Account is Sucessfully Close""Close Account"MessageBoxButtons.OK, MessageBoxIcon.Information);
 
                    }
 
                }
 
            }
 
        }
 
        private void lblClose_Click(object sender, EventArgs e)
        {
            lblMsg.Visible = false;
            lblClose.Visible = false;
        }
 
        private void btnClear_Click(object sender, EventArgs e)
        {
            Clear();
        }
 
        private void frmCloseFDAccount_Load(object sender, EventArgs e)
        {
            Clear();
            txtFDID.Focus();
            lblMsg.Visible = false;
            lblClose.Visible = false;
        }
 
 
 
 
 
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
 
 
 
namespace FinoBank_Application
{
    public partial class frmCreateUser : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmCreateUser()
        {
            InitializeComponent();
        }
 
        SqlCommand cmd;
        SqlDataReader dr;
        SqlConnection conn;
        string gen;
        int img = 1;
 
        private void frmCreateUser_Load(object sender, EventArgs e)
        {
            cmbUserType.SelectedIndex = 0;
            autoID();
        }
 
        //Create automatic IDs
        private void autoID()
        {
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("select MAX(id) from Users", conn);
            object id = cmd.ExecuteScalar();
            if (id != null)
            {
                int i = Convert.ToInt32(id);
                i = i + 1;
                txtUserID.Text = i.ToString();
            }
            else
            {
                txtUserID.Text = "1";
            }
 
        }
 
        //random password
        public static string password(Random random)
        {
            string characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
            StringBuilder result = new StringBuilder(8);
            for (int i = 0; i < 8; i++)
            {
                result.Append(characters[random.Next(characters.Length)]);
            }
            return result.ToString();
        }
 
        //Check the gender of user
        public string checkGen()
        {
            if (rdoFemale.Checked)
            {
                gen = "Female";
            }
            else if (rdoMale.Checked)
            {
                gen = "Male";
            }
            else
            {
                gen = "Other";
            }
            return gen;
        }
 
 
        //Clear Data
        public void clearData()
        {
            txtUserName.Clear();
            txtUserFullName.Clear();
            txtMskMobile.Clear();
            txtDateofBirth.Clear();
            txtEmailID.Clear();
            cmbUserType.SelectedIndex = 0;
            pbImage1.Image = null;
        }
 
        private void btnClearFields_Click(object sender, EventArgs e)
        {
            clearData();
        }
 
        //Check if email is correct
        private bool emailValidation()
        {
            if (Regex.IsMatch(txtEmailID.Text, "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$"))
            {
                return true;
            }
 
            return false;
        }
 
        //save image temporary 
        public byte[] savePhoto(PictureBox pb)
        {
            MemoryStream ms = new MemoryStream();
            pbImage1.Image.Save(ms, pb.Image.RawFormat);
            return ms.GetBuffer();
        }
        //display photo
        public Image DisPhoto(byte[] photo)
        {
            MemoryStream ms = new MemoryStream(photo);
            return Image.FromStream(ms);
        }
 
        //check the age of User
        public int checkAge()
        {
            int year = Convert.ToInt32(dateTimePicker1.Value.Year);
            int year1 = Convert.ToInt32(DateTime.Now.Year);
            int age = year1 - year;
            return age;
        }
 
        //Upload Image
        private void btnUpload_Click_1(object sender, EventArgs e)
        {
            OpenFileDialog d = new OpenFileDialog();
            d.Title = "Select Image";
            d.Filter = " (*.jpg;*.png;*.jpeg) | *.jpg;*.png;*.jpeg";
            DialogResult dr = new DialogResult();
            dr = d.ShowDialog();
            if (dr == DialogResult.OK)
            {
                img = 0;
                pbImage1.Image = new Bitmap(d.FileName);
            }
        }
 
        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            if (checkAge() >= 18)
            {
                txtDateofBirth.Text = dateTimePicker1.Value.ToString("dd/MM/yyyy");
            }
            else
            {
                MessageBox.Show("User must be equal of greater then 18 years!""Error"MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 
        private void btnCreateUser_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            bool exist = false;
            string userpass = "";
            Random rnd = new Random();
            string[] pass = new string[10];
            for (int i = 0; i < pass.Length; i++)
            {
                pass[i] = password(rnd);
                userpass = pass[i];
            }
 
            if (txtUserName.Text == string.Empty || txtMskMobile.Text == string.Empty || txtUserFullName.Text == string.Empty || txtDateofBirth.Text == string.Empty)
            {
                MessageBox.Show("All fields are mendetory! ""Inform"MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                cmd = new SqlCommand("select username from Users where username='" + txtUserName.Text + "'", conn);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    exist = true;
                }
                dr.Close();
                if (exist)
                {
                    MessageBox.Show("Username Already Exist Please Enter Other Username""Error"MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtUserName.Focus();
                }
                else
                {
                    if (txtMskMobile.MaskFull)
                    {
                        if (emailValidation())
                        {
                            if (cmbUserType.SelectedIndex == 0)
                            {
                                MessageBox.Show("Please Select user Roll""Select User roll"MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                if (img == 1)
                                {
                                    MessageBox.Show("Please upload user Image""Upload Image"MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                                else
                                {
                                    try
                                    {   
                                        //Save the information in User table
                                        cmd = new SqlCommand("insert into Users  (id,username,password,type,fullname,dob,gender,mobile,email,image) values (@id,@uname,@pass,@type,@name,@dob,@gen,@mob,@email,@image)", conn);
                                        cmd.Parameters.AddWithValue("id", txtUserID.Text);
                                        cmd.Parameters.AddWithValue("uname", txtUserName.Text);
                                        cmd.Parameters.AddWithValue("pass", userpass);
                                        cmd.Parameters.AddWithValue("type", cmbUserType.SelectedItem);
                                        cmd.Parameters.AddWithValue("name", txtUserFullName.Text);
                                        cmd.Parameters.AddWithValue("dob", txtDateofBirth.Text);
                                        cmd.Parameters.AddWithValue("gen", checkGen());
                                        cmd.Parameters.AddWithValue("mob", txtMskMobile.Text);
                                        cmd.Parameters.AddWithValue("email", txtEmailID.Text);
                                        cmd.Parameters.AddWithValue("image", savePhoto(pbImage1));
                                        cmd.ExecuteNonQuery();
 
                                        MessageBox.Show("User Created Successfully!  ,Temporary Password Send User Via Email.""Success"MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        clearData();
                                        autoID();
 
                                    }
                                    catch (Exception ex)
                                    {
                                        MessageBox.Show(ex.Message);
                                    }
 
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("Email Address Is Not Valid ""Email Is Invalid"MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
 
                    }
                    else
                    {
                       MessageBox.Show("Invalid Mobile Number!""Invalid"MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
 
            }
        }
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
 
 
namespace FinoBank_Application
{
    public partial class frmCustomerInformation : Form
    {
 
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
 
        public frmCustomerInformation()
        {
            InitializeComponent();
        }
 
 
        //string gender = "", gender1 = "", marid = "", marid1 = "";
        //SqlCommand cmd;
        //SqlDataReader dr;
        //string type;
        //Clear All the field
 
        //Clear All the field
        private void clear()
        {
            txtAccountNumber.Clear();
            txtCustomertype.Clear();
            txtCustomerName.Clear();
            txtFatherName.Clear();
        }
 
        //display photo
        public Image DisPhoto(byte[] photo)
        {
            MemoryStream ms = new MemoryStream(photo);
            return Image.FromStream(ms);
        }
 
        //display sign
        public Image DisSign(byte[] photo)
        {
            MemoryStream ms = new MemoryStream(photo);
            return Image.FromStream(ms);
        }
 
        //save image for first customer photo
        public byte[] savePhoto1(PictureBox pb)
        {
 
            MemoryStream ms = new MemoryStream();
            pbImage.Image.Save(ms, pb.Image.RawFormat);
            return ms.GetBuffer();
        }
 
        private void btnhidepanel_Click(object sender, EventArgs e)
        {
            panel1.Visible = true;
        }
 
        private void btnPrevious_Click(object sender, EventArgs e)
        {
            panel1.Visible = false;
        }
 
        private void frmCustomerInformation_Load(object sender, EventArgs e)
        {
            panel1.Visible = false;
        }
 
        //save image for second customer photo
        public byte[] savePhoto2(PictureBox pb)
        {
 
            MemoryStream ms = new MemoryStream();
            pbImage1.Image.Save(ms, pb.Image.RawFormat);
            return ms.GetBuffer();
        }
 
        ////save image for first customer sign
        public byte[] saveSign1(PictureBox pb)
        {
 
            MemoryStream ms = new MemoryStream();
            pbSignature.Image.Save(ms, pb.Image.RawFormat);
            return ms.GetBuffer();
        }
        //save image for first customer sign
        public byte[] savesign2(PictureBox pb)
        {
 
            MemoryStream ms = new MemoryStream();
            pbSignature1.Image.Save(ms, pb.Image.RawFormat);
            return ms.GetBuffer();
        }
     }   
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
 
namespace FinoBank_Application
{
    public partial class frmCustomerList : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmCustomerList()
        {
            InitializeComponent();
        }
 
        SqlConnection conn;
        SqlCommand cmd;
        SqlDataReader dr;
        SqlDataAdapter da;
        DataTable dt = new DataTable();
 
 
        //display photo
        public Image DisPhoto(byte[] photo)
        {
            MemoryStream ms = new MemoryStream(photo);
            return Image.FromStream(ms);
        }
 
        //display sign
        public Image DisSign(byte[] photo)
        {
            MemoryStream ms = new MemoryStream(photo);
            return Image.FromStream(ms);
        }
 
        //select selected id from datagrid view
        private double selectId()
        {
            int a = dataGridView1.SelectedCells[0].RowIndex;
 
            double c = Convert.ToInt64(dataGridView1.Rows[a].Cells[0].Value.ToString());
            return c;
        }
 
        private void frmCustomerList_Load(object sender, EventArgs e)
        {
 
            cmbSelect.SelectedIndex = 0;
            dataGridView1.EnableHeadersVisualStyles = false;
 
            conn = new SqlConnection(CS);
            conn.Open();
            da = new SqlDataAdapter("select accno as 'Account No' ,account as 'Account Type' ,acctype as 'Customer Type' , name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where status='" + true + "'", conn);
            //da = new SqlDataAdapter("select * from customer", conn);
            da.Fill(dt);
            dataGridView1.DataSource = dt;
 
            ((DataGridViewImageColumn)dataGridView1.Columns[24]).ImageLayout = DataGridViewImageCellLayout.Stretch;
            ((DataGridViewImageColumn)dataGridView1.Columns[25]).ImageLayout = DataGridViewImageCellLayout.Stretch;
            ((DataGridViewImageColumn)dataGridView1.Columns[46]).ImageLayout = DataGridViewImageCellLayout.Stretch;
            ((DataGridViewImageColumn)dataGridView1.Columns[47]).ImageLayout = DataGridViewImageCellLayout.Stretch;
 
        }
 
 
 
 
 
 
 
 
 
 
 
        private void btnSearch_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            if (cmbSelect.SelectedIndex == 0)
            {
                while (dataGridView1.Rows.Count >= 1)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                dataGridView1.EnableHeadersVisualStyles = false;
                da = new SqlDataAdapter("select accno as 'Account No',account as 'Account Type' ,acctype as 'Customer Type', name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where  status='" + true + "'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (cmbSelect.SelectedIndex == 1)
            {
                while (dataGridView1.Rows.Count >= 1)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                dataGridView1.EnableHeadersVisualStyles = false;
                da = new SqlDataAdapter("select accno as 'Account No',account as 'Account Type' ,acctype as 'Customer Type', name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where accno= '" + txtSearch.Text + "' AND status='" + true + "'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (cmbSelect.SelectedIndex == 2)
            {
                while (dataGridView1.Rows.Count >= 1)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                dataGridView1.EnableHeadersVisualStyles = false;
                da = new SqlDataAdapter("select accno as 'Account No' ,account as 'Account Type' ,acctype as 'Customer Type' , name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where name_f like'" + txtSearch.Text + "%' OR name_s like'" + txtSearch.Text + "%' AND status='" + true + " '", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (cmbSelect.SelectedIndex == 3)
            {
                while (dataGridView1.Rows.Count >= 1)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                dataGridView1.EnableHeadersVisualStyles = false;
                da = new SqlDataAdapter("select accno as 'Account No',account as 'Account Type' ,acctype as 'Customer Type', name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where acctype='" + txtSearch.Text + "' AND status='" + true + "'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (cmbSelect.SelectedIndex == 4)
            {
                while (dataGridView1.Rows.Count >= 1)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                dataGridView1.EnableHeadersVisualStyles = false;
                da = new SqlDataAdapter("select accno as 'Account No' ,account as 'Account Type' ,acctype as 'Customer Type' , name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where city_f='" + txtSearch.Text + "' OR city_s='" + txtSearch.Text + "' AND status='" + true + "'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (cmbSelect.SelectedIndex == 5)
            {
                while (dataGridView1.Rows.Count >= 1)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                dataGridView1.EnableHeadersVisualStyles = false;
                da = new SqlDataAdapter("select accno as 'Account No',account as 'Account Type' ,acctype as 'Customer Type' , name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where distic_f='" + txtSearch.Text + "' OR distic_s='" + txtSearch.Text + "' AND status='" + true + "'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (cmbSelect.SelectedIndex == 6)
            {
                while (dataGridView1.Rows.Count >= 1)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                dataGridView1.EnableHeadersVisualStyles = false;
                da = new SqlDataAdapter("select accno as 'Account No' ,account as 'Account Type' ,acctype as 'Customer Type' , name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where state_f='" + txtSearch.Text + "' OR state_s='" + txtSearch.Text + "' AND status='" + true + "'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (cmbSelect.SelectedIndex == 7)
            {
                while (dataGridView1.Rows.Count >= 1)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                dataGridView1.EnableHeadersVisualStyles = false;
                da = new SqlDataAdapter("select accno as 'Account No' ,account as 'Account Type' ,acctype as 'Customer Type' , name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where gender_f='" + txtSearch.Text + "' AND status='" + true + "'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (cmbSelect.SelectedIndex == 8)
            {
                while (dataGridView1.Rows.Count >= 1)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                dataGridView1.EnableHeadersVisualStyles = false;
                da = new SqlDataAdapter("select accno as 'Account No' ,account as 'Account Type' ,acctype as 'Customer Type' , name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where account='" + txtSearch.Text + "' AND status='" + true + "'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (cmbSelect.SelectedIndex == 9)
            {
                while (dataGridView1.Rows.Count >= 1)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                dataGridView1.EnableHeadersVisualStyles = false;
                da = new SqlDataAdapter("select accno as 'Account No' ,account as 'Account Type' ,acctype as 'Customer Type' , name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where mobile_f='" + txtSearch.Text + "' OR mobile_s='" + txtSearch.Text + "' AND status='" + true + "'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (cmbSelect.SelectedIndex == 10)
            {
                while (dataGridView1.Rows.Count >= 1)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                dataGridView1.EnableHeadersVisualStyles = false;
                da = new SqlDataAdapter("select accno as 'Account No' ,account as 'Account Type' ,acctype as 'Customer Type' , name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where email_f='" + txtSearch.Text + "' OR email_s='" + txtSearch.Text + "' AND status='" + true + "'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (cmbSelect.SelectedIndex == 11)
            {
                while (dataGridView1.Rows.Count >= 1)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                dataGridView1.EnableHeadersVisualStyles = false;
                da = new SqlDataAdapter("select accno as 'Account No' ,account as 'Account Type' ,acctype as 'Customer Type' , name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where fname_f like'" + txtSearch.Text + "%' OR fname_s like'" + txtSearch.Text + "%' AND status='" + true + "'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (cmbSelect.SelectedIndex == 12)
            {
                while (dataGridView1.Rows.Count >= 1)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                dataGridView1.EnableHeadersVisualStyles = false;
                da = new SqlDataAdapter("select accno as 'Account No' ,account as 'Account Type' ,acctype as 'Customer Type' , name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where mname_f like'" + txtSearch.Text + "%' OR mname_s like'" + txtSearch.Text + "%' AND status='" + true + "'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            if (cmbSelect.SelectedIndex == 13)
            {
                while (dataGridView1.Rows.Count >= 1)
                {
                    dataGridView1.Rows.RemoveAt(0);
                }
                dataGridView1.EnableHeadersVisualStyles = false;
                da = new SqlDataAdapter("select accno as 'Account No' ,account as 'Account Type' ,acctype as 'Customer Type' , name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where maritial_f='" + txtSearch.Text + "' OR maritial_s='" + txtSearch.Text + "' AND status='" + true + "'", conn);
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
 
 
        }
 
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            while (dataGridView1.RowCount > 0)
            {
                dataGridView1.Rows.RemoveAt(0);
            }
            txtSearch.Clear();
            cmbSelect.SelectedIndex = 0;
            dataGridView1.EnableHeadersVisualStyles = false;
            da = new SqlDataAdapter("select accno as 'Account No' ,account as 'Account Type' ,acctype as 'Customer Type' , name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where status='" + true + "'", conn);
            //da = new SqlDataAdapter("select * from customer",db.cn);
            da.Fill(dt);
            dataGridView1.DataSource = dt;
        }
 
        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
            string type = "";
            //frmCustomerInformation FrmCustomerInformation = new frmCustomerInformation();
            frmCustomerInformation FrmCustomerInformation = new frmCustomerInformation();
            double id = selectId();
            cmd = new SqlCommand("select acctype from customer where accno=" + id + "", conn);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                type = dr[0].ToString();
            }
            dr.Close();
 
            if (type == "single")
            {
                FrmCustomerInformation.panel1.Visible = false;
                cmd = new SqlCommand("select * from customer where accno='" + id + "'", conn);
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
 
                    FrmCustomerInformation.txtAccountNumber.Text = dr[0].ToString();
                    FrmCustomerInformation.txtCustomertype.Text = dr[1].ToString();
                    FrmCustomerInformation.txtAccuntType.Text = dr[2].ToString();
                    FrmCustomerInformation.txtCustomerName.Text = dr[3].ToString();
                    FrmCustomerInformation.txtFatherName.Text = dr[4].ToString();
                    FrmCustomerInformation.txtMotherName.Text = dr[5].ToString();
                    FrmCustomerInformation.txtDateofBirth.Text = dr[6].ToString();
                    FrmCustomerInformation.txtGender.Text = dr[7].ToString();
                    FrmCustomerInformation.MsktxtAdharNumber.Text = dr[8].ToString();
                    FrmCustomerInformation.txtPanNumber.Text = dr[9].ToString();
                    FrmCustomerInformation.txtQualification.Text = dr[10].ToString();
                    FrmCustomerInformation.txtNationality.Text = dr[11].ToString();
                    FrmCustomerInformation.txtState.Text = dr[12].ToString();
                    FrmCustomerInformation.txtDistrict.Text = dr[13].ToString();
                    FrmCustomerInformation.txtTaluka.Text = dr[14].ToString();
                    FrmCustomerInformation.txtCity.Text = dr[15].ToString();
                    FrmCustomerInformation.MsktxtPinCode.Text = dr[16].ToString();
                    FrmCustomerInformation.txtAddress.Text = dr[17].ToString();
                    FrmCustomerInformation.MsktxtMobileNumber.Text = dr[18].ToString();
                    FrmCustomerInformation.txtEmailID.Text = dr[19].ToString();
                    FrmCustomerInformation.txtMaritalStatus.Text = dr[20].ToString();
                    FrmCustomerInformation.txtReligion.Text = dr[21].ToString();
                    FrmCustomerInformation.txtIncome.Text = dr[22].ToString();
                    FrmCustomerInformation.pbSignature.Image = DisSign((byte[])dr[25]);
                    FrmCustomerInformation.pbImage.Image = DisPhoto((byte[])dr[26]);
                    FrmCustomerInformation.ShowDialog();
                    
                }
                dr.Close();
 
 
            }
            else
            {
 
                FrmCustomerInformation.panel1.Visible = true;
                cmd = new SqlCommand("select * from customer where accno='" + id + "'", conn);
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
 
                    FrmCustomerInformation.txtAccountNumber.Text = dr[0].ToString();
                    FrmCustomerInformation.txtCustomertype.Text = dr[1].ToString();
                    FrmCustomerInformation.txtAccuntType.Text = dr[2].ToString();
                    FrmCustomerInformation.txtCustomerName.Text = dr[3].ToString();
                    FrmCustomerInformation.txtFatherName.Text = dr[4].ToString();
                    FrmCustomerInformation.txtMotherName.Text = dr[5].ToString();
                    FrmCustomerInformation.txtDateofBirth.Text = dr[6].ToString();
                    FrmCustomerInformation.txtGender.Text = dr[7].ToString();
                    FrmCustomerInformation.MsktxtAdharNumber.Text = dr[8].ToString();
                    FrmCustomerInformation.txtPanNumber.Text = dr[9].ToString();
                    FrmCustomerInformation.txtQualification.Text = dr[10].ToString();
                    FrmCustomerInformation.txtNationality.Text = dr[11].ToString();
                    FrmCustomerInformation.txtState.Text = dr[12].ToString();
                    FrmCustomerInformation.txtDistrict.Text = dr[13].ToString();
                    FrmCustomerInformation.txtTaluka.Text = dr[14].ToString();
                    FrmCustomerInformation.txtCity.Text = dr[15].ToString();
                    FrmCustomerInformation.MsktxtPinCode.Text = dr[16].ToString();
                    FrmCustomerInformation.txtAddress.Text = dr[17].ToString();
                    FrmCustomerInformation.MsktxtMobileNumber.Text = dr[18].ToString();
                    FrmCustomerInformation.txtEmailID.Text = dr[19].ToString();
                    FrmCustomerInformation.txtMaritalStatus.Text = dr[20].ToString();
                    FrmCustomerInformation.txtReligion.Text = dr[21].ToString();
                    FrmCustomerInformation.txtIncome.Text = dr[22].ToString();
                    FrmCustomerInformation.pbSignature.Image = DisSign((byte[])dr[25]);
                    FrmCustomerInformation.pbImage.Image = DisPhoto((byte[])dr[26]);
 
 
                    //Second Customer
                    FrmCustomerInformation.txtCustomerName1.Text = dr[27].ToString();
                    FrmCustomerInformation.txtFatherName1.Text = dr[28].ToString();
                    FrmCustomerInformation.txtMotherName1.Text = dr[29].ToString();
                    FrmCustomerInformation.txtDateofBirth1.Text = dr[30].ToString();
                    FrmCustomerInformation.txtGender1.Text = dr[31].ToString();
                    FrmCustomerInformation.MsktxtAdharNumber1.Text = dr[32].ToString();
                    FrmCustomerInformation.txtPanNumber2.Text = dr[33].ToString();
                    FrmCustomerInformation.txtQualification1.Text = dr[34].ToString();
                    FrmCustomerInformation.txtNationality1.Text = dr[35].ToString();
                    FrmCustomerInformation.txtState1.Text = dr[36].ToString();
                    FrmCustomerInformation.txtDistrict1.Text = dr[37].ToString();
                    FrmCustomerInformation.txtTaluka1.Text = dr[38].ToString();
                    FrmCustomerInformation.txtCity1.Text = dr[39].ToString();
                    FrmCustomerInformation.MsktxtPinCode1.Text = dr[40].ToString();
                    FrmCustomerInformation.txtAddress1.Text = dr[41].ToString();
                    FrmCustomerInformation.MsktxtMobileNumber1.Text = dr[42].ToString();
                    FrmCustomerInformation.txtEmailID1.Text = dr[43].ToString();
                    FrmCustomerInformation.txtMaritalStatus1.Text = dr[44].ToString();
                    FrmCustomerInformation.txtReligion1.Text = dr[45].ToString();
                    FrmCustomerInformation.txtIncome1.Text = dr[46].ToString();
                    FrmCustomerInformation.pbSignature1.Image = DisSign((byte[])dr[47]);
                    FrmCustomerInformation.pbImage1.Image = DisPhoto((byte[])dr[48]);
                    FrmCustomerInformation.ShowDialog();
 
                }
 
                dr.Close();
 
            }
 
 
        }
 
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
           /* cmbSelect.SelectedIndex = 0;
            dataGridView1.EnableHeadersVisualStyles = false;
 
            conn = new SqlConnection(CS);
            conn.Open();
            da = new SqlDataAdapter("select accno as 'Account No' ,account as 'Account Type' ,acctype as 'Customer Type' , name_f as 'Customer Name' , fname_f as 'Father Name', mname_f as 'Mother Name', dob_f as 'DOB' , gender_f as 'Gender', aadhar_f as 'Aadhar Number' , pan_f as 'Pan number', qualifi_f as 'Qualification' , nation_f as 'Nation' , state_f as 'State' , distic_f as 'Distic' , taluka_f as 'Taluka' , city_f as 'City' , pin_f as 'Pin Code' , address as 'Address' ,mobile_f as 'Mobile Number' , email_f as 'Email' , maritial_f as 'Meritial Status' , relgion_f as 'Reigion' , income_f as 'Income' , joindate_f as 'Join Date' , sign_f as 'Signature' , photo_f as 'Image', name_s as 'Customer Name' , fname_s as 'Father Name', mname_s as 'Mother Name', dob_s as 'DOB' , gender_s as 'Gender', aadhar_s as 'Aadhar Number' , pan_s as 'Pan number' ,qualifi_s as 'Qualification' , nation_s as 'Nation' , state_s as 'State' , distic_s as 'Distic' , taluka_s as 'Taluka' , city_s as 'City' , pin_s as 'Pin Code' , address_s as 'Address' , mobile_s as 'Mobile Number' ,email_s as 'Email' , maritial_s as 'Meritial Status' , religion_s as 'Reigion' , income_s as 'Income'  , sign_s as 'Signature' , photo_s as 'Image'   from customer where mname_f like'" + txtSearch.Text + "%' OR mname_s like'" + txtSearch.Text + "%' AND status='" + true + "'", conn);
            //da = new SqlDataAdapter("select * from customer", conn);
            da.Fill(dt);
            dataGridView1.DataSource = dt;
 
            ((DataGridViewImageColumn)dataGridView1.Columns[24]).ImageLayout = DataGridViewImageCellLayout.Stretch;
            ((DataGridViewImageColumn)dataGridView1.Columns[25]).ImageLayout = DataGridViewImageCellLayout.Stretch;
            ((DataGridViewImageColumn)dataGridView1.Columns[46]).ImageLayout = DataGridViewImageCellLayout.Stretch;
            ((DataGridViewImageColumn)dataGridView1.Columns[47]).ImageLayout = DataGridViewImageCellLayout.Stretch;
            */
        }
    }
}
 

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
 
namespace FinoBank_Application
{
    public partial class frmDeposit : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
 
        public frmDeposit()
        {
            InitializeComponent();
        }
 
        SqlConnection conn;
        SqlCommand cmd;
        SqlDataReader dr;
 
        string time;
 
        private void frmDeposit_Load(object sender, EventArgs e)
        {
            lblloader.Visible = false;
            txtDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
            time = DateTime.Now.ToString("hh:mm:ss");
            autoId();
        }
 
 
        //Method to convert number into words
        public string ConvertNumbertoWords(long number)
        {
            if (number.ToString() == ""return "Zero";
            if (number == 0) return "Zero";
            if (number < 0) return "minus " + ConvertNumbertoWords(Math.Abs(number));
            string words = "";
 
            if ((number / 10000000) > 0)
            {
                words += ConvertNumbertoWords(number / 10000000) + " Corer ";
                number %= 10000000;
            }
            if ((number / 100000) > 0)
            {
                words += ConvertNumbertoWords(number / 100000) + " Lakes ";
                number %= 100000;
            }
            if ((number / 1000) > 0)
            {
                words += ConvertNumbertoWords(number / 1000) + " Thousand ";
                number %= 1000;
            }
            if ((number / 100) > 0)
            {
                words += ConvertNumbertoWords(number / 100) + " Hundred ";
                number %= 100;
            }
            //if ((number / 10) > 0)  
            //{  
            // words += ConvertNumbertoWords(number / 10) + " RUPEES ";  
            // number %= 10;  
            //}  
            if (number > 0)
            {
                if (words != "") words += "And ";
                var unitsMap = new[]
        {
            "Zero""One""Two""Three""Four""Five""Six""Seven""Eight""Nine""Ten""Eleven""Twelve""Thirteen""Fourteen""Fifteen""Sixtenn""Seventeen""Eighteen""Ninteen"
        };
                var tensMap = new[]
        {
            "Zero""Ten""Twenty""Thirty""Fourty""Fifty""Sixty""Seventy""Eighty""Ninety"
        };
                if (number < 20) words += unitsMap[number];
                else
                {
                    words += tensMap[number / 10];
                    if ((number % 10) > 0) words += " " + unitsMap[number % 10];
                }
            }
            return words;
 
        }
 
        //Generate autoID in deposit
        private void autoId()
        {
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("select MAX(id) from deposite", conn);
            string id = cmd.ExecuteScalar().ToString();
            if (id != string.Empty)
            {
                double did = Convert.ToDouble(id);
                //did++;
                did = did + 1;
                txtDepositeId.Text = did.ToString();
            }
            else
            {
                txtDepositeId.Text = "1";
            }
        }
 
        //display photo
        public Image DisPhoto(byte[] photo)
        {
            MemoryStream ms = new MemoryStream(photo);
            return Image.FromStream(ms);
        }
 
        //display sign
        public Image DisSign(byte[] photo)
        {
            MemoryStream ms = new MemoryStream(photo);
            return Image.FromStream(ms);
        }
 
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (txtAccountNumber.Text == string.Empty)
            {
                MessageBox.Show("Account number can't be blank!""Error"MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                //select account type
                conn = new SqlConnection(CS);
                conn.Open();
                cmd = new SqlCommand("select acctype from customer where accno='" + txtAccountNumber.Text + "' AND  status='" + true + "'", conn);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    txtCustomerType.Text = dr[0].ToString();
                }
                else
                {
                    MessageBox.Show("Account Number Not Associate With This Bank""Error"MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                dr.Close();
 
                string avilbl = balance(txtAccountNumber.Text);
 
                cmd = new SqlCommand("select account,name_f,name_s,sign_f,photo_f,sign_s,photo_s,email_f,email_s from customer where accno='" + txtAccountNumber.Text + "' and status='" + true + "'", conn);
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    if (txtCustomerType.Text == "single")
                    {
                        pbPhoto1.Visible = false;
                        pbSign1.Visible = false;
                        txtAccountType.Text = dr[0].ToString();
                        txtFirstAccountHolder.Text = dr[1].ToString();
                        txtCustomerType.Text = "single";
                        //txtCustomerType.Text = dr[2].ToString();
                        pbSign.Image = DisSign((byte[])dr[3]);
                        pbPhoto.Image = DisPhoto((byte[])dr[4]);
                        txtAccountBalance.Text = avilbl;
                        //email1 = dr[7].ToString();
 
                    }
 
                    if (txtCustomerType.Text == "joint")
                    {
                        pbPhoto1.Visible = true;
                        pbSign1.Visible = true;
                        txtAccountType.Text = dr[0].ToString();
                        txtFirstAccountHolder.Text = dr[1].ToString();
                        txtCustomerType.Text = dr[2].ToString();
                        txtCustomerType.Text = "joint";
                        pbSign.Image = DisSign((byte[])dr[3]);
                        pbPhoto.Image = DisPhoto((byte[])dr[4]);
 
                        //Second person Details
                        txtSecondAccountHolder.Text = dr[2].ToString();
                        pbSign1.Image = DisSign((byte[])dr[5]);
                        pbPhoto1.Image = DisPhoto((byte[])dr[6]);
                        txtAccountBalance.Text = avilbl;
 
                    }
 
 
                }
                dr.Close();
 
            }
        }
 
 
        public string balance(string acno)
        {
            //get avliable balance from databse
            conn = new SqlConnection(CS);
            conn.Open();
            string balance = "";
            cmd = new SqlCommand("select balance from balance where accno='" + acno + "' ", conn);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                balance = dr[0].ToString();
 
            }
            else
            {
                balance = "0";
            }
            dr.Close();
            return balance;
        }
 
 
 
        private void btnClear_Click(object sender, EventArgs e)
        {
            Clear();
        }
 
        public void Clear()
        {
            txtAccountNumber.Clear();
            txtFirstAccountHolder.Clear();
            txtSecondAccountHolder.Clear();
            txtAccountType.Clear();
            txtAccountBalance.Clear();
            txtAmoutDeposit.Clear();
            pbPhoto.Image = null;
            pbSign.Image = null;
            pbSign1.Image = null;
            pbPhoto1.Image = null;
        }
 
 
        //bank baalnce
        private double BankBalance()
        {
            double bal = 0;
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("select * from BankBalance", conn);
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                bal = Convert.ToDouble(dr[0].ToString());
            }
            dr.Close();
            return bal;
        }
 
        private void btnDeposite_Click(object sender, EventArgs e)
        {
            if (txtAmoutDeposit.Text == string.Empty)
            {
                MessageBox.Show("Please enter the amount to be deposited!""Info"MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
 
 
 
                try
                {
                    conn = new SqlConnection(CS);
                    conn.Open();
 
                    string s = balance(txtAccountNumber.Text);
                    double money = Convert.ToDouble(txtAmoutDeposit.Text);
                    double avlble = Convert.ToDouble(s) + money;
 
                    //insert into deposite
                    cmd = new SqlCommand("insert into deposite values (@id,@no,@date,@money,@intext,@detail)", conn);
                    cmd.Parameters.AddWithValue("id", txtDepositeId.Text);
                    cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);
                    cmd.Parameters.AddWithValue("date", txtDate.Text);
                    cmd.Parameters.AddWithValue("money", txtAmoutDeposit.Text);
                    cmd.Parameters.AddWithValue("intext""Sample");
                    cmd.Parameters.AddWithValue("detail", txtDetails.Text);
                    cmd.ExecuteNonQuery();
 
 
                    //insert into bank balance
                    double bb = BankBalance();
                    double newbb = bb + money;
                    cmd = new SqlCommand("update BankBalance set balance =" + newbb + "", conn);
                    cmd.ExecuteNonQuery();
 
 
                    //insert into passbook
                    cmd = new SqlCommand("insert into passbook (accno,date,info,deposite,avlabl,time) values (@no,@date,@info,@deposite,@avlabl,@time)", conn);
                    cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);
                    cmd.Parameters.AddWithValue("date", txtDate.Text);
                    cmd.Parameters.AddWithValue("info", txtDetails.Text);
                    cmd.Parameters.AddWithValue("deposite", txtAmoutDeposit.Text);
                    cmd.Parameters.AddWithValue("avlabl", avlble.ToString());
                    cmd.Parameters.AddWithValue("time", time);
                    cmd.ExecuteNonQuery();
 
 
                    //insert/updated into balance
                    cmd = new SqlCommand("update balance set balance='" + Convert.ToInt32(avlble) + "' where accno='" + txtAccountNumber.Text + "'", conn);
                    cmd.ExecuteNonQuery();
 
 
                    //insert into Transaction
                    cmd = new SqlCommand("insert into trans_info values(@date,@time,@accno,@type,@ammount)", conn);
                    cmd.Parameters.AddWithValue("date"DateTime.Now.ToString("dd/MM/yyyy"));
                    cmd.Parameters.AddWithValue("time", time);
                    cmd.Parameters.AddWithValue("accno", txtAccountNumber.Text);
                    cmd.Parameters.AddWithValue("type""Deposit Money");
                    cmd.Parameters.AddWithValue("ammount", txtAmoutDeposit.Text);
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                lblloader.Visible = true;
 
                MessageBox.Show("Deposite Suceess Please Print Receipt""Sucess"MessageBoxButtons.OK, MessageBoxIcon.Information);
 
 
                //print reciept
                DataTable dt = new DataTable();
                frmReportForm r = new frmReportForm();
                r.crystalReportViewer1.ReportSource = null;
                r.crystalReportViewer1.Refresh();
                dt.Clear();
                SqlDataAdapter da = new SqlDataAdapter("select * from deposite where accono='" + txtAccountNumber.Text + "' AND id='" + txtDepositeId.Text + "'", conn);
                da.Fill(dt);
                Reports.crDeposit d = new Reports.crDeposit();
                d.Database.Tables["deposite"].SetDataSource(dt);
                r.crystalReportViewer1.ReportSource = d;
                r.crystalReportViewer1.Refresh();
                r.Show();
                Clear();
                autoId();
            }
        }
 
        private void txtAmoutDeposit_TextChanged(object sender, EventArgs e)
        {
            if (txtAmoutDeposit.Text == "")
            {
                lblMoneyToWord.Text = "";
            }
            else
            {
                long am = Convert.ToInt64(txtAmoutDeposit.Text);
                lblMoneyToWord.Text = ConvertNumbertoWords(am);
            }
        }
    }
}

 

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Configuration;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using System.Data.SqlClient;

using System.Text.RegularExpressions;

using System.IO;

using System.Net;

using System.Net.Mail;

 

 

 

namespace FinoBank_Application

{

    public partial class frmEditCustomerDetails : Form

    {

 

        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;

 

        public frmEditCustomerDetails()

        {

            InitializeComponent();

        }

 

 

        frmReportForm r = new frmReportForm();

       // string time;

        int img1 = 1, img2 = 1, sign1 = 1, sign2 = 1;

 

        SqlConnection conn;

        SqlCommand cmd;

        //SqlDataAdapter da;

        SqlDataReader dr;

        DataTable dt = new DataTable();

        bool joint = false;

        // bool email = true;

        bool single = false;

        string gender, gender1, marid1, marid, type, accno;

 

 

 

        protected void clear()

        {

            rdoMale.Checked = false;

            rdoFemale.Checked = false;

            rdoOther.Checked = false;

            rdoMarried.Checked = false;

            rdoUnmarried.Checked = false;

            rdoAnnulated.Checked = false;

            rdoDivorced.Checked = false;

            cmbDistrict.SelectedIndex = 0;

            cmbNationality.SelectedIndex = 0;

            cmbQualification.SelectedIndex = 0;

            cmbState.SelectedIndex = 0;

            MsktxtAdharNumber.Clear();

            txtCity.Clear();

            txtCustomerName.Clear();

            txtDateofBirth.Clear();

            txtEmailID.Clear();

            txtFatherName.Clear();

            txtIncome.Clear();

            txtPanNumber.Clear();

            txtReligion.Clear();

            txtTaluka.Clear();

            txtMotherName.Clear();

            txtAddress.Clear();

            txtDiposit.Clear();

            MsktxtPinCode.Clear();

            MsktxtMobileNumber.Clear();

            pbImage.Image = null;

            pbSignature.Image = null;

            

            //Second fields/Panel

            rdoMale1.Checked = false;

            rdoFemale1.Checked = false;

            rdoOther1.Checked = false;

            rdoMarried1.Checked = false;

            rdoUnmarried1.Checked = false;

            rdoAnnulated1.Checked = false;

            rdoDivorced1.Checked = false;

            cmbDistrict1.SelectedIndex = 0;

            cmbNationality1.SelectedIndex = 0;

            cmbQualification1.SelectedIndex = 0;

            cmbState1.SelectedIndex = 0;

            MsktxtAdharNumber1.Clear();

            txtCity1.Clear();

            txtCustomerName1.Clear();

            txtDateofBirth1.Clear();

            txtEmailID1.Clear();

            txtFatherName1.Clear();

            txtIncome1.Clear();

            txtPanNumber1.Clear();

            txtReligion1.Clear();

            txtTaluka1.Clear();

            txtMotherName1.Clear();

            txtAddress1.Clear();

            MsktxtPinCode1.Clear();

            MsktxtMobileNumber1.Clear();

            pbImage1.Image = null;

            pbSignature1.Image = null;

        }

 

        //check the age of customer

        public int checkAgeSingle()

        {

            int year = Convert.ToInt32(dateTimePicker1.Value.Year);

            int year1 = Convert.ToInt32(DateTime.Now.Year);

            int age = year1 - year;

            return age;

        }

        public int checkAgeJoint()

        {

            int year = Convert.ToInt32(dateTimePicker2.Value.Year);

            int year1 = Convert.ToInt32(DateTime.Now.Year);

            int age = year1 - year;

            return age;

        }

 

        //Display photo

        public Image DisPhoto(byte[] photo)

        {

            MemoryStream ms = new MemoryStream(photo);

            return Image.FromStream(ms);

        }

 

        //Display sign

        public Image DisSign(byte[] photo)

        {

            MemoryStream ms = new MemoryStream(photo);

            return Image.FromStream(ms);

        }

 

 

 

        private void btnPrevious_Click(object sender, EventArgs e)

        {

            panel1.Visible = false;

        }

 

 

 

        //save image for first customer photo

        public byte[] savePhoto1(PictureBox pb)

        {

 

            MemoryStream ms = new MemoryStream();

            pbImage.Image.Save(ms, pb.Image.RawFormat);

            return ms.GetBuffer();

        }

        //save image for second customer photo

        public byte[] savePhoto2(PictureBox pb)

        {

 

            MemoryStream ms = new MemoryStream();

            pbImage1.Image.Save(ms, pb.Image.RawFormat);

            return ms.GetBuffer();

        }

 

        ////save image for first customer sign

        public byte[] saveSign1(PictureBox pb)

        {

 

            MemoryStream ms = new MemoryStream();

            pbSignature.Image.Save(ms, pb.Image.RawFormat);

            return ms.GetBuffer();

        }

        //save image for first customer sign

        public byte[] saveSign2(PictureBox pb)

        {

 

            MemoryStream ms = new MemoryStream();

            pbSignature1.Image.Save(ms, pb.Image.RawFormat);

            return ms.GetBuffer();

        }

 

 

 

        // Select all data and fill in all the fields

        private void btnSearch_Click(object sender, EventArgs e)

        {

            if (txtAccountNumber.Text == string.Empty)

            {

                MessageBox.Show("Please enter account number! ""Info"MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

            else

            {

                conn = new SqlConnection(CS);

                conn.Open();

                cmd = new SqlCommand("select * from customer where accno='" + Convert.ToInt64(txtAccountNumber.Text) + "' AND status='" + true + "'", conn);

                dr = cmd.ExecuteReader();

                while (dr.Read())

                {

                    if (type == "single")

                    {

                        panel1.Visible = false;

                        btnhidepanel.Visible = false;

                        txtCustomerName.Text = dr[3].ToString();

                        txtFatherName.Text = dr[4].ToString();

                        txtMotherName.Text = dr[5].ToString();

                        txtDateofBirth.Text = dr[6].ToString();

                        if (dr["gender_f"].ToString() == "male")

                        {

                            rdoMale.Checked = true;

                        }

                        else if (dr["gender_f"].ToString() == "female")

                        {

                            rdoFemale.Checked = true;

                        }

                        else

                        {

                            rdoOther.Checked = true;

                        }

                        MsktxtAdharNumber.Text = dr[8].ToString();

                        txtPanNumber.Text = dr[9].ToString();

                        cmbQualification.SelectedItem = dr[10].ToString();

                        cmbNationality.SelectedItem = dr[11].ToString();

                        cmbState.SelectedItem = dr[12].ToString();

                        cmbDistrict.SelectedItem = dr[13].ToString();

                        txtTaluka.Text = dr[14].ToString();

                        txtCity.Text = dr[15].ToString();

                        MsktxtPinCode.Text = dr[16].ToString();

                        txtAddress.Text = dr[17].ToString();

                        MsktxtMobileNumber.Text = dr[18].ToString();

                        txtEmailID.Text = dr[19].ToString();

                        if (dr["maritial_f"].ToString() == "maried")

                        {

                            rdoMarried.Checked = true;

                        }

                        else if (dr["maritial_f"].ToString() == "UnMaried")

                        {

                            rdoUnmarried.Checked = true;

                        }

                        else if (dr["maritial_f"].ToString() == "Divorced")

                        {

                            rdoUnmarried.Checked = true;

                        }

                        else

                        {

                            rdoAnnulated.Checked = true;

                        }

                        txtReligion.Text = dr[21].ToString();

                        txtIncome.Text = dr[22].ToString();

                        pbImage.Image = DisSign((byte[])dr[26]);

                        pbSignature.Image = DisPhoto((byte[])dr[25]);

 

                    }

                    else

                    {

                        btnhidepanel.Visible = true;

                        btnPrevious.Visible = true;

                        txtCustomerName.Text = dr[3].ToString();

                        txtFatherName.Text = dr[4].ToString();

                        txtMotherName.Text = dr[5].ToString();

                        txtDateofBirth.Text = dr[6].ToString();

                        if (dr["gender_f"].ToString() == "male")

                        {

                            rdoMale.Checked = true;

                        }

                        else if (dr["gender_f"].ToString() == "female")

                        {

                            rdoFemale.Checked = true;

                        }

                        else

                        {

                            rdoOther.Checked = true;

                        }

                        MsktxtAdharNumber.Text = dr[8].ToString();

                        txtPanNumber.Text = dr[9].ToString();

                        cmbQualification.SelectedItem = dr[10].ToString();

                        cmbNationality.SelectedItem = dr[11].ToString();

                        cmbState.SelectedItem = dr[12].ToString();

                        cmbDistrict.SelectedItem = dr[13].ToString();

                        txtTaluka.Text = dr[14].ToString();

                        txtCity.Text = dr[15].ToString();

                        MsktxtPinCode.Text = dr[16].ToString();

                        txtAddress.Text = dr[17].ToString();

                        MsktxtMobileNumber.Text = dr[18].ToString();

                        txtEmailID.Text = dr[19].ToString();

                        if (dr["maritial_f"].ToString() == "maried")

                        {

                            rdoMarried.Checked = true;

                        }

                        else if (dr["maritial_f"].ToString() == "UnMaried")

                        {

                            rdoUnmarried.Checked = true;

                        }

                        else if (dr["maritial_f"].ToString() == "Divorced")

                        {

                            rdoUnmarried.Checked = true;

                        }

                        else

                        {

                            rdoAnnulated.Checked = true;

                        }

                        txtReligion.Text = dr[21].ToString();

                        txtIncome.Text = dr[22].ToString();

                        pbImage.Image = DisSign((byte[])dr[26]);

                        pbSignature.Image = DisPhoto((byte[])dr[25]);

 

                        //Second person details to visible 

                        txtCustomerName1.Text = dr[27].ToString();

                        txtFatherName1.Text = dr[28].ToString();

                        txtMotherName1.Text = dr[29].ToString();

                        txtDateofBirth1.Text = dr[30].ToString();

                        if (dr["gender_s"].ToString() == "male")

                        {

                            rdoMale1.Checked = true;

                        }

                        else if (dr["gender_s"].ToString() == "female")

                        {

                            rdoFemale1.Checked = true;

                        }

                        else

                        {

                            rdoOther1.Checked = true;

                        }

                        MsktxtAdharNumber1.Text = dr[32].ToString();

                        txtPanNumber1.Text = dr[33].ToString();

                        cmbQualification1.SelectedItem = dr["qualifi_s"].ToString();

                        cmbNationality1.SelectedItem = dr[35].ToString();

                        cmbState1.SelectedItem = dr[36].ToString();

                        cmbDistrict1.SelectedItem = dr["distic_s"].ToString();

                        txtTaluka1.Text = dr[38].ToString();

                        txtCity1.Text = dr[49].ToString();

                        MsktxtPinCode1.Text = dr[40].ToString();

                        txtAddress1.Text = dr[41].ToString();

                        MsktxtMobileNumber1.Text = dr[42].ToString();

                        txtEmailID1.Text = dr[43].ToString();

                        if (dr["maritial_s"].ToString() == "maried")

                        {

                            rdoMarried1.Checked = true;

                        }

                        else if (dr["maritial_s"].ToString() == "UnMaried")

                        {

                            rdoUnmarried1.Checked = true;

                        }

                        else if (dr["maritial_s"].ToString() == "Divorced")

                        {

                            rdoUnmarried1.Checked = true;

                        }

                        else

                        {

                            rdoAnnulated1.Checked = true;

                        }

                        txtReligion1.Text = dr[45].ToString();

                        txtIncome1.Text = dr[46].ToString();

                        pbImage1.Image = DisSign((byte[])dr[48]);

                        pbSignature1.Image = DisPhoto((byte[])dr[47]);

 

 

                    }

 

                }

 

            }

        }

 

        private void frmEditCustomerDetails_Load(object sender, EventArgs e)

        {

            panel1.Visible = false;

            btnhidepanel.Visible = false;     

        }

 

 

 

        private void button4_Click(object sender, EventArgs e)

        {

            this.Close();

        }

 

 

        private void Mask_Enter(object sender, EventArgs e)

        {

            MaskedTextBox mt = (MaskedTextBox)sender;

            mt.BackColor = Color.Yellow;

 

        }

 

        private void Mask_Leave(object sender, EventArgs e)

        {

            MaskedTextBox mt = (MaskedTextBox)sender;

            mt.BackColor = Color.White;

 

            //MaskedTextBox mt = new MaskedTextBox();

            //mt.BackColor = Color.White;

 

        }

 

        private void Combo_Enter(object sender, EventArgs e)

        {

            ComboBox cb = (ComboBox)sender;

            cb.BackColor = Color.Lime ;

        }

 

        private void Combo_Leave(object sender, EventArgs e)

        {

            ComboBox cb = (ComboBox)sender;

            cb.BackColor = Color.White;

        }

 

 

        //Select image of customer 1

        private void btnUploadImgae_Click(object sender, EventArgs e)

        {

            OpenFileDialog d = new OpenFileDialog();

            d.Title = "Select Image";

            d.Filter = " (*.jpg;*.png;*.jpeg) | *.jpg;*.png;*.jpeg";

 

            DialogResult dr = new DialogResult();

            dr = d.ShowDialog();

            if (dr == DialogResult.OK)

            {

                img1 = 0;

                pbImage.Image = new Bitmap(d.FileName);

            }

        }

 

        //Select sign of customer 1

        private void btnUploadSigns_Click(object sender, EventArgs e)

        {

            OpenFileDialog d = new OpenFileDialog();

            d.Title = "Select Image";

            d.Filter = " (*.jpg;*.png;*.jpeg) | *.jpg;*.png;*.jpeg";

 

            DialogResult dr = new DialogResult();

            dr = d.ShowDialog();

            if (dr == DialogResult.OK)

            {

                sign1 = 0;

                pbSignature.Image = new Bitmap(d.FileName);

 

            }

 

        }

 

        //Select image of customer 2

        private void btnUploadImgae1_Click(object sender, EventArgs e)

        {

            OpenFileDialog d = new OpenFileDialog();

            d.Title = "Select Image";

            d.Filter = " (*.jpg;*.png;*.jpeg) | *.jpg;*.png;*.jpeg";

 

            DialogResult dr = new DialogResult();

            dr = d.ShowDialog();

            if (dr == DialogResult.OK)

            {

                img2 = 0;

                pbImage1.Image = new Bitmap(d.FileName);

            }

        }

 

        //Select sign of customer 2

        private void btnUploadSigns1_Click(object sender, EventArgs e)

        {

            OpenFileDialog d = new OpenFileDialog();

            d.Title = "Select Image";

            d.Filter = " (*.jpg;*.png;*.jpeg) | *.jpg;*.png;*.jpeg";

 

            DialogResult dr = new DialogResult();

            dr = d.ShowDialog();

            if (dr == DialogResult.OK)

            {

                sign2 = 0;

                pbSignature1.Image = new Bitmap(d.FileName);

            }

        }

 

 

 

 

 

        //insert only String in Text Box

        private void TextField_KeyPress(object sender, KeyPressEventArgs e)

        {

                        

            if (e.KeyChar >= '0' && e.KeyChar <= '9')

            {

                e.Handled = true;

            }

            else

            {

                e.Handled = false;

            }

 

 

        }

 

        private void txtIncome1_KeyPress(object sender, KeyPressEventArgs e)

        {

 

        }

 

        //insert only Numbers in Text Box

        private void NumbericField_KeyPress(object sender, KeyPressEventArgs e)

        {

            

            if (e.KeyChar >= '0' && e.KeyChar <= '9' || e.KeyChar == 08)

            {

                e.Handled = false;

            }

            else

            {

                e.Handled = true;

            }

        }

 

 

        private void rdoSingle_CheckedChanged(object sender, EventArgs e)

        {

            //clearData2();

            type = "single";

            //clearData2();

            //btnSecondPerson.Enabled = false;

            //btnshhowpanel.Visible = false;

            single = true;

            joint = false;

            panel1.Visible = false;

 

 

        }

        

 

        //automatic generate id (account numbers)

        double id;

 

 

 

        private void dateTimePicker2_ValueChanged(object sender, EventArgs e)

        {

            //print date in textbox

            if (checkAgeJoint() >= 10)

            {

                txtDateofBirth1.Text = dateTimePicker2.Value.ToString("dd/MM/yyyy");

            }

            else

            {

                MessageBox.Show("Age must be greater than 10 to create an account!""Information!"MessageBoxButtons.OK, MessageBoxIcon.Stop);

                //MessageBox.Show("");

            }

 

        }

 

        private void txtAccountNumber_Enter(object sender, EventArgs e)

        {

            clear();

        }

 

        private void txtAccountNumber_Leave(object sender, EventArgs e)

        {

            conn = new SqlConnection(CS);

            conn.Open();

            if (txtAccountNumber.Text == string.Empty)

            {

 

            }

            else

            {

 

                //check if Account no exist

                bool Exist = false;

                cmd = new SqlCommand("select * from customer where accno='" + Convert.ToInt64(txtAccountNumber.Text) + "' AND status='" + true + "'", conn);

                dr = cmd.ExecuteReader();

                if (dr.Read())

                {

                    Exist = true;

                }

                else

                {

                    DialogResult d = MessageBox.Show("Account Number Not Exist In This Bank""Error"MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);

                    if (d == DialogResult.Retry)

                    {

                        txtAccountNumber.Clear();

                        txtAccountNumber.Focus();

                        cmbType.Items.Clear();

                    }

                    else

                    {

 

                    }

                }

                dr.Close();

                //get data in combo box

                if (Exist)

                {

 

                    cmbType.Items.Clear();

                    cmd = new SqlCommand("select acctype from customer where accno='" + txtAccountNumber.Text + "'", conn);

                    dr = cmd.ExecuteReader();

                    if (dr.Read())

                    {

                        type = dr[0].ToString();

                        cmbType.Items.Add(dr[0].ToString());

                    }

                    dr.Close();

                    cmbType.SelectedIndex = 0;

 

                }

            }

        }

 

        private void btnhidepanel_Click_1(object sender, EventArgs e)

        {

            panel1.Visible = true;

        }

 

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)

        {

            //print date in textbox

            if (checkAgeSingle() >= 10)

            {

                txtDateofBirth.Text = dateTimePicker1.Value.ToString("dd/MM/yyyy");

            }

            else

            {

                MessageBox.Show("Age must be greater than 10 to create an account!""Information!"MessageBoxButtons.OK, MessageBoxIcon.Stop);

                //MessageBox.Show("");

            }

 

 

        }

 

        private void btnDelete_Click(object sender, EventArgs e)

        {

            if (txtAccountNumber.Text == string.Empty)

            {

                MessageBox.Show("Please enter account number!""Information!"MessageBoxButtons.OK, MessageBoxIcon.Stop);

 

            }

            else

            { 

 

            DialogResult d = MessageBox.Show("Are you sure want to Deactivate this account?""DeActivate ?"MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (d == DialogResult.Yes)

            {

                conn = new SqlConnection(CS);

                conn.Open();

                cmd = new SqlCommand("update customer set status='" + false + "' where accno='" + txtAccountNumber.Text + "'", conn);

                cmd.ExecuteNonQuery();

                MessageBox.Show("Account Successfully Deativated!");

                clear();

            }

            }

        }

 

        private void btnSave_Click(object sender, EventArgs e)

        {

            if (type == "single")

            {

                if (MsktxtAdharNumber.Text == string.Empty || txtAddress.Text == string.Empty || txtCity.Text == string.Empty || txtDateofBirth.Text == string.Empty || txtEmailID.Text == string.Empty || txtIncome.Text == string.Empty || txtFatherName.Text == string.Empty || txtCustomerName.Text == string.Empty || MsktxtMobileNumber.Text == string.Empty || txtMotherName.Text == string.Empty || txtPanNumber.Text == string.Empty || MsktxtPinCode.Text == string.Empty || txtReligion.Text == string.Empty || txtTaluka.Text == string.Empty || cmbDistrict.SelectedIndex == 0 || cmbNationality.SelectedIndex == 0 || cmbQualification.SelectedIndex == 0 || cmbState.SelectedIndex == 0)

                {

                    MessageBox.Show("All fields are mendetory please check again!""Error"MessageBoxButtons.OK, MessageBoxIcon.Error);

                }

                else

                {

                    try

                    {

                        conn = new SqlConnection(CS);

                        conn.Open();

 

                        //insert into customer

                        cmd = new SqlCommand("update customer set name_f=@name,fname_f=@fname,mname_f=@fname,dob_f=@dob,gender_f=@gender,aadhar_f=@aadhar,pan_f=@pan,qualifi_f=@quali,distic_f=@distic,taluka_f=@taluka,city_f=@city,pin_f=@pin,address=@address,mobile_f=@mobile,email_f=@email,maritial_f=@maritial,sign_f=@sign,relgion_f=@relgion,nation_f=@nation_f,state_f=@state_f,photo_f=@photo where accno='" + txtAccountNumber.Text + "'", conn);

                        cmd.Parameters.AddWithValue("name", txtCustomerName.Text);

                        cmd.Parameters.AddWithValue("fname", txtFatherName.Text);

                        cmd.Parameters.AddWithValue("mname", txtMotherName.Text);

                        cmd.Parameters.AddWithValue("dob", txtDateofBirth.Text);

                        if (rdoMale.Checked)

                        {

                            cmd.Parameters.AddWithValue("gender""male");

                        }

                        else if (rdoFemale.Checked)

                        {

                            cmd.Parameters.AddWithValue("gender""female");

                        }

                        else

                        {

                            cmd.Parameters.AddWithValue("gender""other");

                        }

                        cmd.Parameters.AddWithValue("aadhar", MsktxtAdharNumber.Text);

                        cmd.Parameters.AddWithValue("pan", txtPanNumber.Text);

                        cmd.Parameters.AddWithValue("quali", cmbQualification.SelectedItem);

                        cmd.Parameters.AddWithValue("nation_f", cmbNationality.SelectedItem);

                        cmd.Parameters.AddWithValue("state_f", cmbState.SelectedItem);

                        cmd.Parameters.AddWithValue("distic", cmbDistrict.SelectedItem);

                        cmd.Parameters.AddWithValue("taluka", txtTaluka.Text);

                        cmd.Parameters.AddWithValue("city", txtCity.Text);

                        cmd.Parameters.AddWithValue("pin", MsktxtPinCode.Text);

                        cmd.Parameters.AddWithValue("address", txtAddress.Text);

                        cmd.Parameters.AddWithValue("mobile", MsktxtMobileNumber.Text);

                        cmd.Parameters.AddWithValue("email", txtEmailID.Text);

                        cmd.Parameters.AddWithValue("relgion", txtReligion.Text);

                        if (rdoMarried.Checked)

                        {

                            cmd.Parameters.AddWithValue("maritial""Maried");

                        }

                        else if (rdoUnmarried.Checked)

                        {

                            cmd.Parameters.AddWithValue("maritial""UnMaried");

                        }

                        else if (rdoDivorced.Checked)

                        {

                            cmd.Parameters.AddWithValue("maritial""Divorced");

                        }

                        else

                        {

                            cmd.Parameters.AddWithValue("maritial""Annulated");

                        }

 

                        cmd.Parameters.AddWithValue("religion", txtReligion.Text);

                        cmd.Parameters.AddWithValue("income", txtIncome.Text);

                        cmd.Parameters.AddWithValue("deposite", txtDiposit.Text);

 

                        cmd.Parameters.AddWithValue("sign", saveSign1(pbSignature));

                        cmd.Parameters.AddWithValue("photo", savePhoto1(pbImage));

                        //cmd.Parameters.AddWithValue("status", true);

                        cmd.ExecuteNonQuery();

 

                        MessageBox.Show("Customer information updated successfully!""Updated"MessageBoxButtons.OK, MessageBoxIcon.Information);

                        clear();

 

                    }

                    catch (Exception ex)

                    {

                        MessageBox.Show(ex.Message);

 

                    }

 

                }

            }

            else 

            {

                if (MsktxtAdharNumber.Text == string.Empty || txtAddress.Text == string.Empty || txtCity.Text == string.Empty || txtDateofBirth.Text == string.Empty || txtEmailID.Text == string.Empty || txtIncome.Text == string.Empty || txtFatherName.Text == string.Empty || txtCustomerName.Text == string.Empty || MsktxtMobileNumber.Text == string.Empty || txtMotherName.Text == string.Empty || txtPanNumber.Text == string.Empty || MsktxtPinCode.Text == string.Empty || txtReligion.Text == string.Empty || txtTaluka.Text == string.Empty || cmbDistrict.SelectedIndex == 0 || cmbNationality.SelectedIndex == 0 || cmbQualification.SelectedIndex == 0 || cmbState.SelectedIndex == 0 || MsktxtAdharNumber1.Text == string.Empty || txtAddress1.Text == string.Empty || txtCity1.Text == string.Empty || txtDateofBirth1.Text == string.Empty || txtEmailID1.Text == string.Empty || txtIncome1.Text == string.Empty || txtFatherName1.Text == string.Empty || txtCustomerName1.Text == string.Empty || MsktxtMobileNumber1.Text == string.Empty || txtMotherName1.Text == string.Empty || txtPanNumber1.Text == string.Empty || MsktxtPinCode1.Text == string.Empty || txtReligion1.Text == string.Empty || txtTaluka1.Text == string.Empty || cmbDistrict1.SelectedIndex == 0 || cmbNationality1.SelectedIndex == 0 || cmbQualification1.SelectedIndex == 0 || cmbState1.SelectedIndex == 0)

                {

                    MessageBox.Show("All fields are mendetory please check again!""Error"MessageBoxButtons.OK, MessageBoxIcon.Error);

                }

                else

                {

                    try

                    {

                        //insert into customer joint

                        conn = new SqlConnection(CS);

                        conn.Open();

 

                        cmd = new SqlCommand("update customer set name_f=@name,fname_f=@fname,mname_f=@fname,dob_f=@dob,gender_f=@gender,aadhar_f=@aadhar,pan_f=@pan,qualifi_f=@quali,distic_f=@distic,taluka_f=@taluka,city_f=@city,pin_f=@pin,address=@address,mobile_f=@mobile,email_f=@email,maritial_f=@maritial,sign_f=@sign,photo_f=@photo,name_s=@name1,fname_s=@fname1,mname_s=@fname1,dob_s=@dob1,gender_s=@gender1,aadhar_s=@aadhar1,qualifi_s=@quali1,pan_s=@pan1,distic_s=@distic1,taluka_s=@taluka1,city_s=@city1,pin_s=@pin1,address_s=@address1,mobile_s=@mobile1,email_s=@email1,maritial_s=@maritial1,sign_s=@sign1,photo_s=@photo1 where accno='" + txtAccountNumber.Text + "' ", conn);

                        cmd.Parameters.AddWithValue("name", txtCustomerName.Text);

                        cmd.Parameters.AddWithValue("fname", txtFatherName.Text);

                        cmd.Parameters.AddWithValue("mname", txtMotherName.Text);

                        cmd.Parameters.AddWithValue("dob", txtDateofBirth.Text);

                        if (rdoMale.Checked)

                         {

                             cmd.Parameters.AddWithValue("gender""male");

                         }

                         else if (rdoFemale.Checked)

                         {

                             cmd.Parameters.AddWithValue("gender""female");

                         }

                         else

                         {

                             cmd.Parameters.AddWithValue("gender""other");

                         }

 

                         cmd.Parameters.AddWithValue("aadhar", MsktxtAdharNumber.Text);

                         cmd.Parameters.AddWithValue("pan", txtPanNumber.Text);

                         cmd.Parameters.AddWithValue("quali", cmbQualification.SelectedItem);

                         cmd.Parameters.AddWithValue("nation", cmbNationality.SelectedItem);

                         cmd.Parameters.AddWithValue("state", cmbState.SelectedItem);

                         cmd.Parameters.AddWithValue("distic", cmbDistrict.SelectedItem);

                         cmd.Parameters.AddWithValue("taluka", txtTaluka.Text);

                         cmd.Parameters.AddWithValue("city", txtCity.Text);

                         cmd.Parameters.AddWithValue("pin", MsktxtPinCode.Text);

                         cmd.Parameters.AddWithValue("address", txtAddress.Text);

                         cmd.Parameters.AddWithValue("mobile", MsktxtMobileNumber.Text);

                         cmd.Parameters.AddWithValue("email", txtEmailID.Text);

                         cmd.Parameters.AddWithValue("relgion", txtReligion.Text);

                         if (rdoMarried.Checked)

                         {

                             cmd.Parameters.AddWithValue("maritial""Maried");

                         }

                         else if (rdoUnmarried.Checked)

                         {

                             cmd.Parameters.AddWithValue("maritial""UnMaried");

                         }

                         else if (rdoDivorced.Checked)

                         {

                             cmd.Parameters.AddWithValue("maritial""Divorced");

                         }

                         else

                         {

                             cmd.Parameters.AddWithValue("maritial""Annulated");

                         }

 

                         cmd.Parameters.AddWithValue("religion", txtReligion.Text);

                         cmd.Parameters.AddWithValue("income", txtIncome.Text);

                         cmd.Parameters.AddWithValue("deposite", txtDiposit.Text);

 

                         cmd.Parameters.AddWithValue("sign", saveSign1(pbSignature));

                         cmd.Parameters.AddWithValue("photo", savePhoto1(pbImage));

 

 

                         //Second person information

 

                         cmd.Parameters.AddWithValue("name1", txtCustomerName1.Text);

                         cmd.Parameters.AddWithValue("fname1", txtFatherName1.Text);

                         cmd.Parameters.AddWithValue("mname1", txtMotherName1.Text);

                         cmd.Parameters.AddWithValue("dob1", txtDateofBirth1.Text);

                         if (rdoMale.Checked)

                         {

                             cmd.Parameters.AddWithValue("gender1""male");

                         }

                         else if (rdoFemale.Checked)

                         {

                             cmd.Parameters.AddWithValue("gender1""female");

                         }

                         else

                         {

                             cmd.Parameters.AddWithValue("gender1""other");

                         }

                         cmd.Parameters.AddWithValue("aadhar1", MsktxtAdharNumber1.Text);

                         cmd.Parameters.AddWithValue("pan1", txtPanNumber1.Text);

                         cmd.Parameters.AddWithValue("quali1", cmbQualification1.SelectedItem);

                         cmd.Parameters.AddWithValue("nation1", cmbNationality1.SelectedItem);

                         cmd.Parameters.AddWithValue("state1", cmbState1.SelectedItem);

                         cmd.Parameters.AddWithValue("distic1", cmbDistrict1.SelectedItem);

                         cmd.Parameters.AddWithValue("taluka1", txtTaluka1.Text);

                         cmd.Parameters.AddWithValue("city1", txtCity1.Text);

                         cmd.Parameters.AddWithValue("pin1", MsktxtPinCode1.Text);

                         cmd.Parameters.AddWithValue("address1", txtAddress1.Text);

                         cmd.Parameters.AddWithValue("mobile1", MsktxtMobileNumber1.Text);

                         cmd.Parameters.AddWithValue("email1", txtEmailID1.Text);

                         cmd.Parameters.AddWithValue("relgion1", txtReligion1.Text);

                         if (rdoMarried.Checked)

                         {

                             cmd.Parameters.AddWithValue("maritial1""Maried");

                         }

                         else if (rdoUnmarried.Checked)

                         {

                             cmd.Parameters.AddWithValue("maritial1""UnMaried");

                         }

                         else if (rdoDivorced.Checked)

                         {

                             cmd.Parameters.AddWithValue("maritial1""Divorced");

                         }

                         else

                         {

                             cmd.Parameters.AddWithValue("maritial1""Annulated");

                         }

 

                         cmd.Parameters.AddWithValue("religion1", txtReligion1.Text);

                         cmd.Parameters.AddWithValue("income1", txtIncome1.Text);

                         //cmd.Parameters.AddWithValue("deposite", txtDiposit.Text);

 

                         cmd.Parameters.AddWithValue("sign1", saveSign2(pbSignature));

                         cmd.Parameters.AddWithValue("photo1", savePhoto2(pbImage));

                         

                        cmd.ExecuteNonQuery();

 

                        MessageBox.Show("Customer information updated successfully!""Updated"MessageBoxButtons.OK, MessageBoxIcon.Information);

                        clear();

                    }

                    catch (Exception ex)

                    {

                        MessageBox.Show(ex.Message);

 

                    }

                }

 

            }

 

 

 

 

        }

 

        private void autoId()

        {

            conn = new SqlConnection(CS);

            conn.Open();

            cmd = new SqlCommand("select MAX(accno) from customer", conn);

            accno = cmd.ExecuteScalar().ToString();

            if (accno == "")

            {

                txtAccountNumber.Text = "30000000001";

            }

            else

            {

                id = Convert.ToInt64(accno);

                id = id + 1;

                txtAccountNumber.Text = id.ToString();

            }

        }

 

        //validations

        private bool emailValidation()

        {

            if (Regex.IsMatch(txtEmailID.Text, "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$"))

            {

                return true;

            }

            else

            {

                return false;

            }

        }

 

        private bool emailValidation1()

        {

            if (Regex.IsMatch(txtEmailID1.Text, "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$"))

            {

                return true;

            }

            else

            {

                return false;

            }

        }

 

        //check first account holder gender

        private string CheckGen1()

        {

            if (rdoMale.Checked)

            {

                gender = "male";

            }

            else if (rdoFemale.Checked)

            {

                gender = "female";

            }

            else

            {

                gender = "Other";

            }

            return gender;

        }

 

        //check Second account holder gender

        private string CheckGen2()

        {

            if (rdoMale1.Checked)

            {

                gender1 = "male";

            }

            else if (rdoFemale1.Checked)

            {

                gender1 = "female";

            }

            else

            {

                gender1 = "Other";

            }

            return gender1;

        }

 

 

        //check Maritial Status of Customer 1

        private string checkMar1()

        {

            if (rdoMarried.Checked)

            {

                marid = "maried";

            }

            else if(rdoUnmarried.Checked)

            {

                marid = "unmaried";

            }

            else if (rdoDivorced.Checked)

            {

                marid = "Divorced";

            }

            else

            {

                marid = "Annulated";

            }

            return marid;

        }

 

 

        //check Maritial Status of Customer 1

        private string checkMar2()

        {

            if (rdoMarried1.Checked)

            {

                marid1 = "maried";

            }

            else if (rdoUnmarried1.Checked)

            {

                marid1 = "unmaried";

            }

            else if (rdoDivorced1.Checked)

            {

                marid1 = "Divorced";

            }

            else

            {

                marid1 = "Annulated";

            }

            return marid1;

        }

 

 

 

       /* private void NewCustomer_Load(object sender, EventArgs e)

        {

            //show date in label

            lbldate.Text = DateTime.Now.ToString("dd-MM-yyyy");

            time = DateTime.Now.ToString("hh:mm:ss");

            autoId();

            cbdis.SelectedIndex = 0;

            cbnation.SelectedIndex = 0;

            cbqualify.SelectedIndex = 0;

            cbstate.SelectedIndex = 0;

            cbstate1.SelectedIndex = 0;

            cbqualify1.SelectedIndex = 0;

            cbnatinality1.SelectedIndex = 0;

            cbdistic1.SelectedIndex = 0;

        }

        */

   

 

    }

}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
 
 
 
namespace FinoBank_Application
{
    public partial class frmEditUser : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmEditUser()
        {
            InitializeComponent();
        }
 
        SqlCommand cmd;
        SqlDataReader dr;
        DataTable dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter();
        SqlConnection conn;
        int img = 1;
        string gen1 = "";
 
        private void frmEditUser_Load(object sender, EventArgs e)
        {
            cmbUserType.SelectedIndex = 0;
            load();
 
        }
 
 
        public void clearData()
        {
            txtDateofBirth.Clear();
            txtMskMobile.Clear();
            txtUserFullName.Clear();
 
 
            txtEmailID.Clear();
            pbImage1.Image = null;
 
            cmbSelectUser.SelectedIndex = 0;
            cmbUserType.SelectedIndex = 0;
        }
 
 
        private void load()
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            cmbSelectUser.Items.Clear();
            cmbSelectUser.Items.Add("------Select User------");
            cmd = new SqlCommand("select username from Users", conn);
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                cmbSelectUser.Items.Add(dr[0].ToString());
            }
            dr.Close();
            cmbSelectUser.SelectedIndex = 0;
 
        }
 
 
        //Check the gender of user
        public string checkGen()
        {
            if (rdoFemale.Checked)
            {
                gen1 = "Female";
            }
            else if (rdoMale.Checked)
            {
                gen1 = "Male";
            }
            else
            {
                gen1 = "Other";
            }
            return gen1;
        }
 
 
 
        private void btnClearFields_Click(object sender, EventArgs e)
        {
            clearData();
        }
 
        //Check if email is correct
        private bool emailValidation()
        {
            if (Regex.IsMatch(txtEmailID.Text, "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$"))
            {
                return true;
            }
 
            return false;
        }
 
        //save image temporary 
        public byte[] savePhoto(PictureBox pb)
        {
            MemoryStream ms = new MemoryStream();
            pbImage1.Image.Save(ms, pb.Image.RawFormat);
            return ms.GetBuffer();
        }
        //display photo
        public Image DisPhoto(byte[] photo)
        {
            MemoryStream ms = new MemoryStream(photo);
            return Image.FromStream(ms);
        }
 
        //check the age of User
        public int checkAge()
        {
            int year = Convert.ToInt32(dateTimePicker1.Value.Year);
            int year1 = Convert.ToInt32(DateTime.Now.Year);
            int age = year1 - year;
            return age;
        }
 
        //Upload Image
        private void btnUpload_Click_1(object sender, EventArgs e)
        {
            OpenFileDialog d = new OpenFileDialog();
            d.Title = "Select Image";
            d.Filter = " (*.jpg;*.png;*.jpeg) | *.jpg;*.png;*.jpeg";
            DialogResult dr = new DialogResult();
            dr = d.ShowDialog();
            if (dr == DialogResult.OK)
            {
                img = 0;
                pbImage1.Image = new Bitmap(d.FileName);
            }
        }
 
        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            if (checkAge() >= 18)
            {
                txtDateofBirth.Text = dateTimePicker1.Value.ToString("dd/MM/yyyy");
            }
            else
            {
                MessageBox.Show("User must be equal of greater then 18 years!""Error"MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 
       
 
        private void btnDelete_Click(object sender, EventArgs e)
        {
 
            DialogResult d = MessageBox.Show("Are You Want To Delete User Called " + cmbSelectUser.SelectedItem, "Inform"MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (d == DialogResult.Yes)
            {
                cmd = new SqlCommand("delete from Users where username='" + cmbSelectUser.SelectedItem + "'", conn);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Sucessfully Deleted ""Delete"MessageBoxButtons.OK, MessageBoxIcon.Information);
                clearData();
                load();
 
            }
            else
            {
 
            }
        }
 
        private void cmbSelectUser_SelectedIndexChanged(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            cmd = new SqlCommand("select * from Users where username='" + cmbSelectUser.SelectedItem + "'", conn);
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
 
 
                cmbUserType.SelectedItem = dr[3].ToString();
                txtUserFullName.Text = dr[4].ToString();
                txtDateofBirth.Text = dr[5].ToString();
                if (dr[6].ToString() == "Female")
                {
                    rdoFemale.Checked = true;
                }
                else if (dr[6].ToString() == "Male")
                {
                    rdoMale.Checked = true;
                }
                else
                {
                    rdoOther.Checked = true;
                }
 
                txtMskMobile.Text = dr[7].ToString();
                txtEmailID.Text = dr[8].ToString();
                pbImage1.Image = DisPhoto((byte[])dr[9]);
 
            }
            dr.Close();
        }
 
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            if (txtMskMobile.Text == string.Empty || txtUserFullName.Text == string.Empty || txtDateofBirth.Text == string.Empty)
            {
                MessageBox.Show("All fields are mendetory! ""Inform"MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
 
                cmd = new SqlCommand("update Users set type=@type,fullname=@fnm,dob=@dob,gender=@gen,mobile=@mob,email=@email,image=@image where username=@uname", conn);
                cmd.Parameters.AddWithValue("uname", cmbSelectUser.SelectedItem);
                cmd.Parameters.AddWithValue("type", cmbUserType.SelectedItem);
                cmd.Parameters.AddWithValue("fnm", txtUserFullName.Text);
                cmd.Parameters.AddWithValue("dob", txtDateofBirth.Text);
                cmd.Parameters.AddWithValue("gen", checkGen());
                cmd.Parameters.AddWithValue("mob", txtMskMobile.Text);
                cmd.Parameters.AddWithValue("email", txtEmailID.Text);
                cmd.Parameters.AddWithValue("image", savePhoto(pbImage1));
                cmd.ExecuteNonQuery();
 
                MessageBox.Show("User Suceesfully Updated!""Success"MessageBoxButtons.OK, MessageBoxIcon.Information);
                clearData();
                load();
            }
        }
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
 
namespace FinoBank_Application
{
    public partial class frmFDInterestRates : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmFDInterestRates()
        {
            InitializeComponent();
        }
 
        SqlCommand cmd;
        SqlDataReader dr;
        SqlConnection conn;
 
 
        private void getData()
        {
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("select * from fdrate", conn);
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                txtold1.Text = dr[0].ToString();
                txtold2.Text = dr[1].ToString();
                txtold3.Text = dr[2].ToString();
                txtold4.Text = dr[3].ToString();
                txtold5.Text = dr[4].ToString();
                txtold6.Text = dr[5].ToString();
                txtold7.Text = dr[6].ToString();
                txtold8.Text = dr[7].ToString();
                txtold9.Text = dr[8].ToString();
                txtold10.Text = dr[9].ToString();
                txtold15.Text = dr[10].ToString();
                txtold20.Text = dr[11].ToString();
                txtold25.Text = dr[12].ToString();
 
                txtnew1.Text = dr[0].ToString();
                txtnew2.Text = dr[1].ToString();
                txtnew3.Text = dr[2].ToString();
                txtnew4.Text = dr[3].ToString();
                txtnew5.Text = dr[4].ToString();
                txtnew6.Text = dr[5].ToString();
                txtnew7.Text = dr[6].ToString();
                txtnew8.Text = dr[7].ToString();
                txtnew9.Text = dr[8].ToString();
                txtnew10.Text = dr[9].ToString();
                txtnew15.Text = dr[10].ToString();
                txtnew20.Text = dr[11].ToString();
                txtnew25.Text = dr[12].ToString();
 
            }
            dr.Close();
        }
 
        private void frmFDInterestRates_Load(object sender, EventArgs e)
        {
            getData();
        }
 
        private void btnChange_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("update fdrate set [1]=" + txtnew1.Text + ",[2]=" + txtnew2.Text + ",[3]=" + txtnew3.Text + " ,[4]= " + txtnew4.Text + " ,[5]= " + txtnew5.Text + " ,[6]= " + txtnew6.Text + " ,[7]= " + txtnew7.Text + " ,[8]= " + txtnew8.Text + " ,[9]= " + txtnew9.Text + " ,[10]= " + txtnew10.Text + " ,[15]= " + txtnew15.Text + " ,[20]= " + txtnew20.Text + ",[25]= " + txtnew25.Text + "", conn);
            cmd.ExecuteNonQuery();
            MessageBox.Show("Rates Update Sucessfully!  ""Update"MessageBoxButtons.OK, MessageBoxIcon.Information);
            getData();
        }
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
 
namespace FinoBank_Application
{
    public partial class frmLoanAccountInfo : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmLoanAccountInfo()
        {
            InitializeComponent();
        }
 
        SqlDataReader dr;
        SqlCommand cmd;
        SqlConnection conn;
        int paid, unpaid, total;
        string emidate, interval;
        //string date, month, year;
 
        private void lbemi_SelectedIndexChanged(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            //print EMi status in label
            lblemino.Text = lbemi.SelectedItem.ToString();
            label17.Visible = true;
            cmd = new SqlCommand("select emistatus from emi where loanid=@id AND emino=@emino", conn);
            cmd.Parameters.AddWithValue("id", txtid.Text);
            cmd.Parameters.AddWithValue("emino", lbemi.SelectedItem);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                if (dr[0].ToString() == "")
                {
                    lblemistatus.Text = "UnPaid EMI";
                    lblpaiddate.Visible = false;
                    lblpdate1.Visible = false;
                }
                else
                {
                    lblemistatus.Text = dr[0].ToString();
                    lblpaiddate.Visible = true;
                    lblpdate1.Visible = true;
                }
            }
            else
            {
                lblemistatus.Text = "UnPaid EMI";
                lblpaiddate.Visible = false;
                lblpdate1.Visible = false;
            }
            dr.Close();
 
 
            // print Paying date  
            cmd = new SqlCommand("select firstemi from loan where id='" + txtid.Text + "'", conn);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                emidate = dr[0].ToString();
                edate = Convert.ToDateTime(dr[0]);
            }
 
            dr.Close();
 
            //print paid emi date
 
            cmd = new SqlCommand("select date from emi where loanid=@id AND emino=@emino", conn);
            cmd.Parameters.AddWithValue("id", txtid.Text);
            cmd.Parameters.AddWithValue("emino", lbemi.SelectedItem);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                lblpaiddate.Text = dr[0].ToString();
 
            }
            dr.Close();
 
            int selid = lbemi.SelectedIndex;
 
            if (interval == "12")
            {
                int m = selid * 12;
                //DateTime d = Convert.ToDateTime(emidate);
                DateTime d = edate.AddMonths(m);
                lbldate.Text = d.ToString("dd/MM/yyyy");
 
 
            }
 
            if (interval == "6")
            {
                int m = selid * 6;
 
                DateTime d = edate.AddMonths(m);
                lbldate.Text = d.ToString("dd/MM/yyyy");
 
            }
 
            if (interval == "3")
            {
                int m = selid * 3;
                //DateTime d = Convert.ToDateTime(emidate);
                DateTime d = edate.AddMonths(m);
                lbldate.Text = d.ToString("dd/MM/yyyy");
 
 
            }
        }
 
        private void btnSearch_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            //clear the list box
            lbemi.Items.Clear();
            lblemino.Text = "EMI NO";
            lblemistatus.Text = "Paid / UnPaid";
            lbldate.Text = "00/00/0000";
 
 
            //check if loan account exist
            bool loanExist = false;
            cmd = new SqlCommand("select * from loan where id='" + txtid.Text + "'", conn);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                loanExist = true;
            }
            else
            {
                loanExist = false;
            }
            dr.Close();
 
            if (loanExist)
            {
 
 
                //display all data in text box
                cmd = new SqlCommand("select accno,name,amount,interest,duration,noofemi,emiammount,totalamount,type,interval,startdate,enddate from loan where id='" + txtid.Text + "'", conn);
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    txtaccno.Text = dr[0].ToString();
                    txtname.Text = dr[1].ToString();
                    txtammount.Text = dr[2].ToString();
                    txtinterest.Text = dr[3].ToString();
                    txtduration.Text = dr[4].ToString();
                    txtnoofemi.Text = dr[5].ToString();
                    total = Convert.ToInt32(txtnoofemi.Text);
                    txtemiamount.Text = dr[6].ToString();
                    txttotal.Text = dr[7].ToString();
                    txttype.Text = dr[8].ToString();
                    txtinterval.Text = dr[9].ToString();
                    interval = txtinterval.Text;
                    txtsdate.Text = dr[10].ToString();
                    txtedate.Text = dr[11].ToString();
                }
                dr.Close();
 
 
                cmd = new SqlCommand("select paidemi from emi where loanid='" + txtid.Text + "'", conn);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
 
                    txtpaidemi.Text = dr[0].ToString();
                    paid = Convert.ToInt32(txtpaidemi.Text);
                }
                else
                {
                    txtpaidemi.Text = "0";
                }
                dr.Close();
                //calculate the unpaid emis
                unpaid = total - paid;
                txtunpaid.Text = unpaid.ToString();
 
                //add emis in list box
 
                for (int i = 1; i <= total; i++)
                {
                    lbemi.Items.Add("EMI-" + i.ToString());
                }
            }
            else
            {
                MessageBox.Show("Loan Account Not Exist""Error"MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 
        DateTime edate;
        private void frmLoanAccountInfo_Load(object sender, EventArgs e)
        {
 
        }
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
namespace FinoBank_Application
{
    public partial class frmLoanRates : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmLoanRates()
        {
            InitializeComponent();
        }
        SqlCommand cmd;
        SqlDataReader dr;
        SqlConnection conn;
 
 
        protected void load()
        {
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("select * from loanrate ", conn);
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                txteducation.Text = dr[0].ToString();
                txthome.Text = dr[1].ToString();
                txtcar.Text = dr[2].ToString();
                txtfarm.Text = dr[3].ToString();
                txtpersonal.Text = dr[4].ToString();
 
 
                txtneweducation.Text = dr[0].ToString();
                txtnewhome.Text = dr[1].ToString();
                txtnewcar.Text = dr[2].ToString();
                txtnewfarm.Text = dr[3].ToString();
                txtnewpersonal.Text = dr[4].ToString();
            }
            dr.Close();
        }
 
        private void frmLoanRates_Load(object sender, EventArgs e)
        {
            load();
        }
 
        private void btnChange_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            cmd = new SqlCommand("update loanrate set education='" + txtneweducation.Text + "' , home='" + txtnewhome.Text + "' , car='" + txtnewcar.Text + "' , farm='" + txtnewfarm.Text + "', personal='" + txtpersonal.Text + "'", conn);
            cmd.ExecuteNonQuery();
            MessageBox.Show("Loan Rate Change Suceesfully ..""Change"MessageBoxButtons.OK, MessageBoxIcon.Information);
            load();
        }
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
namespace FinoBank_Application
{
    public partial class frmNewFDAccount : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmNewFDAccount()
        {
            InitializeComponent();
        }
 
 
        SqlCommand cmd;
        SqlConnection conn; 
        SqlDataReader dr;
        DataTable dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter();
 
 
 
        //auto fd id
        private void autoId()
        {
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("select MAX(id) from fd", conn);
            string id = cmd.ExecuteScalar().ToString();
            if (id == string.Empty)
            {
                txtFDID.Text = "100001";
                txtFDActNo.Text = "100001";
            }
            else
            {
                double fdid = Convert.ToDouble(id);
                fdid = fdid + 1;
                txtFDID.Text = fdid.ToString();
                txtFDActNo.Text = fdid.ToString();
            }
        }
 
 
        private void frmNewFDAccount_Load(object sender, EventArgs e)
        {
            txtDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
            txtStartDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
            autoId();
            //txtFDActNo.Text == autoId();
            lblloader.Visible = false;
        }
 
        //display photo
        public Image DisPhoto(byte[] photo)
        {
            MemoryStream ms = new MemoryStream(photo);
            return Image.FromStream(ms);
        }
 
        private void btnsearch_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            if (txtAccountNumber.Text == string.Empty)
            {
 
                MessageBox.Show("Account number can't be blank!.""Error"MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtAccountNumber.Focus();
            }
            else
            {
 
                cmd = new SqlCommand("select account,acctype,name_f,name_s,photo_f,photo_s from customer where accno='" + txtAccountNumber.Text + "'", conn);
                dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
 
                    while (dr.Read())
                    {
                        txtActType.Text = dr[0].ToString();
                        txtCustType.Text = dr[1].ToString();
                        if (txtCustType.Text == "single")
                        {
                            lblSecondCustomer.Visible = false;
                            pb2.Visible = false;
                            lblFirstCustomer.Text = dr[2].ToString();
                            pb1.Image = DisPhoto((byte[])dr[4]);
                        }
                        else
                        {
                            lblSecondCustomer.Visible = true;
                            pb2.Visible = true;
                            lblFirstCustomer.Text = dr[2].ToString();
                            lblSecondCustomer.Text = dr[3].ToString();
                            pb1.Image = DisPhoto((byte[])dr[4]);
                            pb2.Image = DisPhoto((byte[])dr[5]);
                        }
                    }
 
                }
                else
                {
 
                    MessageBox.Show("Account Does Not Exist.""Account Not Availbale"MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtAccountNumber.Focus();
                }
                dr.Close();
 
                //get balanve available in account
                txtBal.Text = getBal().ToString();
 
            }
        }
 
        private double getBal()
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            double bal = 0;
            cmd = new SqlCommand("select balance from balance where accno='" + txtAccountNumber.Text + "'", conn);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                bal = Convert.ToDouble(dr[0].ToString());
            }
            dr.Close();
            return bal;
        }
 
 
 
        private void clear()
        {
            txtAccountNumber.Clear();
            txtActType.Clear();
            txtFDAmount.Clear();
            txtCustType.Clear();
            txtDate.Clear();
            txtInterest.Clear();
            lblFirstCustomer.Text = "";
            lblSecondCustomer.Text = "";
            txtStartDate.Clear();
            txtTotalAmt.Clear();
            txtTotalInterest.Clear();
            txtBal.Clear();
            pb1.Image = null;
            pb2.Image = null;
            txtStartDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
        }
 
        private void btnClear_Click(object sender, EventArgs e)
        {
            clear();
        }
 
 
        //bank baalnce
        private double BankBalance()
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            dr.Close();
            double bal = 0;
            cmd = new SqlCommand("select * from BankBalance", conn);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                bal = Convert.ToDouble(dr[0].ToString());
            }
            dr.Close();
            return bal;
        }
 
        private void btnCreateFD_Click(object sender, EventArgs e)
        {
            if (txtAccountNumber.Text == string.Empty)
            {
                MessageBox.Show("Please enter account number! ""info"MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                conn = new SqlConnection(CS);
                conn.Open();
 
                if (txtTotalAmt.Text == string.Empty)
                {
                    MessageBox.Show("Please Enter All Details ""Enter Details"MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
 
                    if (cmbMoneyDeposite.SelectedIndex == 1)
                    {
                        //insert into fd
                        cmd = new SqlCommand("insert into fd values ('" + txtFDID.Text + "','" + txtAccountNumber.Text + "','" + txtActType.Text + "','" + txtCustType.Text + "'," + txtFDAmount.Text + ",'" + cmbMoneyDeposite.SelectedItem + "'," + txtInterest.Text + "," + txtTotalInterest.Text + "," + txtTotalAmt.Text + ",'" + txtStartDate.Text + "','" + txtEndDate.Text + "','" + lblFirstCustomer.Text + "','" + true + "')", conn);
                        cmd.ExecuteNonQuery();
 
 
                        //insert into bank balance
                        double bb = BankBalance();
                        double newbb = bb + Convert.ToDouble(txtTotalAmt.Text);
                        cmd = new SqlCommand("update BankBalance set balance =" + newbb + "", conn);
                        cmd.ExecuteNonQuery();
 
 
 
                        //insert into passbook
                        cmd = new SqlCommand("insert into passbook (accno,date,info,depositE,time) values('" + txtAccountNumber.Text + "','" + DateTime.Now.ToString("dd/MM/yyyy") + "','Create FD Account','" + txtTotalAmt.Text + "','" + DateTime.Now.ToString("hh:mm:ss") + "')", conn);
                        cmd.ExecuteNonQuery();
 
 
                        MessageBox.Show("Your FD Is Created  Please Print The Reciept""FD Create"MessageBoxButtons.OK, MessageBoxIcon.Information);
 
                        lblloader.Visible = true;
                        //lblmsg.Visible = false;
                        //print reciept
 
                        frmReportForm r = new frmReportForm();
                        r.crystalReportViewer1.ReportSource = null;
                        r.crystalReportViewer1.Refresh();
                        dt.Clear();
                        da = new SqlDataAdapter("select * from fd where id='" + txtFDID.Text + "'", conn);
                        da.Fill(dt);
                        Reports.crNewFD nfd = new Reports.crNewFD();
                        nfd.Database.Tables["fd"].SetDataSource(dt);
                        r.crystalReportViewer1.ReportSource = nfd;
                        r.crystalReportViewer1.Refresh();
                        r.Show();
 
 
                        clear();
                        autoId();
                    }
                    else
                    {
                        double balance = getBal();
                        double amt = Convert.ToDouble(txtTotalAmt.Text);
                        if (balance >= amt)
                        {
                            double newbal = balance - amt;
                            //insert into fd
                            cmd = new SqlCommand("insert into fd values ('" + txtFDID.Text + "','" + txtAccountNumber.Text + "','" + txtActType.Text + "','" + txtCustType.Text + "'," + txtFDAmount.Text + ",'" + cmbDuration.SelectedItem + "'," + txtInterest.Text + "," + txtTotalInterest.Text + "," + txtTotalAmt.Text + ",'" + txtStartDate.Text + "','" + txtEndDate.Text + "','" + lblFirstCustomer.Text + "','" + true + "')", conn);
                            cmd.ExecuteNonQuery();
 
                            //insert into passbook
                            cmd = new SqlCommand("insert into passbook (accno,date,info,transfer,avlabl,time) values('" + txtAccountNumber.Text + "','" + DateTime.Now.ToString("dd/MM/yyyy") + "','Transfer To FD Account','" + amt.ToString() + "','" + newbal.ToString() + "','" + DateTime.Now.ToString("hh:mm:ss") + "')", conn);
                            cmd.ExecuteNonQuery();
 
                            //insert into balance
                            cmd = new SqlCommand("update balance set balance='" + newbal + "' where accno='" + txtAccountNumber.Text + "'", conn);
                            cmd.ExecuteNonQuery();
 
 
                            MessageBox.Show("Your FD Is Created  Please Print The Reciept""FD Create"MessageBoxButtons.OK, MessageBoxIcon.Information);
 
                            //lblmsg.Visible = false;
                            //print reciept
                            lblloader.Visible = true;
 
                            frmReportForm r = new frmReportForm();
                            r.crystalReportViewer1.ReportSource = null;
                            r.crystalReportViewer1.Refresh();
                            dt.Clear();
                            da = new SqlDataAdapter("select * from fd where id='" + txtFDID.Text + "'", conn);
                            da.Fill(dt);
                            Reports.crNewFD nfd = new Reports.crNewFD();
                            nfd.Database.Tables["fd"].SetDataSource(dt);
                            r.crystalReportViewer1.ReportSource = nfd;
                            r.crystalReportViewer1.Refresh();
                            r.Show();
 
 
                            clear();
                            autoId();
 
 
                        }
                        else
                        {
                            MessageBox.Show("Your Balance Is less than your FD Ammount ""Not Enogth Balance"MessageBoxButtons.OK, MessageBoxIcon.Error);
 
                        }
                    }
 
 
                }
 
 
            }
        }
 
        private void cmbDuration_SelectedIndexChanged(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            if (txtFDAmount.Text == string.Empty)
            {
                MessageBox.Show("Please Enter Ammount First""Enter Ammount"MessageBoxButtons.OK, MessageBoxIcon.Information);
 
            }
            else
            {
                //get interest rate based on duration
                string d = cmbDuration.SelectedItem.ToString();
                MessageBox.Show(d);
                cmd = new SqlCommand("select [" + cmbDuration.SelectedItem + "] from fdrate ", conn);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    txtInterest.Text = dr[0].ToString();
                }
                dr.Close();
 
                //calculate total interest
 
                int year = Convert.ToInt32(cmbDuration.SelectedItem);
                double ammount = Convert.ToDouble(txtFDAmount.Text);
                double inte = Convert.ToDouble(txtInterest.Text);
 
 
                double totalint = (year * ammount * inte) / 100;
                double total = totalint + ammount;
                txtTotalInterest.Text = totalint.ToString();
                txtTotalAmt.Text = total.ToString();
 
                //calculate ending date
                int eyear = Convert.ToInt32(DateTime.Now.ToString("yyyy")) + year;
                txtEndDate.Text = DateTime.Now.ToString("dd/MM/") + eyear.ToString();
 
            }
        }
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
namespace FinoBank_Application
{
    public partial class frmNewLoan : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmNewLoan()
        {
            InitializeComponent();
        }
 
        SqlCommand cmd;
        SqlDataReader dr;
        SqlDataAdapter da;
        SqlConnection conn;
        DataTable dt = new DataTable();
 
        bool Exist = false;
        int interval; /*int mo, dat;*/
        string date, month, year, accno;
 
        private void btnWitSearch_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            bool ex;
            if (txtWitAccNo.Text == string.Empty)
            {
                MessageBox.Show("Please Enter Account Number...""Eroor"MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
 
                cmd = new SqlCommand("select * from customer where accno='" + txtWitAccNo.Text + "'", conn);
                dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    ex = true;
                }
                else
                {
                    ex = false;
                }
                dr.Close();
                if (ex)
                {
                    if (txtCustAccNo.Text == txtWitAccNo.Text)
                    {
                        MessageBox.Show("Same Account number please check...?? ");
                    }
                    else
                    {
                        //select account information from database
                        cmd = new SqlCommand("select account,acctype,name_f,name_s from customer where accno='" + txtWitAccNo.Text + "'", conn);
                        dr = cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            txtWitAccType.Text = dr[0].ToString();
                            txtWitType.Text = dr[1].ToString();
                            if (txtWitType.Text == "single")
                            {
                                txtWitName1.Text = dr[2].ToString();
                                txtWitName2.Visible = false;
                            }
                            else
                            {
                                txtWitName2.Visible = true;
                                txtWitName1.Text = dr[2].ToString();
                                txtWitName2.Text = dr[3].ToString();
                            }
                        }
                        dr.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Account Not Exist""Not Exits"MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
 
        private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
        {
            txtstartdate.Text = dateTimePicker2.Value.ToString("dd/MM/yyyy hh:mm:ss");
        }
 
        private void txtLoanduration_TextChanged(object sender, EventArgs e)
        {
            // print ending date in textbox by change in duaration
            if (txtLoanduration.Text.Length > 0)
            {
                int y = Convert.ToInt32(year) + Convert.ToInt32(txtLoanduration.Text);
                int m = Convert.ToInt32(month);
                if (m < 10)
                {
                    month = "0" + m.ToString();
                }
                else
                {
                    month = m.ToString();
                }
                txtenddate.Text = date + "/" + month + "/" + y.ToString();
 
            }
            else
            {
                txtLoanduration.Text = "";
            }
            intervalCal();
        }
 
        //bank baalnce
        private double BankBalance()
        {
            conn = new SqlConnection(CS);
            conn.Open();
            double bal = 0;
            cmd = new SqlCommand("select * from BankBalance", conn);
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                bal = Convert.ToDouble(dr[0].ToString());
            }
            dr.Close();
            return bal;
        }
 
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            if (cmbloantype.SelectedIndex == 0)
            {
                MessageBox.Show("Please Select Loan Type ...""Eroor"MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (txtloanamount.Text == string.Empty)
                {
                    MessageBox.Show("Please Enter Loan Amount""Eroor"MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (txtLoanduration.Text == string.Empty)
                    {
                        MessageBox.Show("Please Enter Loan Duration...""Eroor"MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        if (cmbinterval.SelectedIndex == 0)
                        {
                            MessageBox.Show("Please Select EMI Interval ...""Eroor"MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
 
                        //calculation
 
                        amount = Convert.ToDouble(txtloanamount.Text);
                        duration = Convert.ToDouble(txtLoanduration.Text);
 
                        //calculate total interest
                        totalint = (amount * duration * interest) / 100;
                        txtTotalEMIAmount.Text = totalint.ToString();
 
                        //calculate total amount
                        totalamount = amount + totalint;
                        txtTotalAmount.Text = totalamount.ToString();
 
                        //calculate amount of EMI's
                        emino = Convert.ToDouble(txtEMINo.Text);
                        emiamount = totalamount / emino;
                        txtEMIAmmount.Text = emiamount.ToString();
 
                        //print emi date by emi interval
                        if (interval == 12)
                        {
                            DateTime d = Convert.ToDateTime(txtstartdate.Text);
                            DateTime emidate = d.AddMonths(12);
                            txtEMIDate.Text = emidate.ToString();
 
                        }
                        else
                        {
                            if (interval == 6)
                            {
                                DateTime d = Convert.ToDateTime(txtstartdate.Text);
                                DateTime emidate = d.AddMonths(6);
                                txtEMIDate.Text = emidate.ToString();
                                /*
                                mo = Convert.ToInt32( emidate.Month.ToString());
                                dat =Convert.ToInt32( emidate.Date.ToString());
                                year = emidate.Year.ToString();
                                if (mo > 10)
                                {
                                    month = mo.ToString();
                                }
                                else
                                {
                                    month = "0" + mo.ToString();
                                }
 
                                if (dat > 10)
                                {
                                    date = dat.ToString();
                                }
                                else
                                {
                                    date = "0" + dat.ToString();
                                }
 
                                txtemidate.Text = date + "/" + month + "/" + year;
                                 */
                            }
                            if (interval == 3)
                            {
                                DateTime d = Convert.ToDateTime(txtstartdate.Text);
                                DateTime emidate = d.AddMonths(3);
                                txtEMIDate.Text = emidate.ToString();
 
                            }
                        }
                    }
                }
            }
        }
 
        private void txtstartdate_TextChanged(object sender, EventArgs e)
        {
            // print ending date in textbox by change in date
            date = dateTimePicker2.Value.Date.ToString("dd");
            month = dateTimePicker2.Value.Month.ToString();
            year = dateTimePicker2.Value.Year.ToString();
            int mon = Convert.ToInt32(month);
            if (mon > 9)
            {
                month = mon.ToString();
            }
            else
            {
                month = "0" + mon.ToString();
            }
 
            if (txtLoanduration.Text.Length > 0)
            {
                int y = Convert.ToInt32(year) + Convert.ToInt32(txtLoanduration.Text);
                txtenddate.Text = date + "/" + month + "/" + y.ToString();
 
            }
            else
            {
                txtLoanduration.Text = "";
            }
        }
 
        private void btnCustSearch_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
            bool ex = false;
            if (txtCustAccNo.Text == string.Empty)
            {
                MessageBox.Show("Please Enter Account Number...""Error"MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                cmd = new SqlCommand("select * from customer where accno='" + txtCustAccNo.Text + "'", conn);
                dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    ex = true;
                }
                else
                {
                    ex = false;
                }
                dr.Close();
 
 
                if (ex)
                {
                    //check if account holder already took loan?????
                    cmd = new SqlCommand("select * from loan where accno='" + txtCustAccNo.Text + "'", conn);
                    dr = cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        Exist = true;
                    }
                    else
                    {
                        Exist = false;
                    }
                    dr.Close();
                }
                else
                {
                    MessageBox.Show("Account Not Exits""Not Exist"MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
 
 
                if (Exist)
                {
                    MessageBox.Show("Already Took Loan");
                }
                else
                {
 
 
                    //select account information from database
                    accno = txtCustAccNo.Text;
                    cmd = new SqlCommand("select account,acctype,name_f,name_s from customer where accno='" + txtCustAccNo.Text + "'", conn);
                    dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        txtCustAccType.Text = dr[0].ToString();
                        txtCuctType.Text = dr[1].ToString();
                        if (txtCuctType.Text == "single")
                        {
                            txtCustName1.Text = dr[2].ToString();
                            txtCustName2.Visible = false;
                        }
                        else
                        {
                            txtCustName1.Text = dr[2].ToString();
                            txtCustName2.Visible = true;
                            txtCustName2.Text = dr[3].ToString();
                        }
                    }
                    dr.Close();
                }
 
 
            }
 
 
        }
 
        private void cmbinterval_SelectedIndexChanged(object sender, EventArgs e)
        {
            intervalCal();
        }
 
        private void btnCnfLoan_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            if (txtCustAccNo.Text == string.Empty)
            {
                MessageBox.Show("Enter Account Number""Eoor"MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (txtWitAccNo.Text == string.Empty)
                {
                    MessageBox.Show("Enter Witness Account Number""Eroor"MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
 
                    if (txtEMIAmmount.Text == string.Empty)
                    {
                        MessageBox.Show("Please Fill All Loan Details ...""Eorro"MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
 
 
                        //lblmsg.Visible = true;
                        cmd = new SqlCommand("insert into loan values (@id,@type,@amount,@accno,@acctype,@name,@interest,@sdate,@edate,@duration,@interval,@noofemi,@firstemi,@emiammount,@totint,@totamount,@waccno,@wname,@wtype,@status)", conn);
                        cmd.Parameters.AddWithValue("id", txtloanid.Text);
                        cmd.Parameters.AddWithValue("type", cmbloantype.SelectedItem);
                        cmd.Parameters.AddWithValue("amount", txtloanamount.Text);
                        cmd.Parameters.AddWithValue("accno", txtCustAccNo.Text);
                        cmd.Parameters.AddWithValue("acctype", txtCustAccType.Text);
                        if (txtCustName2.Visible)
                        {
                            cmd.Parameters.AddWithValue("name", txtCustName1.Text + " And " + txtCustName2.Text);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("name", txtCustName1.Text);
                        }
                        cmd.Parameters.AddWithValue("interest", interest.ToString());
                        cmd.Parameters.AddWithValue("sdate", txtstartdate.Text.Substring(0, 10));
                        cmd.Parameters.AddWithValue("edate", txtenddate.Text);
                        cmd.Parameters.AddWithValue("duration", txtLoanduration.Text);
                        cmd.Parameters.AddWithValue("interval", interval.ToString());
                        cmd.Parameters.AddWithValue("noofemi", txtEMINo.Text);
                        cmd.Parameters.AddWithValue("firstemi"Convert.ToDateTime(txtEMIDate.Text));
                        cmd.Parameters.AddWithValue("emiammount", txtEMIAmmount.Text);
                        cmd.Parameters.AddWithValue("totint", txtTotalEMIAmount.Text);
                        cmd.Parameters.AddWithValue("totamount", txtTotalAmount.Text);
                        cmd.Parameters.AddWithValue("waccno", txtWitAccNo.Text);
                        cmd.Parameters.AddWithValue("wname", txtWitName1.Text);
                        cmd.Parameters.AddWithValue("wtype", txtWitAccType.Text);
                        cmd.Parameters.AddWithValue("status"true);
                        cmd.ExecuteNonQuery();
 
 
                        //insert into bank balance
                        double bb = BankBalance();
                        double newbb = bb - Convert.ToDouble(txtloanamount.Text);
                        cmd = new SqlCommand("update BankBalance set balance =" + newbb + "", conn);
                        cmd.ExecuteNonQuery();
 
 
 
 
                        MessageBox.Show("Successfully Loan Aproved Please Print The Form Copy.....");
 
                        frmReportForm rf = new frmReportForm();
 
                        //clear the crystal report viever
 
                        dt.Clear();
 
                        //select from customer
                        Reports.crNewLoan l = new Reports.crNewLoan();
 
                        da = new SqlDataAdapter("select * from loan l, customer c where l.accno='" + accno + "' AND c.accno='" + accno + "'", conn);
                        da.Fill(dt);
                        l.Database.Tables["Loan"].SetDataSource(dt);
                        rf.crystalReportViewer1.ReportSource = l;
                        rf.crystalReportViewer1.Refresh();
                        rf.Show();
 
 
                        ClearData();
                        autoId();
                    }
 
                }
 
 
 
            }
 
        }
 
        private void cmbloantype_SelectedIndexChanged(object sender, EventArgs e)
        {
            //set interest % on by loan type 
            if (cmbloantype.SelectedIndex == 1)
            {
                txtinterest.Text = "5%";
                interest = edu;
 
            }
            if (cmbloantype.SelectedIndex == 2)
            {
                txtinterest.Text = "12.5%";
                interest = home;
 
            }
            if (cmbloantype.SelectedIndex == 3)
            {
                txtinterest.Text = "10%";
                interest = personal;
 
            }
            if (cmbloantype.SelectedIndex == 4)
            {
                txtinterest.Text = "6.2%";
                interest = farm;
 
            }
            if (cmbloantype.SelectedIndex == 5)
            {
                txtinterest.Text = "8%";
                interest = car;
 
            }
        }
 
        private void btnClear_Click(object sender, EventArgs e)
        {
            ClearData();
            autoId();
        }
 
        double interest, amount, emino, emiamount, totalint, totalamount, duration, home, edu, personal, farm, car;
 
        private void frmNewLoan_Load(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("select * from loanrate ", conn);
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                edu = Convert.ToDouble(dr[0].ToString());
                home = Convert.ToDouble(dr[1].ToString());
                car = Convert.ToDouble(dr[2].ToString());
                farm = Convert.ToDouble(dr[3].ToString());
                personal = Convert.ToDouble(dr[4].ToString());
            }
            dr.Close();
 
            cmbloantype.SelectedIndex = 0;
            cmbinterval.SelectedIndex = 0;
            autoId();
            txtstartdate.Text = DateTime.Now.ToString();
        }
 
        public void autoId()
        {
            // auto loan id generator 
            conn = new SqlConnection(CS);
            conn.Open();
            int id;
            cmd = new SqlCommand("select MAX(id) from loan", conn);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                string s = dr[0].ToString();
                if (s == "")
                {
                    txtloanid.Text = "1";
                }
                else
                {
                    id = Convert.ToInt32(s) + 1;
                    txtloanid.Text = id.ToString();
                }
            }
            dr.Close();
 
        }
 
 
        public void intervalCal()
        {
            if (txtLoanduration.Text.Length > 0)
            {
                //set no of emi's
                if (cmbinterval.SelectedIndex == 1)
                {
                    emino = Convert.ToInt32(txtLoanduration.Text) * 4;
                    txtEMINo.Text = emino.ToString();
                    interval = 3;
 
                }
                if (cmbinterval.SelectedIndex == 2)
                {
                    emino = Convert.ToInt32(txtLoanduration.Text) * 2;
                    txtEMINo.Text = emino.ToString();
                    interval = 6;
                }
                if (cmbinterval.SelectedIndex == 3)
                {
                    emino = Convert.ToInt32(txtLoanduration.Text) * 1;
                    txtLoanduration.Text = emino.ToString();
                    interval = 12;
                }
            }
        }
 
        public void ClearData()
        {
           // lblmsg.Visible = false;
            txtWitName1.Clear();
            txtWitName2.Clear();
            txtWitAccType.Clear();
            txtWitAccNo.Clear();
            txtWitType.Clear();
            txtTotalAmount.Clear();
            txtCustName1.Clear();
            txtCustName2.Clear();
            txtloanamount.Clear();
            txtTotalEMIAmount.Clear();
            txtinterest.Clear();
            txtEMINo.Clear();
            txtEMIDate.Clear();
            txtEMIAmmount.Clear();
            txtenddate.Clear();
            txtLoanduration.Clear();
            txtCuctType.Clear();
            //txtname1.Clear();
            txtCustAccType.Clear();
            txtCustAccNo.Clear();
            cmbinterval.SelectedIndex = 0;
            cmbloantype.SelectedIndex = 0;
 
        }
 
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
namespace FinoBank_Application
{
    public partial class frmPassbook : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmPassbook()
        {
            InitializeComponent();
        }
 
 
        //SqlCommand cmd;
        SqlDataAdapter da;
        SqlConnection conn;
        DataTable dt = new DataTable();
        bool exist = false;
 
        private void frmPassbook_Load(object sender, EventArgs e)
        {
 
        }
 
        private void btnSearch_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
            //check accno is exist
            if (txtAccountNumber.Text == string.Empty)
            {
 
                MessageBox.Show("Please enter account number! ""Enter Account"MessageBoxButtons.OK, MessageBoxIcon.Information);
 
            }
            else
            {
                
                SqlCommand cmd = new SqlCommand("select * from customer where accno='" + txtAccountNumber.Text + "' AND status='" + true + "'", conn);
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    exist = true;
                }
                else
                {
                    exist = false;
                }
                dr.Close();
            }
 
            //clear the crystal report viever
            if (exist)
            {
                dt.Clear();
                Reports.crPassbook p = new Reports.crPassbook();
                crystalReportViewer1.ReportSource = null;
                p.Refresh();
                crystalReportViewer1.Refresh();
 
                //select from customer
 
                da = new SqlDataAdapter("select * from customer c, passbook p where c.accno='" + txtAccountNumber.Text + "' AND p.accno='" + txtAccountNumber.Text + "'", conn);
                da.Fill(dt);
                //Saurashtra_Gramin_Bank.Reports.crPassbook p = new Saurashtra_Gramin_Bank.Reports.crPassbook();
                p.Database.Tables["DataTable"].SetDataSource(dt);
                crystalReportViewer1.ReportSource = p;
                crystalReportViewer1.Refresh();
 
 
            }
            else
            {
                MessageBox.Show("Account Number Does not Exist""Invalid Account Number"MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
 
 
        }
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
namespace FinoBank_Application
{
    public partial class frmPayLoanEMI : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmPayLoanEMI()
        {
            InitializeComponent();
        }
 
        SqlCommand cmd;
        SqlDataReader dr;
        SqlDataAdapter da;
        SqlConnection conn;
        DataTable dt = new DataTable();
        DateTime d1;
        DateTime nemi;
        bool exist = false;
        string firstemi, emidate, time = DateTime.Now.ToString("hh:mm:ss"); //mail = "hadiya12345678.yk@gmail.com";
        //string date, month, year;
 
        private void cmbemi_SelectedIndexChanged(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
 
            //check the emi status
            try
            {
                if (cmbemi.SelectedIndex == 0)
                {
 
                }
                else
                {
                    cmd = new SqlCommand("select * from emi where loanid=@id AND emino=@no", conn);
                    cmd.Parameters.AddWithValue("id", txtid.Text);
                    cmd.Parameters.AddWithValue("no", cmbemi.SelectedItem);
                    dr = cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        txtstatus.Text = "EMI Paid ";
                    }
                    else
                    {
                        txtstatus.Text = "EMI UnPaid ";
                    }
                    dr.Close();
                }
            }
            catch
            {
 
            }
        }
 
        int no, interval, emino;
 
        private void btnPay_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
            if (txtid.Text == string.Empty)
            {
                MessageBox.Show("Please enter Loan ID!");
 
            }
            else
            {
                //dr.Close();
                if (cmbemi.SelectedIndex == 0)
                {
                    MessageBox.Show("Select Emi Number.");
                }
                else
                {
 
                    bool exist = false;
 
                    //select email id
                    //lblmsg1.Visible = false;
                    //cmd = new SqlCommand("select email_f from customer where accno='" + txtaccno.Text + "' AND status ='" + true + "'", conn);
                    //dr = cmd.ExecuteReader();
                    //if (dr.Read())
                    //{
                    //    mail = dr[0].ToString();
                    //}
                    //dr.Close();
 
                    //check if this EMI is paid
                    cmd = new SqlCommand("select * from emi where loanid='" + txtid.Text + "'AND emino='" + cmbemi.SelectedItem + "'", conn);
                    dr = cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        exist = true;
                    }
                    dr.Close();
 
 
                    if (exist)
                    {
                        MessageBox.Show("EMI Already Paid"""MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        if (previousEMI())
                        {
 
                            //insert into bank balance
                            double bb = BankBalance();
                            double newbb = bb + Convert.ToDouble(txtemiamount.Text);
                            cmd = new SqlCommand("update BankBalance set balance =" + newbb + "", conn);
                            cmd.ExecuteNonQuery();
 
 
                            lblmsg.Visible = true;
                            dr.Close();
                            cmd = new SqlCommand("insert into emi(loanid,accno,name,date,emino,emiamount,emistatus,nextemi) values (@id,@accno,@name,@date,@emino,@ammount,@status,@nextemi)", conn);
                            cmd.Parameters.AddWithValue("id", txtid.Text);
                            cmd.Parameters.AddWithValue("accno", txtaccno.Text);
                            cmd.Parameters.AddWithValue("name", txtname.Text);
                            cmd.Parameters.AddWithValue("date", lblDateFormat.Text);
                            cmd.Parameters.AddWithValue("emino", cmbemi.SelectedItem);
                            cmd.Parameters.AddWithValue("ammount", txtemiamount.Text);
                            cmd.Parameters.AddWithValue("status""EMI Paid");
                            cmd.Parameters.AddWithValue("nextemi", nemi);
 
                            cmd.ExecuteNonQuery();
                            int paidemi = emino + 1;
                            //set paid emis 
                            cmd = new SqlCommand("update emi set paidemi=@emi where loanid='" + txtid.Text + "'", conn);
                            cmd.Parameters.AddWithValue("emi", paidemi.ToString());
                            cmd.ExecuteNonQuery();
 
                            //insert into Transaction
                            cmd = new SqlCommand("insert into trans_info values(@date,@time,@accno,@type,@ammount)", conn);
                            cmd.Parameters.AddWithValue("date", lblDateFormat.Text);
                            cmd.Parameters.AddWithValue("time", time);
                            cmd.Parameters.AddWithValue("accno", txtaccno.Text);
                            cmd.Parameters.AddWithValue("type", txtloantype.Text + " 's " + cmbemi.SelectedItem + " Paid");
                            cmd.Parameters.AddWithValue("ammount", txtemiamount.Text);
 
                            cmd.ExecuteNonQuery();
 
                            //send mail
                            //try
                            //{
 
                            //    gmail gmlsnd = new gmail();
                            //    gmlsnd.auth("sgbdhokadava@gmail.com", "yogesh@33@sgb");
                            //    gmlsnd.To = mail;
                            //    gmlsnd.Subject = "Loan EMI Sucessfully Paid";
                            //    gmlsnd.fromAlias = "Saurashtra Gramin Bank - Dhokadva";
                            //    gmlsnd.Message = "Dear " + txtname.Text + " Your " + txtloantype.Text + " Asociate With Account Number " + txtaccno.Text + " 's " + cmbemi.SelectedItem + " is sucessfully Paid On " + lbldate.Text + " And " + time + " Your Next Emi Date is :: " + lblnextemidate;
                            //    gmlsnd.Priority = 1;
                            //    gmlsnd.send();
                            //}
                            //catch (Exception ex)
                            //{
                            //      MessageBox.Show("Internet Connection Is Required ", "Not Internet", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            //}
 
                            MessageBox.Show(" EMI Recieved Successfully! ... Please Print The Reciept""sucess"MessageBoxButtons.OK, MessageBoxIcon.Information);
                            lblloader.Visible = true;
                            lblmsg.Visible = true;
                            lblmsg.BringToFront();
 
                            //show crystal report
                            Reports.crEMIPayment emi = new Reports.crEMIPayment();
 
                            //clear data table 
                            dt.Clear();
 
                            frmReportForm rf = new frmReportForm();
                            da = new SqlDataAdapter("select * from emi where loanid='" + txtid.Text + "' AND emino='" + cmbemi.SelectedItem + "'", conn);
                            da.Fill(dt);
                            emi.Database.Tables["emi"].SetDataSource(dt);
                            rf.crystalReportViewer1.ReportSource = emi;
                            rf.crystalReportViewer1.Refresh();
                            rf.Show();
 
                        }
                        else
                        {
                            MessageBox.Show("Previous EMI is Not Paid ...");
                        }
                    }
                    txtid.Clear();
                    ClearData();
                }
 
 
 
            }
 
        }
 
        private void btnClear_Click(object sender, EventArgs e)
        {
            txtid.Clear();
            ClearData();
        }
 
        private void btnSearch_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            if (txtid.Text == string.Empty)
            {
                MessageBox.Show("Please enter Loan ID""info"MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                //clear all textbox
                ClearData();
 
                cmd = new SqlCommand("select * from loan where id='" + txtid.Text + "'", conn);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    exist = true;
                }
                else
                {
                    exist = false;
 
                }
                dr.Close();
 
                if (exist)
                {
 
 
                    cmd = new SqlCommand("select type,amount,accno,name,interest,duration,interval,emiammount,totalinterest,totalamount,noofemi from loan where id='" + txtid.Text + "'", conn);
                    dr = cmd.ExecuteReader();
 
                    while (dr.Read())
                    {
                        txtloantype.Text = dr[0].ToString();
                        txtamount.Text = dr[1].ToString();
                        txtaccno.Text = dr[2].ToString();
                        txtname.Text = dr[3].ToString();
                        txtinterest.Text = dr[4].ToString();
                        txtduration.Text = dr[5].ToString();
                        txtinterval.Text = dr[6].ToString();
                        txtemiamount.Text = dr[7].ToString();
                        txtintamount.Text = dr[8].ToString();
                        txttotal.Text = dr[9].ToString();
                        txtnoemi.Text = dr[10].ToString();
                        no = Convert.ToInt32(dr[10]);
 
                    }
 
                    dr.Close();
 
                    NoOfPaidEmi();
                    AddEMI();
                    cmbemi.SelectedIndex = 0;
 
                    //calculate the next date of emi
                    if (Convert.ToInt32(txtpaidemi.Text) > 0)
                    {
                        int emino = Convert.ToInt32(txtpaidemi.Text);
                        cmd = new SqlCommand("select nextemi from emi where loanid=@id AND emino=@no", conn);
                        cmd.Parameters.AddWithValue("id", txtid.Text);
                        cmd.Parameters.AddWithValue("no""EMI-" + emino.ToString());
                        dr = cmd.ExecuteReader();
                        if (dr.Read())
                        {
                            emidate = dr[0].ToString();
                        }
                        dr.Close();
                        nextDate();
                        //date = emidate.Substring(0, 2);
                        //month = emidate.Substring(3, 2);
                        //year = emidate.Substring(6, 4);
 
 
                    }
 
 
                    else
                    {
                        cmd = new SqlCommand("select firstemi from loan where id='" + txtid.Text + "'", conn);
                        dr = cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            firstemi = dr[0].ToString();
                        }
                        dr.Close();
 
                        d1 = Convert.ToDateTime(firstemi);
                        nemi = d1;
                        txtEMIDate.Text = d1.ToString("dd/MM/yyyy");
                    }
                    // MessageBox.Show(date + month+year);
                }
                else
                {
                    MessageBox.Show("Loan Id Not Exist"""MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
 
            }
        }
 
        private void frmPayLoanEMI_Load(object sender, EventArgs e)
        {
            lblloader.Visible = false;
            cmbemi.SelectedIndex = 0;
            lblDateFormat.Text = DateTime.Now.ToString("dd/MM/yyyy");
            lblmsg.Visible = false;
        }
 
 
        //bank baalnce
        private double BankBalance()
        {
            dr.Close();
            double bal = 0;
            cmd = new SqlCommand("select * from BankBalance", conn);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                bal = Convert.ToDouble(dr[0].ToString());
            }
            dr.Close();
            return bal;
        }
 
 
        void ClearData()
        {
            //clear all fields
            //lblmsg1.Visible = false;
            txtaccno.Clear();
            txtamount.Clear();
            txtduration.Clear();
            txtemiamount.Clear();
            txtintamount.Clear();
            txtinterest.Clear();
            txtloantype.Clear();
            txtname.Clear();
            txtnoemi.Clear();
            txtpaidemi.Clear();
            txtstatus.Clear();
            txttotal.Clear();
            txtEMIDate.Text = "00/00/0000";
            cmbemi.Items.Clear();
            cmbemi.Items.Add("Select EMI Number");
            cmbemi.SelectedIndex = 0;
        }
 
        public void NoOfPaidEmi()
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            emino = 0;
            // calculate the number of paid emi
            cmd = new SqlCommand("select emino from emi where loanid='" + txtid.Text + "'  AND emistatus =@emino", conn);
            cmd.Parameters.AddWithValue("emino""EMI Paid");
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                emino = emino + 1;
            }
            dr.Close();
            if (emino == no)
            {
                lblmsg.Visible = true;
                lblmsg.BringToFront();
                cmd = new SqlCommand("update loan set status=@st where id='" + txtid.Text + " '", conn);
                cmd.Parameters.AddWithValue("st"false);
                cmd.ExecuteNonQuery();
            }
            else
            {
                lblmsg.Visible = false;
            }
            txtpaidemi.Text = emino.ToString();
        }
 
        public void AddEMI()
        {
            int i = 1;
            cmbemi.Items.Clear();
            cmbemi.Items.Add("Select EMI Number");
            while (i <= no)
            {
                cmbemi.Items.Add("EMI-" + i.ToString());
                i++;
            }
        }
 
        public void nextDate()
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
 
            // print the next date 
            cmd = new SqlCommand("select interval from loan where id='" + txtid.Text + "'", conn);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                interval = Convert.ToInt32(dr["interval"].ToString());
            }
            dr.Close();
 
 
 
 
            //print emi date by emi interval
            if (interval == 12)
            {
                DateTime d = Convert.ToDateTime(emidate);
                DateTime d1 = d.AddMonths(12);
                txtEMIDate.Text = d1.ToString("dd/MM/yyyy");
                nemi = d1;
 
            }
            if (interval == 6)
            {
 
                DateTime d = Convert.ToDateTime(emidate);
                DateTime d1 = d.AddMonths(6);
                txtEMIDate.Text = d1.ToString("dd/MM/yyyy");
                nemi = d1;
            }
            if (interval == 3)
            {
 
                DateTime d = Convert.ToDateTime(emidate);
                DateTime d1 = d.AddMonths(3);
                txtEMIDate.Text = d1.ToString("dd/MM/yyyy");
                nemi = d1;
            }
        }
        protected bool previousEMI()
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            int npemi = Convert.ToInt32(txtpaidemi.Text);
            int sid = cmbemi.SelectedIndex - 1;
            if (npemi > 1)
            {
                cmd = new SqlCommand("select * from emi where emino='EMI-" + sid + "'", conn);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    return true;
                }
                dr.Close();
                return false;
            }
            else
            {
                return true;
            }
        }
 
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
 
 
namespace FinoBank_Application
{
    public partial class frmReminder : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmReminder()
        {
            InitializeComponent();
        }
 
        SqlCommand cmd;
        SqlConnection conn;
 
 
 
        private void frmReminder_Load(object sender, EventArgs e)
        {
 
        }
 
        private void frmReminder_FormClosed(object sender, FormClosedEventArgs e)
        {
 
        }
 
 
 
        private void pictureBox1_Click(object sender, EventArgs e)
        {
 
        }
 
        private void btnDeleteReminder_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("delete from reminder where title='" + lblTitle.Text + "'", conn);
            cmd.ExecuteNonQuery();
            //MessageBox.Show("delete");
            this.Close();
 
        }
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace FinoBank_Application
{
    public partial class frmReportForm : Form
    {
        public frmReportForm()
        {
            InitializeComponent();
        }
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
namespace FinoBank_Application
{
    public partial class frmResetPassword : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmResetPassword()
        {
            InitializeComponent();
        }
 
        SqlCommand cmd;
        SqlDataReader dr;
        SqlConnection conn;
        //MailMessage message;
       // SmtpClient smtp;
        string mail, pass;
 
        private void frmResetPassword_Load(object sender, EventArgs e)
        {
 
        }
 
        private void btnCheck_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            bool exist = false;
            cmd = new SqlCommand("select * from Users where username=@user", conn);
            cmd.Parameters.AddWithValue("user", txtusername.Text);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                exist = true;
            }
            else
            {
                exist = false;
            }
            dr.Close();
            if (exist)
            {
 
                lblque.Visible = true;
                txtans.Visible = true;
                //label6.Visible = true;
                btnVerify.Visible = true;
                cmd = new SqlCommand("select question , answer from Users where username='" + txtusername.Text + "'", conn);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    lblque.Text = dr[0].ToString();
                }
                dr.Close();
            }
            else
            {
                MessageBox.Show("Enter Valid Username""Error"MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtusername.Clear();
                lblque.Visible = false;
                txtans.Visible = false;
                btnVerify.Visible = false;
 
            }
        }
 
        private bool emailValidation()
        {
            if (Regex.IsMatch(pass, "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$"))
            {
                return true;
            }
 
            return false;
        }
 
        private void btnVerify_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            bool exist = false;
            string userpass = "";
            Random rnd = new Random();
            string[] pass = new string[10];
            for (int i = 0; i < pass.Length; i++)
            {
                pass[i] = password(rnd);
                userpass = pass[i];
            }
 
            cmd = new SqlCommand("select email from Users where question=@que AND answer=@ans AND username=@user", conn);
            cmd.Parameters.AddWithValue("que", lblque.Text);
            cmd.Parameters.AddWithValue("ans", txtans.Text);
            cmd.Parameters.AddWithValue("user", txtusername.Text);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                exist = true;
                mail = dr[0].ToString();
            }
            else
            {
                exist = false;
            }
            dr.Close();
 
            if (exist)
            {
 
                try
                {
                    /*
                    gmail gmlsnd = new gmail();
                    gmlsnd.auth("sgbdhokadava@gmail.com", "yogesh@33@sgb");
                    gmlsnd.To = mail;
                    gmlsnd.Subject = "Reset Password";
                    gmlsnd.fromAlias = "Saurashtra Gramin Bank - Dhokadva";
                    gmlsnd.Message = "This Is Your Temparory Password For Loginto SGB System . Set New Passoword After Loginto System . Temparory Password => " + userpass;
                    gmlsnd.Priority = 1;
                    gmlsnd.send();
                    */
                    cmd = new SqlCommand("update Users set password='" + userpass + "' where username ='" + txtusername.Text + "'", conn);
                    cmd.ExecuteNonQuery();
 
                    label3.Visible = true;
                    label3.BringToFront();
 
                    MessageBox.Show("Your Temparory Passowrd Is Send To Your Register Email Address Use That Passowrd To Log Into System""Mail Send"MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                catch (Exception ex)
                {
                     MessageBox.Show(ex.Message);
 
                    // MessageBox.Show("Internet Connection Is Required ", "Not Internet", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
 
            }
            else
            {
                MessageBox.Show("Please Enter Correct Answer of Given Question ""Incorrect Answer"MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            dr.Close();
        }
 
        private void TextBox_Leave(object sender, EventArgs e)
        {
            TextBox t = (TextBox)sender;
            if (t.Text.Trim() == String.Empty)
            {
                errorProvider1.SetError(t, "Please Enter Password");
               // err = 0;
            }
 
        }
 
        //random password
        public static string password(Random random)
        {
            string characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
            StringBuilder result = new StringBuilder(8);
            for (int i = 0; i < 8; i++)
            {
                result.Append(characters[random.Next(characters.Length)]);
            }
            return result.ToString();
        }
 
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
 
 
namespace FinoBank_Application
{
    public partial class frmSetReminder : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmSetReminder()
        {
            InitializeComponent();
        }
 
        SqlCommand cmd;
        SqlDataReader dr;
        SqlConnection conn;
        string user;
 
        private void frmSetReminder_Load(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
            this.dateTimePicker1.CustomFormat = "hh:mm:ss";
            this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
            this.dateTimePicker1.ShowUpDown = true;
            txtDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
 
            //select username
            cmd = new SqlCommand("select username from tempuser", conn);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                user = dr[0].ToString();
            }
            dr.Close();
 
        }
 
        private void btnSetReminder_Click(object sender, EventArgs e)
        {
            if (txtMsg.Text == string.Empty || txtTitle.Text == string.Empty)
            {
                MessageBox.Show("Title or Messge cannot be blank!""Info"MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                conn = new SqlConnection(CS);
                conn.Open();
                cmd = new SqlCommand("insert into reminder values ('" + txtDate.Text + "','" + dateTimePicker1.Value.ToString("hh:mm:ss") + "','" + txtMsg.Text + "','" + user + "','" + txtTitle.Text + "')", conn);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Reminder created sucessfully!""Reminder Set"MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 
        private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
        {
            txtDate.Text = dateTimePicker2.Value.ToString("dd/MM/yyyy");
        }
 
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
namespace FinoBank_Application
{
    public partial class frmTransferMoney : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
        public frmTransferMoney()
        {
            InitializeComponent();
        }
 
        SqlCommand cmd;
        SqlDataReader dr;
        SqlConnection conn;
        string time;
 
 
 
        // Auto Increment tranfer ID
        private void autoId()
        {
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("select MAX(id) from Transfer", conn);
            string id = cmd.ExecuteScalar().ToString();
            if (id != string.Empty)
            {
                double wid = Convert.ToDouble(id);
                wid = wid + 1;
                txtTranferID.Text = wid.ToString();
            }
            else
            {
                txtTranferID.Text = "1";
            }
 
        }
 
 
        private void frmTransferMoney_Load(object sender, EventArgs e)
        {
            txtDate.Text = DateTime.Now.ToString("dd-MM-yyyy");
            time = DateTime.Now.ToString("hh:mm:ss");
            txtTime.Text = time;
            autoId();
        }
 
        //get avliable balance from databse (Common for both)
        public string balance(string acno)
        {
            string balance = "";
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("select balance from balance where accno='" + acno + "'", conn);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                balance = dr[0].ToString();
            }
            else
            {
                balance = "0";
            }
            dr.Close();
            return balance;
        }
 
        private void btnTransfer_Click(object sender, EventArgs e)
        {
 
            if (txtTransAccount.Text == string.Empty)
            {
                MessageBox.Show("Please enter the account number!""Error"MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                //Check if transferee exist or not
                bool exist = false;
                conn = new SqlConnection(CS);
                conn.Open();
                cmd = new SqlCommand("select * from customer where accno='" + txtTransAccount.Text + "' AND status='" + true + "'", conn);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    exist = true;
                }
                else
                {
                    exist = false;
                }
                dr.Close();
 
 
                //get tranferree details
                if (exist)
                {
                    cmd = new SqlCommand("select account,acctype,name_f from customer where accno='" + txtTransAccount.Text + "' ", conn);
                    dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        txtTransferAccountType.Text = dr[0].ToString();
                        txtTransferCustomerType.Text = dr[1].ToString();
                        txtTransferAccountHolder.Text = dr[2].ToString();
                    }
                    dr.Close();
                    string sbal = balance(txtTransAccount.Text);
                    txtTransferAccountBalance.Text = sbal;
 
                }
                else
                {
                    MessageBox.Show("Account doesn't exist!");
                }
 
            }
        }
 
        private void btnReceAccount_Click(object sender, EventArgs e)
        {
            if (txtReceAccountNumber.Text == string.Empty)
            {
                MessageBox.Show("Please enter the account number!""Error"MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                //Check if recipient exist or not
                bool exist = false;
                conn = new SqlConnection(CS);
                conn.Open();
                cmd = new SqlCommand("select * from customer where accno='" + txtReceAccountNumber.Text + "' AND status='" + true + "'", conn);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    exist = true;
                }
                else
                {
                    exist = false;
                }
                dr.Close();
 
 
                if (exist)
                {
                    if (txtTransAccount.Text == txtReceAccountNumber.Text)
                    {
                        MessageBox.Show("Both account number can't be same!""Error"MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        //get recipeient data
                        cmd = new SqlCommand("select account,acctype,name_f from customer where accno='" + txtReceAccountNumber.Text + "' ", conn);
                        dr = cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            txtReceAccountType.Text = dr[0].ToString();
                            txtReceCustomerType.Text = dr[1].ToString();
                            txtReceAccountHolder.Text = dr[2].ToString();
                        }
                        dr.Close();
                        string rbal = balance(txtReceAccountNumber.Text);
                        txtReceAvailableBalance.Text = rbal;
 
                    }
 
                }
                else
                {
                    MessageBox.Show("Account doesn't exist!");
                }
 
            }
 
        }
 
        public void Clear()
        {
            txtTransAccount.Clear();
            txtTransferAccountBalance.Clear();
            txtTransferAccountHolder.Clear();
            txtTransferAccountType.Clear();
            txtTransferCustomerType.Clear();
            txtReceAccountNumber.Clear();
            txtReceAccountHolder.Clear();
            txtReceAccountType.Clear();
            txtReceAvailableBalance.Clear();
            txtReceCustomerType.Clear();
 
            txtAmountTransfer.Clear();
 
        }
 
        private void btnClearFields_Click(object sender, EventArgs e)
        {
            Clear();
        }
 
        private void btnMoneyTransfer_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(CS);
            conn.Open();
 
            if (txtAmountTransfer.Text == string.Empty)
            {
                MessageBox.Show("Please Enter Amount!");
            }
            else
            {
                int bal, bal1, amt;
                bal = Convert.ToInt32(txtTransferAccountBalance.Text);
                bal1 = Convert.ToInt32(txtReceAvailableBalance.Text);
                amt = Convert.ToInt32(txtAmountTransfer.Text);
                int avlble = bal - amt;
                int avlble1 = bal1 + amt;
                if (amt > bal)
                {
                    MessageBox.Show("Amount must be less or equal to the balance!""Error"MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    //insert into transfer table
                    cmd = new SqlCommand("insert into Transfer values (@id,@fno,@fnm,@ftype,@rno,@rnm,@rtype,@amount,@detail,@date)", conn);
                    cmd.Parameters.AddWithValue("id", txtTranferID.Text);
                    cmd.Parameters.AddWithValue("fno", txtTransAccount.Text);
                    cmd.Parameters.AddWithValue("fnm", txtTransferAccountHolder.Text);
                    cmd.Parameters.AddWithValue("ftype", txtTransferAccountType.Text);
                    cmd.Parameters.AddWithValue("rno", txtTransAccount.Text);
                    cmd.Parameters.AddWithValue("rnm", txtReceAccountHolder.Text);
                    cmd.Parameters.AddWithValue("rtype", txtReceAccountType.Text);
                    cmd.Parameters.AddWithValue("amount", txtAmountTransfer.Text);
                    cmd.Parameters.AddWithValue("detail""Transfer Money From " + txtTransAccount.Text + " To  " + txtReceAccountNumber.Text);
                    cmd.Parameters.AddWithValue("date", txtDate.Text);
                    cmd.ExecuteNonQuery();
 
                    //insert into transferee passbook
                    cmd = new SqlCommand("insert into  passbook (accno,date,info,transfer,avlabl,time) values (@no,@date,@info,@transfer,@avalabl,@time)", conn);
                    cmd.Parameters.AddWithValue("no", txtTransAccount.Text);
                    cmd.Parameters.AddWithValue("date", txtDate.Text);
                    cmd.Parameters.AddWithValue("info""Transfer to " + txtReceAccountNumber.Text);
                    cmd.Parameters.AddWithValue("transfer", txtAmountTransfer.Text);
                    cmd.Parameters.AddWithValue("avalabl", avlble.ToString());
                    cmd.Parameters.AddWithValue("time", time);
                    cmd.ExecuteNonQuery();
 
                    //insert into recipient passbook
                    cmd = new SqlCommand("insert into  passbook (accno,date,info,transfer,avlabl,time) values (@no,@date,@info,@transfer,@avalabl,@time)", conn);
                    cmd.Parameters.AddWithValue("no", txtReceAccountNumber.Text);
                    cmd.Parameters.AddWithValue("date", txtDate.Text);
                    cmd.Parameters.AddWithValue("info""Transfer From " + txtTransAccount.Text);
                    cmd.Parameters.AddWithValue("transfer", txtAmountTransfer.Text);
                    cmd.Parameters.AddWithValue("avalabl", avlble1.ToString());
                    cmd.Parameters.AddWithValue("time", time);
                    cmd.ExecuteNonQuery();
 
 
                    //insert into balance of both recipient and transferee
 
                    cmd = new SqlCommand("update balance set balance='" + Convert.ToInt32(avlble1) + "' where accno='" + txtReceAccountNumber.Text + "'", conn);
                    cmd.ExecuteNonQuery();
 
                    cmd = new SqlCommand("update balance set balance='" + Convert.ToInt32(avlble) + "' where accno='" + txtTransAccount.Text + "'", conn);
                    cmd.ExecuteNonQuery();
 
 
                    //insert into Transaction of recever
                    cmd = new SqlCommand("insert into trans_info values(@date,@time,@accno,@type,@ammount)", conn);
                    cmd.Parameters.AddWithValue("date", txtDate.Text);
                    cmd.Parameters.AddWithValue("time", time);
                    cmd.Parameters.AddWithValue("accno", txtReceAccountNumber.Text);
                    cmd.Parameters.AddWithValue("type""Transfer Money from " + txtTransAccount.Text);
                    cmd.Parameters.AddWithValue("ammount", txtAmountTransfer.Text);
                    cmd.ExecuteNonQuery();
 
 
                    //insert into Transaction transferee
                    cmd = new SqlCommand("insert into trans_info values(@date,@time,@accno,@type,@ammount)", conn);
                    cmd.Parameters.AddWithValue("date", txtDate.Text);
                    cmd.Parameters.AddWithValue("time", time);
                    cmd.Parameters.AddWithValue("accno", txtReceAccountNumber.Text);
                    cmd.Parameters.AddWithValue("type""Transfer Money To " + txtReceAccountNumber.Text);
                    cmd.Parameters.AddWithValue("ammount", txtAmountTransfer.Text);
                    cmd.ExecuteNonQuery();
 
                    MessageBox.Show("Balance Transfer Success Please print Reciept""Sucess"MessageBoxButtons.OK, MessageBoxIcon.Information);
 
 
 
                    //print reciept
                    conn = new SqlConnection(CS);
                    conn.Open();
                    frmReportForm r = new frmReportForm();
                    DataTable dt = new DataTable();
                    r.crystalReportViewer1.ReportSource = null;
                    r.crystalReportViewer1.Refresh();
                    dt.Clear();
                    cmd = new SqlCommand("select * from Transfer where fromaccno='" + txtTransAccount.Text + "' AND toaccno='" + txtReceAccountNumber.Text + "' AND id='" + txtTranferID.Text + "'", conn);
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    da.Fill(dt);
                    Reports.crTransferMoney t = new Reports.crTransferMoney();
                    t.Database.Tables["Transfer"].SetDataSource(dt);
                    r.crystalReportViewer1.ReportSource = t;
                    r.crystalReportViewer1.Refresh();
                    r.Show();
 
                    Clear();
                    autoId();
 
                }
 
 
            }
        }
    }
}

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Net.Mail;
 
 
namespace FinoBank_Application
{
    public partial class frmWithdrawal : Form
    {
        string CS = ConfigurationManager.ConnectionStrings["FinobankDB"].ConnectionString;
 
        public frmWithdrawal()
        {
            InitializeComponent();
        }
 
        SqlConnection conn;
        SqlCommand cmd;
        SqlDataReader dr;
 
        string time;
 
        //Generate autoID in withdraw
        private void autoId()
        {
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("select MAX(id) from withdraw", conn);
            string id = cmd.ExecuteScalar().ToString();
            if (id != string.Empty)
            {
                double wid = Convert.ToDouble(id);
                wid++;
                txtWithdrawId.Text = wid.ToString();
            }
            else
            {
                txtWithdrawId.Text = "1";
            }
        }
 
        //display photo
        public Image DisPhoto(byte[] photo)
        {
            MemoryStream ms = new MemoryStream(photo);
            return Image.FromStream(ms);
        }
 
        //display sign
        public Image DisSign(byte[] photo)
        {
            MemoryStream ms = new MemoryStream(photo);
            return Image.FromStream(ms);
        }
 
        public string ConvertNumbertoWords(long number)
        {
            if (number.ToString() == ""return "Zero";
            if (number == 0) return "Zero";
            if (number < 0) return "minus " + ConvertNumbertoWords(Math.Abs(number));
            string words = "";
 
            if ((number / 10000000) > 0)
            {
                words += ConvertNumbertoWords(number / 10000000) + " Corer ";
                number %= 10000000;
            }
            if ((number / 100000) > 0)
            {
                words += ConvertNumbertoWords(number / 100000) + " Lakes ";
                number %= 100000;
            }
            if ((number / 1000) > 0)
            {
                words += ConvertNumbertoWords(number / 1000) + " Thousand ";
                number %= 1000;
            }
            if ((number / 100) > 0)
            {
                words += ConvertNumbertoWords(number / 100) + " Hundred ";
                number %= 100;
            }
            //if ((number / 10) > 0)  
            //{  
            // words += ConvertNumbertoWords(number / 10) + " RUPEES ";  
            // number %= 10;  
            //}  
            if (number > 0)
            {
                if (words != "") words += "And ";
                var unitsMap = new[]
        {
            "Zero""One""Two""Three""Four""Five""Six""Seven""Eight""Nine""Ten""Eleven""Twelve""Thirteen""Fourteen""Fifteen""Sixtenn""Seventeen""Eighteen""Ninteen"
        };
                var tensMap = new[]
        {
            "Zero""Ten""Twenty""Thirty""Fourty""Fifty""Sixty""Seventy""Eighty""Ninety"
        };
                if (number < 20) words += unitsMap[number];
                else
                {
                    words += tensMap[number / 10];
                    if ((number % 10) > 0) words += " " + unitsMap[number % 10];
                }
            }
            return words;
 
        }
 
 
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (txtAccountNumber.Text == string.Empty)
            {
                MessageBox.Show("Please enter the account number!""Error"MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
 
                //select account type
                conn = new SqlConnection(CS);
                conn.Open();
                cmd = new SqlCommand("select acctype from customer where accno='" + txtAccountNumber.Text + "' AND  status='" + true + "'", conn);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    txtCustomerType.Text = dr[0].ToString();
                }
                else
                {
                    MessageBox.Show("Account Number Not Associate With This Bank""Error"MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                dr.Close();
 
                string avilbl = balance(txtAccountNumber.Text);
 
                cmd = new SqlCommand("select account,name_f,name_s,sign_f,photo_f,sign_s,photo_s,email_f,email_s from customer where accno='" + txtAccountNumber.Text + "' and status='" + true + "'", conn);
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    if (txtCustomerType.Text == "single")
                    {
                        pbPhoto1.Visible = false;
                        pbSign1.Visible = false;
                        txtAccountType.Text = dr[0].ToString();
                        txtFirstAccountHolder.Text = dr[1].ToString();
                        txtCustomerType.Text = "single";
                        //txtCustomerType.Text = dr[2].ToString();
                        pbSign.Image = DisSign((byte[])dr[3]);
                        pbPhoto.Image = DisPhoto((byte[])dr[4]);
                        txtAccountBalance.Text = avilbl;
                        //email1 = dr[7].ToString();
 
                    }
 
                    if (txtCustomerType.Text == "joint")
                    {
                        pbPhoto1.Visible = true;
                        pbSign1.Visible = true;
                        txtAccountType.Text = dr[0].ToString();
                        txtFirstAccountHolder.Text = dr[1].ToString();
                        txtCustomerType.Text = dr[2].ToString();
                        txtCustomerType.Text = "joint";
                        pbSign.Image = DisSign((byte[])dr[3]);
                        pbPhoto.Image = DisPhoto((byte[])dr[4]);
 
                        //Second person Details
                        txtSecondAccountHolder.Text = dr[2].ToString();
                        pbSign1.Image = DisSign((byte[])dr[5]);
                        pbPhoto1.Image = DisPhoto((byte[])dr[6]);
                        txtAccountBalance.Text = avilbl;
 
                    }
 
 
                }
                dr.Close();
 
            }
        }
 
        public string balance(string acno)
        {
            //get avliable balance from databse
            conn = new SqlConnection(CS);
            conn.Open();
            string balance = "";
            cmd = new SqlCommand("select balance from balance where accno='" + acno + "' ", conn);
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                balance = dr[0].ToString();
 
            }
            else
            {
                balance = "0";
            }
            dr.Close();
            return balance;
        }
 
        private void btnClear_Click(object sender, EventArgs e)
        {
            Clear();
        }
 
        public void Clear()
        {
            txtAccountNumber.Clear();
            txtFirstAccountHolder.Clear();
            txtSecondAccountHolder.Clear();
            txtAccountType.Clear();
            txtAccountBalance.Clear();
            txtAmoutWithdraw.Clear();
            pbPhoto.Image = null;
            pbSign.Image = null;
            pbSign1.Image = null;
            pbPhoto1.Image = null;
        }
 
 
        //bank baalnce
        private double BankBalance()
        {
            double bal = 0;
            conn = new SqlConnection(CS);
            conn.Open();
            cmd = new SqlCommand("select * from BankBalance", conn);
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                bal = Convert.ToDouble(dr[0].ToString());
            }
            dr.Close();
            return bal;
        }
 
        private void btnWithdraw_Click(object sender, EventArgs e)
        {
            int bal = Convert.ToInt32(txtAccountBalance.Text);
            int amt = Convert.ToInt32(txtAmoutWithdraw.Text);
 
            if (txtAmoutWithdraw.Text == string.Empty)
            {
                MessageBox.Show("Please enter the amount to be withrawn! ");
            }
 
            else if (amt > bal)
            {
                MessageBox.Show("Amount Must Be Less Or Equal To Balance ");
            }
            else
            {
 
                try
                {
                    conn = new SqlConnection(CS);
                    conn.Open();
 
                    string s = balance(txtAccountNumber.Text);
                    double money = Convert.ToDouble(txtAmoutWithdraw.Text);
                    double avlble = Convert.ToDouble(s) - money;
 
                    //insert into Withdraw
                    cmd = new SqlCommand("insert into withdraw values (@id,@no,@date,@money,@intext,@detail)", conn);
                    cmd.Parameters.AddWithValue("id", txtWithdrawId.Text);
                    cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);
                    cmd.Parameters.AddWithValue("date", txtDate.Text);
                    cmd.Parameters.AddWithValue("money", txtAmoutWithdraw.Text);
                    cmd.Parameters.AddWithValue("intext""Sample");
                    cmd.Parameters.AddWithValue("detail", txtDetails.Text);
                    cmd.ExecuteNonQuery();
 
 
                    //insert into bank balance
                    double bb = BankBalance();
                    double newbb = bb + money;
                    cmd = new SqlCommand("update BankBalance set balance =" + newbb + "", conn);
                    cmd.ExecuteNonQuery();
 
 
                    //insert into passbook
                    cmd = new SqlCommand("insert into passbook (accno,date,info,widraw,avlabl,time) values (@no,@date,@info,@widraw,@avlabl,@time)", conn);
                    cmd.Parameters.AddWithValue("no", txtAccountNumber.Text);
                    cmd.Parameters.AddWithValue("date", txtDate.Text);
                    cmd.Parameters.AddWithValue("info", txtDetails.Text);
                    cmd.Parameters.AddWithValue("widraw", txtAmoutWithdraw.Text);
                    cmd.Parameters.AddWithValue("avlabl", avlble.ToString());
                    cmd.Parameters.AddWithValue("time", time);
                    cmd.ExecuteNonQuery();
 
 
                    //insert/updated into balance
                    cmd = new SqlCommand("update balance set balance='" + Convert.ToInt32(avlble) + "' where accno='" + txtAccountNumber.Text + "'", conn);
                    cmd.ExecuteNonQuery();
 
 
                    //insert into Transaction
                    cmd = new SqlCommand("insert into trans_info values(@date,@time,@accno,@type,@ammount)", conn);
                    cmd.Parameters.AddWithValue("date"DateTime.Now.ToString("dd/MM/yyyy"));
                    cmd.Parameters.AddWithValue("time", time);
                    cmd.Parameters.AddWithValue("accno", txtAccountNumber.Text);
                    cmd.Parameters.AddWithValue("type""widraw Money");
                    cmd.Parameters.AddWithValue("ammount", txtAmoutWithdraw.Text);
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                lblloader.Visible = true;
 
                MessageBox.Show("Withdraw Suceess Please Print Receipt""Sucess"MessageBoxButtons.OK, MessageBoxIcon.Information);
 
 
                //print reciept
                DataTable dt = new DataTable();
                frmReportForm r = new frmReportForm();
                r.crystalReportViewer1.ReportSource = null;
                r.crystalReportViewer1.Refresh();
                dt.Clear();
                SqlDataAdapter da = new SqlDataAdapter("select * from withdraw where accno='" + txtAccountNumber.Text + "' AND id='" + txtWithdrawId.Text + "'", conn);
                da.Fill(dt);
                Reports.crWithdraw w = new Reports.crWithdraw();
                w.Database.Tables["withdraw"].SetDataSource(dt);
                r.crystalReportViewer1.ReportSource = w;
                r.crystalReportViewer1.Refresh();
                r.Show();
 
                Clear();
                autoId();
 
            }
        }
 
        private void frmWithdrawal_Load_1(object sender, EventArgs e)
        {
            lblloader.Visible = false;
            txtDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
            time = DateTime.Now.ToString("hh:mm:ss");
            autoId();
        }
 
        private void txtAmoutWithdraw_TextChanged(object sender, EventArgs e)
        {
            if (txtAmoutWithdraw.Text == "")
            {
                lblMoneyToWord.Text = "";
            }
            else
            {
                long am = Convert.ToInt64(txtAmoutWithdraw.Text);
                lblMoneyToWord.Text = ConvertNumbertoWords(am);
            }
        }
    }
}

 

 

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
  </configSections>
  <connectionStrings>
    <add name="FinobankDB" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database\Finobank.mdf;Integrated Security=True"
      providerName="System.Data.SqlClient" />
    
    <!--<add name="FinoBank_Application.Properties.Settings.FinobankConnectionString"
      connectionString="Data Source=DESKTOP-7KRFK3E\LOCALSERVER;Initial Catalog=Finobank;Integrated Security=True"
      providerName="System.Data.SqlClient" />-->
  </connectionStrings>
    <startup useLegacyV2RuntimeActivationPolicy="true"
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>
</configuration>

 

 

 

 

x

 

Comments

Popular posts from this blog

Turbo C++ tutorial

Turbo C++ Tutorial  Turbo C++ is a programming language was developed by Borland. C++ was a C++ compiler and integrated development environment and computer language originally from Borland. Most recently it was distributed by Embarcadero Technologies, which acquired all of Borland's compiler tools with the purchase of its CodeGear division in 2008. The original Turbo C++ product line was put on hold after 1994 and was revived in 2006 as an introductory-level IDE, essentially a stripped-down version of their flagship C++Builder. Turbo C++ 2006 was released on September 5, 2006 and was available in 'Explorer' and 'Professional' editions. The Explorer edition was free to download and distribute while the Professional edition was a commercial product. In October 2009 Embarcadero Technologies discontinued support of its 2006 C++ editions. As such, the Explorer edition is no longer available for download and the Professional edition is no longer available

Ganna Gyaras

Ganna Gyaras or called Dev uthavni Aikadashi.... It is also called Prabodhini  Aikadashi. It is belived that after killing the demon called Shankhasur The Great Lord Vishnu went for long sleep... which began after June month...... After diwali's 11th day the Ganna Gyaras is celebrated..... and all the auspicious tasks such as Weddings, New buyings etc. are done.  It is also called that... the end of Chaturmas.... Cool fact... Isn't it..?? Please make comments...... Thank you.