示例#1
0
        private void btnprint_Click(object sender, EventArgs e)
        {
            print();
            if (txtsearch.Text.Length > 0)
            {
                if (dataGridView1.Rows.Count > 0)
                {
                    for (int a = 0; a < dataGridView1.Rows.Count; a++)
                    {
                        string  item     = (dataGridView1.Rows[a].Cells[3].Value.ToString());
                        int     quantity = Convert.ToInt32(dataGridView1.Rows[a].Cells[4].Value.ToString());
                        decimal total    = Convert.ToDecimal(dataGridView1.Rows[a].Cells[5].Value.ToString());
                        string  date     = DateTime.Today.ToShortDateString();
                        int     b        = blod.addorder(item, quantity, total, Convert.ToDateTime(date));
                    }
                }
                else
                {
                    lblmsg.Text = "No record found in database";
                }

                int i = blod.deletefromtable(Convert.ToInt32(txtsearch.Text));
                if (i > 0)
                {
                    MessageBox.Show("Data has been save to database");
                }
            }
        }
        private void dgv_deliver_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == dgv_deliver.Columns["cal_recived"].Index && e.RowIndex >= 0)
            {
                Home_delivery_check check = new Home_delivery_check();
                check.txt_name.Text         = dgv_deliver.CurrentRow.Cells["calcusname"].Value.ToString();
                check.txt_amount.Text       = dgv_deliver.CurrentRow.Cells["caltotal"].Value.ToString();
                check.txt_deliverby.Text    = dgv_deliver.CurrentRow.Cells["caldeliveryman"].Value.ToString();
                check.lblkotid.Text         = dgv_deliver.CurrentRow.Cells["calkotid"].Value.ToString();
                check.homeId.Text           = dgv_deliver.CurrentRow.Cells["calid"].Value.ToString();
                check.lbl_payment_type.Text = dgv_deliver.CurrentRow.Cells["cal_payment_type"].Value.ToString();
                check.ShowDialog();
                gridview();
            }
            else if (e.ColumnIndex == dgv_deliver.Columns["cal_cancel"].Index && e.RowIndex >= 0)
            {
                DialogResult dialogResult = MessageBox.Show("Are You Sure Want To Delete Delivery", "Cancel", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    DataTable dt = blord.getalldata(Convert.ToDecimal(dgv_deliver.CurrentRow.Cells["calkotid"].Value.ToString()));
                    if (dt.Rows.Count > 0)
                    {
                        for (int x = 0; dt.Rows.Count > x; x++)
                        {
                            string customer_name = dt.Rows[x]["user_name"].ToString();
                            table_no = Convert.ToDecimal(dt.Rows[x]["table_no"].ToString());

                            string  item_name     = dt.Rows[x]["item"].ToString();
                            decimal quantity      = Convert.ToDecimal(dt.Rows[x]["quantity"].ToString());
                            decimal total         = Convert.ToDecimal(dt.Rows[x]["total"].ToString());
                            decimal cost          = Convert.ToDecimal(dt.Rows[x]["cost"].ToString());
                            string  category_name = dt.Rows[x]["category_name"].ToString();
                            string  phone_no      = dt.Rows[x]["phone"].ToString();
                            int     bocs          = bloc.insertordercancellation(customer_name, table_no, item_name, quantity, total, cost, "NO", category_name, "K1", phone_no, DateTime.Now, "NULL", "HD");
                        }
                        int vb = blress.voidBillInsert(Convert.ToInt32(dgv_deliver.CurrentRow.Cells["calbill_no"].Value), Convert.ToInt32(0), "Home Delivery Cancel", "True", DateTime.Now, Login.sendtext);//void bill no save
                        int delete_by_table = blord.deletefromtable(table_no);
                        if (delete_by_table > 0)
                        {
                            int hd_no              = (int)table_no;
                            int delete_home_no     = BLLhome.deletehomedeleveryid(hd_no.ToString());
                            int deletehomedelevery = BLLhome.deletehomedeleveryvalue(table_no);
                            MessageBox.Show("Home Delivery Order Has Been Deleted");
                            gridview();
                        }
                    }
                }
            }
        }