Example #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (button2.Text == "Validate")
     {
         Connecntion cn = new Connecntion();
         using (SqlCommand StrQuer = new SqlCommand("SELECT * FROM [user] WHERE Username=@userid AND Password=@password", cn.con))
         {
             cn.connOpen();
             StrQuer.Parameters.AddWithValue("@userid", textBox1.Text.ToString());
             StrQuer.Parameters.AddWithValue("@password", textBox2.Text.ToString());
             using (SqlDataReader dr = StrQuer.ExecuteReader())
             {
                 if (dr.HasRows == false)
                 {
                     MessageBox.Show("User ID Incorrect", "Error");
                 }
                 else
                 {
                     button2.Text      = "Confirm";
                     textBox3.ReadOnly = false;
                     textBox4.ReadOnly = false;
                     textBox1.ReadOnly = true;
                     textBox2.ReadOnly = true;
                     passChange();
                 }
             }
         }
     }
     else
     {
         passChange();
     }
 }
Example #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (textBox2.Text != string.Empty)
            {
                Connecntion cn = new Connecntion();
                cn.connOpen();
                SqlDataReader rd;
                using (SqlCommand cmd = new SqlCommand("select Name from customer where Account_no=(select Account_No from loan where Account_No='" + textBox2.Text + "' and Loan_Status='Approved')", cn.con))
                {
                    using (rd = cmd.ExecuteReader())
                    {
                        if (rd.HasRows == false)
                        {
                            MessageBox.Show("Account doesn't have any Loan", "Result");
                            textBox2.Clear();
                            textBox2.Select();
                        }
                        else if (rd.Read())
                        {
                            textBox3.Text = rd.GetString(0);
                        }
                    }
                }
            }



            else
            {
                MessageBox.Show("Enter Account Number", "Missing Data");
            }
        }
