Example #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedCells.Count >= 1)
            {
                try
                {
                    OleDbCommand cmdBillClear = new OleDbCommand("update bill set billprint='N'", con);
                    //cmdBillClear.Parameters.Add("@billno", OleDbType.VarChar, 100).Value = "441818";
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    cmdBillClear.ExecuteNonQuery();

                    cmdBillClear.Parameters.Clear();
                    cmdBillClear.Dispose();

                    //OleDbDataAdapter adcount = new OleDbDataAdapter("Select * from bill where billno=@billno and billtype=@billtype", con);
                    //adcount.SelectCommand.Parameters.Add("@billno", OleDbType.Integer).Value = Convert.ToInt32(textBox1.Text);
                    //adcount.SelectCommand.Parameters.Add("@billtype", OleDbType.VarChar, 100).Value = "final";
                    //DataSet dscount = new DataSet();
                    //adcount.Fill(dscount);
                    //String count = dscount.Tables[0].Rows.Count.ToString();
                    //count = (23 - Convert.ToInt32(count)).ToString();
                    ////MessageBox.Show(count);

                    //OleDbCommand cmdupdatebillno = new OleDbCommand("update bill set billno=@billno where cname='AAA' and discount<=@discount", con);
                    //cmdupdatebillno.Parameters.Add("@billno", OleDbType.VarChar, 100).Value = textBox1.Text;
                    //cmdupdatebillno.Parameters.Add("@discount", OleDbType.Integer).Value = Convert.ToInt32(count);
                    //if (con.State == ConnectionState.Closed)
                    //{
                    //    con.Open();
                    //}
                    //cmdupdatebillno.ExecuteNonQuery();
                    //cmdupdatebillno.Parameters.Clear();
                    //cmdupdatebillno.Dispose();

                    OleDbCommand cmdBillYes = new OleDbCommand("update bill set billprint='Y' WHERE billno=@billno", con);
                    cmdBillYes.Parameters.Add("@Billno", OleDbType.Integer).Value = Convert.ToInt32(0 + textBox1.Text);
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    cmdBillYes.ExecuteNonQuery();

                    cmdBillYes.Parameters.Clear();
                    cmdBillYes.Dispose();
                    con.Close();
                    Form cffrmReports = new frmReports();
                    cffrmReports.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Example #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                String str = Microsoft.VisualBasic.Interaction.InputBox("Enter Bill No.", "Print Bill", "61", 500, 300);
                if (str != "")
                {
                    OleDbCommand cmdBillClear = new OleDbCommand("update bill set billprint='N'", con);
                    cmdBillClear.Parameters.Add("@billno", OleDbType.VarChar, 100).Value = str;
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    cmdBillClear.ExecuteNonQuery();
                    cmdBillClear.Parameters.Clear();
                    cmdBillClear.Dispose();


                    OleDbCommand cmdBillYes = new OleDbCommand("update bill set billprint='Y' WHERE billno=@billno", con);
                    cmdBillYes.Parameters.Add("@billno", OleDbType.VarChar, 100).Value = str;
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    cmdBillYes.ExecuteNonQuery();

                    cmdBillYes.Parameters.Clear();
                    cmdBillYes.Dispose();
                    con.Close();
                    Form cffrmReports = new frmReports();
                    cffrmReports.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }