示例#1
0
        public void save_and_print()
        {
            decimal parsdec;

            if (dataGridView1.Rows.Count > 0)
            {
                if (!decimal.TryParse(lbltable.Text, out parsdec))
                {
                    MessageBox.Show("Input Error In Table No");
                }
                else if (txtcardamount.Text == "0.00" & txtcashamount.Text == "0.00" || txtcardamount.Text == "0" & txtcashamount.Text == "0")
                {
                    MessageBox.Show("Transaction Cannot Be Processed With Out Cash Or Card Amount");
                }
                else if (txtcardamount.Text != "0.00" || txtcashamount.Text != "0.00")
                {
                    printtobill();
                    if (save_value_toprint == true)
                    {
                        string payment_mode;
                        for (int a = 0; a < dataGridView1.Rows.Count; a++)
                        {
                            string  item           = (dataGridView1.Rows[a].Cells["cal_item_name"].Value.ToString());
                            int     quantity       = Convert.ToInt32(dataGridView1.Rows[a].Cells["cal_qty"].Value.ToString());
                            decimal cost           = Convert.ToDecimal(dataGridView1.Rows[a].Cells["cal_cost"].Value.ToString());
                            decimal total          = Convert.ToDecimal(dataGridView1.Rows[a].Cells["cal_total"].Value.ToString());
                            string  category_name1 = dataGridView1.Rows[a].Cells["cal_category_name"].Value.ToString();
                            //string date = DateTime.Now.ToShortDateString()+" "+DateTime.Now.ToShortTimeString();
                            DateTime date = Convert.ToDateTime(DateTime.Now.ToString());
                            if (chkcash.Checked)
                            {
                                payment_mode = "Cash";
                            }

                            else if (chkcard.Checked)
                            {
                                payment_mode = "Card";
                            }
                            else if (chkcredit.Checked)
                            {
                                payment_mode = "Credit";
                            }
                            else
                            {
                                payment_mode = "Cash/Card";
                            }
                            // int b = blresll.insertintosalesbook(Convert.ToInt32(txtnewbillno.Text), date, txtcashier.Text, lbltable.Text, customername, customermobile, item, quantity, cost, total, payment_mode, cardno, Convert.ToDecimal(txtsubtotal.Text), Convert.ToDecimal(txtdiscount.Text), Convert.ToDecimal(txtcashamount.Text), Convert.ToDecimal(txtcardamount.Text), Convert.ToDecimal(txtgrandtotal.Text), category_name1, "TA", "X");

                            button1WasClicked = true;

                            MessageBox.Show("Data has been save to database with new");

                            foreach (DataGridViewRow row in dataGridView1.Rows)
                            {
                                int order_id = Convert.ToInt32(row.Cells["cal_order_id"].Value);
                                int i        = blord.deletefromorder_id(order_id);
                            }

                            dataGridView1.Rows.Clear();
                        }
                    }
                }
            }
        }
示例#2
0
        private void btn_item_transfer_Click(object sender, EventArgs e)
        {
            if (cbo_table_no_choose.Text != "Choose One" && cbo_table_no_choose.SelectedIndex > 0 && cbo_table_no_choose.Text != "")
            {
                if (dataGridView2.Rows.Count > 0)
                {
                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {
                        string order_id = dataGridView1.Rows[i].Cells["cal_order_id"].Value.ToString();
                        string qty      = dataGridView1.Rows[i].Cells["cal_qty"].Value.ToString();
                        string total    = dataGridView1.Rows[i].Cells["cal_total"].Value.ToString();
                        string status   = dataGridView1.Rows[i].Cells["cal_status"].Value.ToString();
                        if (status == "Update")
                        {
                            int update = blo.updateorderstable(Convert.ToDecimal(qty), Convert.ToInt32(order_id), Convert.ToDecimal(total)); //this stattement will update the item of datagridview1
                        }
                    }
                    for (int i = 0; i < dataGridView2.Rows.Count; i++)
                    {
                        string order_id      = dataGridView2.Rows[i].Cells["cal_order_id_2"].Value.ToString();
                        string qty           = dataGridView2.Rows[i].Cells["cal_qty_2"].Value.ToString();
                        string total         = dataGridView2.Rows[i].Cells["cal_total_2"].Value.ToString();
                        string category_name = dataGridView2.Rows[i].Cells["cal_category_name2"].Value.ToString();
                        string kot_type      = dataGridView2.Rows[i].Cells["cal_kot_type_2"].Value.ToString();
                        string item_name     = dataGridView2.Rows[i].Cells["cal_item_name2"].Value.ToString();
                        string cost          = dataGridView2.Rows[i].Cells["cal_cost_2"].Value.ToString();
                        string status        = dataGridView2.Rows[i].Cells["cal_status_2"].Value.ToString();
                        string table_no      = cbo_table_no_choose.SelectedValue.ToString();
                        if (status == "I")
                        {
                            //DataTable dt = blo.getallbyitem_nameandTableno(item_name, table_no);
                            //if (dt.Rows.Count == 0)
                            //{
                            int insert_order = blo.insertorder_using_sp(Login.sendtext, Convert.ToDecimal(table_no), item_name, Convert.ToDecimal(qty), Convert.ToDecimal(total), Convert.ToDecimal(cost), "Y", category_name, kot_type, "TS", "0", 0);    //this will insert data of datagridview2

                            if (dataGridView2.Rows[i].Cells["cal_delete_status"].Value.ToString() == "True")
                            {
                                int delete_item = blo.deletefromorder_id(Convert.ToInt32(order_id));
                            }
                            //else
                            //{
                            //int updateOrder = blo.updateorderItemTransfer(Convert.ToInt32(order_id), Convert.ToDecimal(table_no));
                            // }
                        }
                        else
                        {
                            int updateOrder = blo.updateorderItemTransfer(Convert.ToInt32(order_id), Convert.ToDecimal(table_no));//this will update datagridview2
                        }
                    }
                    this.Close();
                }
                else
                {
                    MessageBox.Show("There is no data to transfer.", "Invalid Item Transfer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Choose Correct Table No.", "Invalid Table No", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }