Exemple #1
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);
            }
        }
Exemple #2
0
 private void btn_ok_Click(object sender, EventArgs e)
 {
     if (dataGridView1.Rows.Count > 0)
     {
         clearModel();
         for (int i = 0; i < dataGridView1.Rows.Count; i++)
         {
             VoidModel.item_name.Add(dataGridView1.Rows[i].Cells["cal_item_name"].Value.ToString());
             VoidModel.qty.Add(dataGridView1.Rows[i].Cells["cal_qty"].Value.ToString());
             VoidModel.total.Add(dataGridView1.Rows[i].Cells["cal_total"].Value.ToString());
             VoidModel.cost.Add(dataGridView1.Rows[i].Cells["cal_cost"].Value.ToString());
             VoidModel.category_name.Add(dataGridView1.Rows[i].Cells["cal_category_name"].Value.ToString());
             VoidModel.kot_type.Add(dataGridView1.Rows[i].Cells["calkot_print"].Value.ToString());
             if (orderstatus == "HD")
             {
                 if (dataGridView1.Rows[i].Cells["cal_order_id"].Value == null)
                 {
                     int insert_order = blord.insertorder_using_sp(Login.sendtext, Convert.ToDecimal(home_delivery_id), VoidModel.item_name[i], Convert.ToDecimal(dataGridView1.Rows[i].Cells["cal_qty"].Value), Convert.ToDecimal(dataGridView1.Rows[i].Cells["cal_total"].Value), Convert.ToDecimal(dataGridView1.Rows[i].Cells["cal_cost"].Value), "HD", VoidModel.category_name[i], VoidModel.kot_type[i], "HD", service_provider_name.ToString(), kot_id);
                     if (insert_order > 0)
                     {
                         if (Convert.ToDecimal(home_delivery_id) >= 106)
                         {
                             if (Convert.ToDecimal(home_delivery_id) < 1000)
                             {
                                 int hd_no       = blhd.inserthomedeleveryid(Convert.ToInt32(home_delivery_id));
                                 int customer_id = HomeDeliveryModel.customer_id;
                                 if (customer_id > 0)
                                 {
                                     int insertCustomerid = blcdn.insertHomeDeliveryCustomer(customer_id.ToString(), home_delivery_id);
                                 }
                             }
                         }
                     }
                     if (dataGridView1.Rows[i].Cells["calkot_print"].Value.ToString() == "K1")
                     {
                         kot_printer_1 = true;
                     }
                     if (dataGridView1.Rows[i].Cells["calkot_print"].Value.ToString() == "K2")
                     {
                         kot_printer_2 = true;
                     }
                     if (dataGridView1.Rows[i].Cells["calkot_print"].Value.ToString() == "B1")
                     {
                         kot_printer_3 = true;
                     }
                 }
             }
         }
         if (orderstatus == "HD")
         {
             kot_printChecker();
             // this.Close();
             if (Application.OpenForms.OfType <home>().Count() == 1)
             {
                 Application.OpenForms.OfType <home>().First().Close();
             }
             home h = new home(home_delivery_id);
             h.ShowDialog();
         }
         this.Hide();
     }
     else
     {
         clearModel();
         this.Hide();
     }
 }