Example #3
0
        public void inQuery()
        {
            Connecntion cn = new Connecntion();

            cn.connOpen();

            using (SqlCommand cmd = new SqlCommand("insert into customer(Account_No,Name,DOB,Phone_No,Email,Address,District,Gender,Marital_Status,Father_Name,Mother_Name,Balance,Photo) values (@ac,@na,@dob,@pno,@em,@add,@dis,@gen,@msta,@fn,@mn,@bl,@ph)", cn.con))
            {
                byte[] image = getPic();
                cmd.Parameters.AddWithValue("@ac", textBox1.Text);
                cmd.Parameters.AddWithValue("@na", textBox2.Text);
                cmd.Parameters.AddWithValue("@dob", dateTimePicker1.Text);
                cmd.Parameters.AddWithValue("@pno", textBox3.Text);
                cmd.Parameters.AddWithValue("@em", textBox4.Text);
                cmd.Parameters.AddWithValue("@add", richTextBox1.Text);
                cmd.Parameters.AddWithValue("@dis", textBox5.Text);
                cmd.Parameters.AddWithValue("@gen", gen);
                cmd.Parameters.AddWithValue("@msta", mstat);
                cmd.Parameters.AddWithValue("@fn", textBox8.Text);
                cmd.Parameters.AddWithValue("@mn", textBox9.Text);
                cmd.Parameters.AddWithValue("@bl", textBox10.Text);
                cmd.Parameters.AddWithValue("@ph", image);


                try { cmd.ExecuteNonQuery();
                      MessageBox.Show("Information Saved!", "Operation Completed"); }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            cn.con.Close();
            this.Close();
        }
Example #4
0
        public void inQuery()
        {
            Connecntion cn = new Connecntion();

            cn.connOpen();
            using (SqlCommand cmd = new SqlCommand("insert into [user] (Name,Username,Password,Gender,DOB,User_Type,Phone,Address) values (@name,@uname,@pass,@gen,@dob,@utype,@pno,@add)", cn.con))
            {
                cmd.Parameters.AddWithValue("@name", textBox1.Text);
                cmd.Parameters.AddWithValue("@uname", textBox2.Text);
                cmd.Parameters.AddWithValue("@pass", textBox4.Text);
                cmd.Parameters.AddWithValue("@add", richTextBox1.Text);
                cmd.Parameters.AddWithValue("@utype", comboBox1.Text);
                cmd.Parameters.AddWithValue("@dob", dateTimePicker1.Text);
                cmd.Parameters.AddWithValue("@pno", textBox3.Text);
                cmd.Parameters.AddWithValue("@gen", gen);
                try
                {
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("User added to database", "Operation Sucess");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                cn.con.Close();
                this.Close();
            }
        }
Example #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            Connecntion cn = new Connecntion();

            cn.connOpen();
            SqlDataReader rd;

            using (SqlCommand cmd = new SqlCommand("Select Name,Password,Gender,DOB,Phone,Address from [user] where Username='******'", cn.con))
            {
                using (rd = cmd.ExecuteReader())
                {
                    if (rd.HasRows == false)
                    {
                        MessageBox.Show("No Matching details found", "No Data!");
                    }
                    else if (rd.Read())
                    {
                        textBox2.Text = rd.GetString(0);
                        if (rd.GetString(2) == "Male")
                        {
                            radioButton1.Checked = true;
                        }
                        else
                        {
                            radioButton2.Checked = true;
                        }
                        textBox3.Text         = rd.GetString(4);
                        dateTimePicker1.Value = rd.GetDateTime(3);
                        richTextBox1.Text     = rd.GetString(5);
                    }
                }
                cn.con.Close();
            }
        }
Example #6
0
        public void inQuery()
        {
            Connecntion cn = new Connecntion();

            cn.connOpen();
            using (SqlCommand cmd = new SqlCommand("update  [user] set Name=@name,Username=@uname,Gender=@gen,DOB=@dob,Phone=@pno,Address=@add where Username='******'", cn.con))
            {
                cmd.Parameters.AddWithValue("@name", textBox2.Text);
                cmd.Parameters.AddWithValue("@uname", textBox1.Text);

                cmd.Parameters.AddWithValue("@add", richTextBox1.Text);

                cmd.Parameters.AddWithValue("@dob", dateTimePicker1.Text);
                cmd.Parameters.AddWithValue("@pno", textBox3.Text);
                cmd.Parameters.AddWithValue("@gen", gen);
                try
                {
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("User updated to database", "Operation Sucess");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                cn.con.Close();
                this.Close();
            }
        }
        public void inQueryP()
        {
            Connecntion cn = new Connecntion();

            cn.connOpen();
            using (SqlCommand cmd = new SqlCommand("Update customer set Name='" + textBox2.Text + "',DOB='" + dateTimePicker1.Text + "',Phone_No='" + textBox8.Text + "',Email='" + textBox9.Text + "',Address='" + richTextBox1.Text + "',District='" + textBox5.Text + "',Gender=@gen,Marital_Status=@mstat,Father_Name='" + textBox4.Text + "',Mother_Name='" + textBox5.Text + "',Balance='" + textBox3.Text + "',Photo=@img where Account_No='" + textBox1.Text + "'", cn.con))
            {
                byte[] image = getPic();
                cmd.Parameters.AddWithValue("@gen", gen);
                cmd.Parameters.AddWithValue("@mstat", mstat);
                cmd.Parameters.AddWithValue("@img", image);
                try
                {
                    SqlDataReader rd = cmd.ExecuteReader();
                    if (MessageBox.Show("Info Updated!", "Operation Complete", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                    {
                        Clear_Boxes();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            cn.con.Close();
        }
Example #8
0
 public void passChange()
 {
     if (textBox3.Text == string.Empty || textBox4.Text == string.Empty)
     {
         MessageBox.Show("Please type new password and confirm password");
         textBox3.Select();
     }
     else if (textBox3.Text != textBox4.Text)
     {
         MessageBox.Show("Password didn't match", "Error");
     }
     else
     {
         Connecntion cn = new Connecntion();
         using (SqlCommand cmd = new SqlCommand("update [user] set Password='******'where Username='******'", cn.con))
         {
             cn.connOpen();
             try
             {
                 cmd.ExecuteNonQuery();
                 MessageBox.Show("Password Updated", "Operation Succeed");
                 this.Close();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
 }
Example #9
0
        private void button3_Click(object sender, EventArgs e)
        {
            Connecntion cn = new Connecntion();

            cn.connOpen();
            SqlDataReader rd;

            using (SqlCommand cmd = new SqlCommand("Select Name,Balance from customer where Account_no='" + textBox1.Text + "'", cn.con))
            {
                using (rd = cmd.ExecuteReader())
                {
                    if (rd.HasRows == false)
                    {
                        MessageBox.Show("There is no Account with whis Account Number", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        textBox1.Clear();
                    }
                    else if (rd.Read())
                    {
                        textBox5.Text = rd.GetString(0);
                        textBox6.Text = rd.GetInt32(1).ToString();
                    }
                }
            }
            cn.con.Close();
        }
Example #10
0
        private void button1_Click(object sender, EventArgs e)
        {
            Connecntion cn = new Connecntion();

            cn.connOpen();
            SqlDataReader rd;

            using (SqlCommand cmd = new SqlCommand("Select * from customer where Account_no=@ac", cn.con))
            {
                cmd.Parameters.AddWithValue("@ac", textBox1.Text);
                rd = cmd.ExecuteReader();
                if (rd.HasRows == false)
                {
                    MessageBox.Show("Account No Unavailable");
                }
                else if (rd.Read())
                {
                    textBox2.Text         = rd.GetString(1);
                    textBox4.Text         = rd.GetString(9);
                    textBox5.Text         = rd.GetString(10);
                    textBox8.Text         = rd.GetString(3);
                    textBox9.Text         = rd.GetString(4);
                    richTextBox1.Text     = rd.GetString(5);
                    textBox10.Text        = rd.GetString(6);
                    textBox3.Text         = rd.GetInt32(11).ToString();
                    dateTimePicker1.Value = rd.GetDateTime(2);

                    if (rd.GetString(7) == "Male")
                    {
                        radioButton1.Checked = true;
                    }
                    else
                    {
                        radioButton2.Checked = true;
                    }
                    if (rd.GetString(8) == "Married")
                    {
                        radioButton3.Checked = true;
                    }
                    else
                    {
                        radioButton4.Checked = true;
                    }
                    byte[] img = (byte[])(rd[12]);
                    if (img == null)
                    {
                        pictureBox1.Image = null;
                    }
                    else
                    {
                        MemoryStream ms = new MemoryStream(img);
                        pictureBox1.Image = Image.FromStream(ms);
                    }
                }
            }
            cn.con.Close();
        }
Example #11
0
        public void acc()
        {
            Connecntion cn = new Connecntion();

            cn.connOpen();
            SqlCommand cmd = new SqlCommand("select max(Account_no+1) from customer", cn.con);

            //int count = (int)cmd.ExecuteScalar();
            textBox1.Text = cmd.ExecuteScalar().ToString();
            cn.con.Close();
        }
Example #12
0
 private void button5_Click(object sender, EventArgs e)
 {
     if (richTextBox2.Text == string.Empty)
     {
         MessageBox.Show("Enter Customer Account Number", "Enter Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else if (richTextBox2.Text != string.Empty)
     {
         Connecntion cn = new Connecntion();
         cn.connOpen();
         SqlDataReader rd;
         using (SqlCommand cmd = new SqlCommand("select * from loan where Account_No='" + richTextBox2.Text + "'", cn.con))
         {
             using (rd = cmd.ExecuteReader())
             {
                 if (rd.HasRows == false)
                 {
                     MessageBox.Show("No loan record found", "Not Found");
                 }
                 else if (rd.Read())
                 {
                     rd.Close();
                     using (SqlCommand cm3 = new SqlCommand("Select Loan_Status from loan where Account_No='" + richTextBox2.Text + "'", cn.con))
                     {
                         object result = cm3.ExecuteScalar();
                         string res    = Convert.ToString(result);
                         if (res == "Approved")
                         {
                             MessageBox.Show("Loan is approved!\n Can not decline", "Declined");
                         }
                         else
                         {
                             using (SqlCommand cmd2 = new SqlCommand("Delete loan where Account_No='" + richTextBox2.Text + "'", cn.con))
                             {
                                 try
                                 {
                                     cmd2.ExecuteNonQuery();
                                     MessageBox.Show("Loan Declined", "Updated!");
                                 }
                                 catch (Exception ex)
                                 {
                                     MessageBox.Show(ex.Message);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Example #13
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox2.Text != string.Empty)
            {
                Connecntion cn = new Connecntion();
                cn.connOpen();
                using (SqlCommand cmd = new SqlCommand("select Username from [user] where Username=@uname", cn.con))
                {
                    cmd.Parameters.AddWithValue("@uname", textBox2.Text);
                    SqlDataReader rd = cmd.ExecuteReader();
                    if (rd.HasRows)
                    {
                        MessageBox.Show("Username already exists!" +
                                        "\nType another one", "Warning!!");
                        textBox2.Clear();
                    }
                }
                cn.con.Close();
            }

            if (textBox1.Text != string.Empty && textBox2.Text != string.Empty && textBox3.Text != string.Empty && textBox4.Text != string.Empty && richTextBox1.Text != string.Empty)
            {     //if textbox r not empty
                if (radioButton1.Checked || radioButton2.Checked)
                { //if radio buttons are selected correctly
                    if (dateTimePicker1.Value < DateTime.Today.AddYears(-18) &&
                        dateTimePicker1.Value > DateTime.Today.AddYears(-100))
                    {       //after checking the customer is >18
                        if (comboBox1.Text == string.Empty)
                        {
                            MessageBox.Show("Pick a role", "Combobox unchecked");
                        }
                        else
                        {
                            inQuery();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Wrong Date of Birth");
                    }
                }
                else
                {
                    MessageBox.Show("Choose a gender");
                }
            }
            else
            {
                MessageBox.Show("Input all the informations");
            }
        }
Example #14
0
        private void button1_Click(object sender, EventArgs e)
        {
            Connecntion cn = new Connecntion();

            cn.connOpen();


            SqlDataAdapter d = new SqlDataAdapter("select * from [transaction]", cn.con);
            DataTable      t = new DataTable();

            d.Fill(t);
            dataGridView1.DataSource = t;

            //DataSet ds = new DataSet();
            //d.Fill(ds,"transaction,transfer");
            //dataGridView1.DataSource = ds;
            //dataGridView1.DataMember = "transaction,transfer";
        }
Example #15
0
        public void inQuery()
        {
            Connecntion cn = new Connecntion();

            cn.connOpen();
            SqlDataReader rd;

            using (SqlCommand cmd2 = new SqlCommand("Select * from customer where Account_No='" + textBox1.Text + "'", cn.con))
            {
                using (rd = cmd2.ExecuteReader()) {
                    if (rd.HasRows == false)
                    {
                        MessageBox.Show("Account does not exist", "Resuult");
                        textBox1.Clear();
                        textBox1.Select();
                    }
                    else if (rd.Read())
                    {
                        rd.Close();
                        using (SqlCommand cmd = new SqlCommand("insert into fd (Account_No,Type,Amount,Period,Interest,Date) values(@acc,@type,@amount,@per,@inte,@date)", cn.con))
                        {
                            cmd.Parameters.AddWithValue("@acc", textBox1.Text);
                            cmd.Parameters.AddWithValue("@type", rb);
                            cmd.Parameters.AddWithValue("@amount", textBox3.Text);
                            cmd.Parameters.AddWithValue("@per", textBox4.Text);
                            cmd.Parameters.AddWithValue("@inte", textBox5.Text.ToString());
                            cmd.Parameters.AddWithValue("@date", DateTime.Now.ToString("yyyy-MM-dd"));
                            try
                            {
                                cmd.ExecuteNonQuery();
                                MessageBox.Show("Fd Form Created", "Operation Complete");
                                cn.con.Close();
                                this.Close();
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                            }
                        }
                    }
                }
            }
        }
Example #16
0
        private void button3_Click(object sender, EventArgs e)
        {
            Connecntion cn = new Connecntion();

            cn.connOpen();
            SqlDataReader rd;
            SqlCommand    cmd;

            using (cmd = new SqlCommand("Select * from [user] where Username='******'", cn.con))
            {
                try
                {
                    rd = cmd.ExecuteReader();
                    if (rd.HasRows)
                    {
                        rd.Close();
                        cmd = new SqlCommand("Delete from [user] where Username='******'", cn.con);
                        try
                        {
                            rd = cmd.ExecuteReader();
                            MessageBox.Show("User Info Deleted!", "Operation Complete");
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                    else
                    {
                        MessageBox.Show("No record found", "Result");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            cn.con.Close();
            this.Close();
        }
Example #17
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (richTextBox2.Text == string.Empty)
     {
         MessageBox.Show("Enter Customer Account Number", "Enter Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else if (richTextBox2.Text != string.Empty)
     {
         Connecntion cn = new Connecntion();
         cn.connOpen();
         SqlDataReader rd;
         using (SqlCommand cmd = new SqlCommand("select * from loan where Account_No='" + richTextBox2.Text + "'", cn.con))
         {
             using (rd = cmd.ExecuteReader())
             {
                 if (rd.HasRows == false)
                 {
                     MessageBox.Show("No loan record found", "Not Found");
                 }
                 else if (rd.Read())
                 {
                     rd.Close();
                     using (SqlCommand cmd2 = new SqlCommand("update loan set Loan_Status='Approved' where Account_No='" + richTextBox2.Text + "'", cn.con))
                     {
                         try
                         {
                             cmd2.ExecuteNonQuery();
                             MessageBox.Show("Loan Accepted!", "Updated!");
                         }
                         catch (Exception ex)
                         {
                             MessageBox.Show(ex.Message);
                         }
                     }
                 }
             }
         }
     }
 }
Example #18
0
        public void setLabel()
        {
            Connecntion cn = new Connecntion();

            cn.connOpen();
            using (SqlCommand cmd = new SqlCommand("Select COALESCE(SUM(Balance), 0) from customer", cn.con))
            {
                object result = cmd.ExecuteScalar();
                label10.Text = Convert.ToString(result);
            }

            using (SqlCommand cmd = new SqlCommand("Select COALESCE(SUM(Loan_Amount), 0) from loan where Loan_Status='approved'", cn.con))
            {
                object result = cmd.ExecuteScalar();
                label11.Text = Convert.ToString(result);
            }
            using (SqlCommand cmd = new SqlCommand("Select Count(Username) from [user] ", cn.con))
            {
                object result = cmd.ExecuteScalar();
                label12.Text = Convert.ToString(result);
            }
            using (SqlCommand cmd = new SqlCommand("Select Count(Account_No) from customer ", cn.con))
            {
                object result = cmd.ExecuteScalar();
                label13.Text = Convert.ToString(result);
            }
            using (SqlCommand cmd = new SqlCommand("Select Count(Account_No) from loan where Loan_Status='approved'", cn.con))
            {
                object result = cmd.ExecuteScalar();
                label14.Text = Convert.ToString(result);
            }
            using (SqlCommand cmd = new SqlCommand("Select Count(Account_No) from fd", cn.con))
            {
                object result = cmd.ExecuteScalar();
                label15.Text = Convert.ToString(result);
            }
        }
Example #19
0
        public void inQuery()
        {
            Connecntion cn = new Connecntion();

            cn.connOpen();

            using (SqlCommand cmd = new SqlCommand("select * from customer where Account_No='" + textBox1.Text + "'", cn.con))
            {
                SqlDataReader rd;
                using (rd = cmd.ExecuteReader())
                {
                    if (rd.HasRows == false)
                    {
                        MessageBox.Show("Accoung does not exist", "Error");
                        textBox1.Clear();
                        textBox1.Select();
                    }
                    else if (rd.Read())
                    {
                        rd.Close();


                        using (SqlCommand cmd3 = new SqlCommand("select * from loan where Account_No='" + textBox1.Text + "'", cn.con))
                        {
                            using (rd = cmd3.ExecuteReader())
                            {
                                if (rd.HasRows == false)
                                {
                                    rd.Close();
                                    using (SqlCommand cmd2 = new SqlCommand("insert into loan (Account_No,Loan_Amount,Monthly_Pay,Period,Interest,Loan_Status,Date) values(@acc,@loan,@mpay,@per,@inte,@loanstat,@date)", cn.con))
                                    {
                                        string str = "Pending";
                                        cmd2.Parameters.AddWithValue("@acc", textBox1.Text);
                                        cmd2.Parameters.AddWithValue("@loan", textBox2.Text);
                                        cmd2.Parameters.AddWithValue("@loanstat", str.ToString());
                                        cmd2.Parameters.AddWithValue("@mpay", textBox3.Text);

                                        cmd2.Parameters.AddWithValue("@per", textBox4.Text);
                                        cmd2.Parameters.AddWithValue("@inte", textBox5.Text.ToString());
                                        cmd2.Parameters.AddWithValue("@date", DateTime.Now.ToString("yyyy-MM-dd"));
                                        try
                                        {
                                            cmd2.ExecuteNonQuery();
                                            MessageBox.Show("Loan Form Created", "Operation Complete");
                                            cn.con.Close();
                                            this.Close();
                                        }
                                        catch (Exception ex)
                                        {
                                            MessageBox.Show(ex.Message);
                                        }
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("There is already a Loan for this Account", "Request Denied");
                                    textBox1.Select();
                                }
                            }
                        }
                    }
                }
            }
        }
Example #20
0
        public void inQuery()
        {
            int main_loan = 0;
            int up_loan   = 0;

            Connecntion cn = new Connecntion();

            cn.connOpen();
            SqlDataReader rd;

            using (SqlCommand cmd = new SqlCommand("select Loan_Amount from loan where account_no='" + textBox2.Text.ToString() + "'", cn.con))
            {
                using (rd = cmd.ExecuteReader())
                {
                    if (rd.HasRows == false)
                    {
                        MessageBox.Show("Account doesn't have any Loan", "Result");
                        textBox2.Clear();
                        textBox2.Select();
                    }
                    else if (rd.Read())
                    {
                        main_loan = rd.GetInt32(0);
                    }
                }
            }
            if (main_loan >= Convert.ToInt32(textBox5.Text.ToString()))
            {
                //procedure call
                up_loan = main_loan - Convert.ToInt32(textBox5.Text);

                using (SqlCommand cmd = new SqlCommand("loan_pay", cn.con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@ano", Convert.ToInt32(textBox2.Text.ToString()));
                    cmd.Parameters.AddWithValue("@n", textBox3.Text);
                    cmd.Parameters.AddWithValue("@pm", textBox4.Text);
                    cmd.Parameters.AddWithValue("@pa", Convert.ToInt32(textBox5.Text));
                    cmd.Parameters.AddWithValue("@dt", DateTime.Today.ToString("yyyy-MM-dd"));
                    cmd.Parameters.AddWithValue("@ul", up_loan);


                    try
                    {
                        //cn.con.Open();
                        cmd.ExecuteNonQuery();

                        MessageBox.Show("Loan Installment Successfull");
                        this.Close();
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.ToString());
                    }
                }
            }
            else
            {
                MessageBox.Show("incorrect payment");
            }
        }
Example #21
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox5.Text != string.Empty)
            {
                Connecntion cn = new Connecntion();
                cn.connOpen();
                SqlDataReader rd;
                using (SqlCommand cmd = new SqlCommand("select * from customer where Account_No='" + textBox4.Text + "'", cn.con))
                {
                    using (rd = cmd.ExecuteReader())
                    {
                        if (rd.HasRows == false)
                        {
                            MessageBox.Show("No Account Found\ninput again", "Result");
                            textBox4.Clear();
                            textBox4.Select();
                        }


                        else if (rd.Read())
                        {
                            rd.Close();
                            using (SqlCommand cmd2 = new SqlCommand("update customer set Balance=Balance+'" + textBox5.Text + "'where Account_no='" + textBox4.Text + "'", cn.con))
                            {
                                try
                                {
                                    cmd2.ExecuteNonQuery();
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.Message);
                                }
                            }
                            using (SqlCommand cmd2 = new SqlCommand("update customer set Balance=Balance-'" + textBox5.Text + "' where Account_No='" + textBox2.Text + "'", cn.con))
                            {
                                try
                                {
                                    cmd2.ExecuteNonQuery();
                                    MessageBox.Show("Customer Table Updated", "Operation Complete");
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.Message);
                                }
                            }
                            using (SqlCommand cmd2 = new SqlCommand("insert into [transfer] (Payee_Account,Recv_Account,Transfer_Amount,Date) values(@pa,@ra,@amount,@date) ", cn.con))
                            {
                                cmd2.Parameters.AddWithValue("@pa", textBox2.Text);
                                cmd2.Parameters.AddWithValue("@ra", textBox4.Text);
                                cmd2.Parameters.AddWithValue("@amount", textBox5.Text);
                                cmd2.Parameters.AddWithValue("@date", DateTime.Now.ToString("yyyy-MM-dd"));

                                try
                                {
                                    cmd2.ExecuteNonQuery();
                                    MessageBox.Show("Transfer Table Updated!", "Operation Complete");
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.Message);
                                }
                            }
                            using (SqlCommand cmd2 = new SqlCommand("insert into [transaction] (Account_No,TransferFrom,TransferTo,Amount,Date) values (@acc,@tf,@tt,@amount,@date)", cn.con))
                            {
                                cmd2.Parameters.AddWithValue("@acc", textBox2.Text.ToString());
                                cmd2.Parameters.AddWithValue("@tf", textBox2.Text);
                                cmd2.Parameters.AddWithValue("@tt", textBox4.Text);
                                cmd2.Parameters.AddWithValue("@amount", textBox5.Text);
                                cmd2.Parameters.AddWithValue("@date", DateTime.Now.ToString("yyyy-MM-dd"));
                                try
                                {
                                    cmd2.ExecuteNonQuery();
                                    MessageBox.Show("Transaction Complete!", "OPeration Succedd!!");
                                    cn.con.Close();
                                    this.Close();
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.Message);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Enter Amount!", "Error");
            }
        }
Example #22
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox7.Text != string.Empty)
            {
                int deposit;
                deposit = Convert.ToInt32(textBox7.Text);
                deposit = int.Parse(textBox7.Text);
                Connecntion cn = new Connecntion();
                cn.connOpen();
                using (SqlCommand cmd = new SqlCommand("insert into deposit(Account_No,Deposit_Amount,Date) values (@acc,@da,@date)", cn.con))
                {
                    cmd.Parameters.AddWithValue("@acc", textBox1.Text);
                    cmd.Parameters.AddWithValue("@da", textBox7.Text);
                    cmd.Parameters.AddWithValue("@date", DateTime.Now.ToString("yyyy-MM-dd"));
                    try
                    {
                        cmd.ExecuteNonQuery();
                        MessageBox.Show("Deposit Completed!", "Operation Complete");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                using (SqlCommand cmd = new SqlCommand("insert into [transaction] (Account_No,Credit,Date) values (@acc,@da,@date)", cn.con))
                {
                    cmd.Parameters.AddWithValue("@acc", textBox1.Text);
                    cmd.Parameters.AddWithValue("@da", textBox7.Text);

                    cmd.Parameters.AddWithValue("@date", DateTime.Now.ToString("yyyy-MM-dd"));
                    try
                    {
                        cmd.ExecuteNonQuery();
                        MessageBox.Show("Transaction Table Updated!", "Operation Complete");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                int crrBalance;
                crrBalance = Convert.ToInt32(textBox6.Text);
                crrBalance = int.Parse(textBox6.Text);

                int finalbalance = deposit + crrBalance;
                using (SqlCommand cmd = new SqlCommand("update customer set balance='" + finalbalance + "' where Account_No='" + textBox1.Text + "'", cn.con))
                {
                    try
                    {
                        cmd.ExecuteNonQuery();
                        MessageBox.Show("Customer Table Updated", "Operation Complete");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }

                cn.con.Close();
                this.Close();
            }

            else
            {
                MessageBox.Show("Input Deposit Money", "No Value");
                textBox7.Clear();
                textBox7.Select();
            }
        }
Example #23
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox7.Text != string.Empty)
            {
                int anInteger;
                anInteger = Convert.ToInt32(textBox7.Text);
                anInteger = int.Parse(textBox7.Text);
                Connecntion cn = new Connecntion();
                cn.connOpen();
                int crrBalance;
                crrBalance = Convert.ToInt32(textBox6.Text);
                crrBalance = int.Parse(textBox6.Text);
                if (anInteger <= crrBalance)
                {
                    {
                        using (SqlCommand cmd = new SqlCommand("insert into withdraw(Account_No,Withdraw_Amount,Date) values (@acc,@wa,@date)", cn.con))
                        {
                            cmd.Parameters.AddWithValue("@acc", textBox1.Text);
                            cmd.Parameters.AddWithValue("@wa", textBox7.Text);
                            cmd.Parameters.AddWithValue("@date", DateTime.Now.ToString("yyyy-MM-dd"));
                            try
                            {
                                cmd.ExecuteNonQuery();
                                MessageBox.Show("Withdraw Completed!", "Operation Complete");
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                            }
                        }
                    }
                    using (SqlCommand cmd = new SqlCommand("insert into [transaction] (Account_No,Debit,Date) values (@acc,@ca,@date)", cn.con))
                    {
                        cmd.Parameters.AddWithValue("@acc", textBox1.Text);
                        cmd.Parameters.AddWithValue("@ca", textBox7.Text);
                        cmd.Parameters.AddWithValue("@date", DateTime.Now.ToString("yyyy-MM-dd"));
                        try
                        {
                            cmd.ExecuteNonQuery();
                            MessageBox.Show("Transaction Table Update!!!", "Operation Complete");
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }


                    int finalbalance = crrBalance - anInteger;
                    using (SqlCommand cmd = new SqlCommand("update customer set balance='" + finalbalance + "' where Account_No='" + textBox1.Text + "'", cn.con))
                    {
                        try
                        {
                            cmd.ExecuteNonQuery();
                            MessageBox.Show("Customer Table Updated", "Operation Complete");
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                        cn.con.Close();
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Withdrawal amount is more than Current Balance\nInput Again", "Error Result");
                    textBox7.Clear();
                    textBox7.Select();
                }


                cn.con.Close();
            }

            else
            {
                MessageBox.Show("Input Withdrawal Amount", "No Value");
                textBox7.Clear();
                textBox7.Select();
            }
        }