Exemple #1
0
        private void paymentTermsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Show();
            payment_re pr = new payment_re();

            pr.ShowDialog();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            payment_re it = new payment_re();

            it.ShowDialog();
        }
        // int id = 0;
        // string id1 = "";
        private void button9_Click(object sender, EventArgs e)
        {
            string in_no = "";

            // insert query into payment Receipt


            DataGridViewRow newDataRow = dataGridView1.Rows[selectedrow];
            DataGridViewRow row        = dataGridView1.Rows[selectedrow];

            try
            {
                connection.Close();
                connection.Open();

                OleDbDataReader rdr = null;
                OleDbCommand    cmd = new OleDbCommand("select * from payment_receipt where invoice_type = 'Tax-Invoice' AND in_no = '" + row.Cells[0].Value + "' ", connection);
                rdr = cmd.ExecuteReader();
                if (rdr.Read())
                {
                    in_no = Convert.ToString(rdr["in_no"]);
                }
            }
            catch (Exception o)
            {
                MessageBox.Show("getid" + o);
            }
            finally
            {
                connection.Close();
            }

            if (in_no == row.Cells[0].Value.ToString())
            {
                MessageBox.Show("Already exist");
            }
            else
            {
                try
                {
                    string bla = "";
                    bla = "1";

                    get_id gi = new get_id();
                    gi.taxinvoice();
                    int receipt_no = get_id.pay_re;


                    connection.Close();
                    connection.Open();
                    string       command = "insert into payment_receipt(re_no,re_date,payment_type,invoice_type,ref_no,ref_date,in_no,in_date,c_name,total_amount,due_amount,receive_amount,total_receive) values(@re_no,@re_date,@payment_type,@invoice_type,@ref_no,@ref_date,@in_no,@in_date,@c_name,@in_amount,@due_amount,@receive_amount,@total_receive) ";
                    OleDbCommand cmdd    = new OleDbCommand(command, connection);
                    cmdd.Parameters.AddWithValue("@re_no", receipt_no);
                    cmdd.Parameters.AddWithValue("@re_date", DateTime.Now.ToString("MM-dd-yyyy"));
                    cmdd.Parameters.AddWithValue("@payment_type", "Against Invoice");
                    cmdd.Parameters.AddWithValue("@invoice_type", "Tax-Invoice");
                    cmdd.Parameters.AddWithValue("@re_no", receipt_no);
                    cmdd.Parameters.AddWithValue("@re_date", DateTime.Now.ToString("MM-dd-yyyy"));
                    cmdd.Parameters.AddWithValue("@in_no", row.Cells[0].Value);
                    cmdd.Parameters.AddWithValue("@in_date", row.Cells[1].Value);
                    cmdd.Parameters.AddWithValue("@c_name", row.Cells[4].Value);
                    cmdd.Parameters.AddWithValue("@in_amount", row.Cells[5].Value);
                    cmdd.Parameters.AddWithValue("@due_amount", row.Cells[7].Value);
                    string receive = Convert.ToString(Convert.ToDouble(row.Cells[5].Value.ToString()) - Convert.ToDouble(row.Cells[7].Value.ToString()));
                    cmdd.Parameters.AddWithValue("@receive_amount", receive);
                    cmdd.Parameters.AddWithValue("@total_receive", receive);
                    cmdd.ExecuteNonQuery();

                    //update into id
                    int          df       = get_id.pay_re + 1;
                    OleDbCommand command1 = new OleDbCommand(@"UPDATE get_id
                                                    SET pay_re = @City_Name
                                                       
                                                    WHERE ID = " + bla + "", connection);

                    command1.Parameters.AddWithValue("@City_Name", df);

                    command1.ExecuteNonQuery();
                }

                catch (Exception p)
                {
                    MessageBox.Show("" + p);
                }
                finally
                {
                    connection.Close();

                    payment_re ts = new payment_re();
                    ts.ShowDialog();
                }
            }
        }