Esempio n. 1
0
        void addRow(string Name, int SL, int Single, int Sum)
        {
            s++;
            dt.Rows.Add(Name, SL, Single, Sum);
            dataGridView1.DataSource = dt;

            TienHang         += Single;
            richTextBox1.Text = TienHang.ToString();
            TongTien          = TienHang - TienHang * (Convert.ToDouble(richTextBox2.Text) / 100);
            richTextBox3.Text = TongTien.ToString();
            for (int i = 0; i < dt.Rows.Count - 1; i++)
            {
                for (int j = i + 1; j < dt.Rows.Count; j++)
                {
                    string b = dt.Rows[j]["Tên Món Nước"].ToString();
                    if (dt.Rows[i]["Tên Món Nước"].ToString() == b)
                    {
                        dt.Rows[i]["Số lượng"] = Convert.ToInt32(dataGridView1.Rows[i].Cells[1].Value) + Convert.ToInt32(dataGridView1.Rows[j].Cells[1].Value);
                        dataGridView1.Rows.Remove(dataGridView1.Rows[j]);
                        s--;
                        dt.Rows[i]["Thành tiền"] = Convert.ToInt32(dataGridView1.Rows[i].Cells[1].Value) * Convert.ToInt32(dataGridView1.Rows[i].Cells[2].Value);
                    }
                }
            }
        }
Esempio n. 2
0
        private void BtnHoanTat_Click(object sender, EventArgs e)
        {
            int TongTien;

            TongTien = TinhTongThanhTien() + TinhTongChiPhi();
            textBoxTongTienPhieuSuaChua.Text = TongTien.ToString();
            btnHoanTatClicked = true;
        }
Esempio n. 3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            for (int i = 0; i < foodRows; i++)
            {
                dGrFood = foodDataGridView.Rows[i];
                if (cbo_MonAn.Text == dGrFood.Cells["Tên Món Ăn"].Value.ToString())
                {
                    tienFood = Convert.ToInt32(dGrFood.Cells["Giá(VND)"].Value.ToString()) * Convert.ToInt32(num_MonAn.Value.ToString());
                }
            }
            for (int i = 0; i < drinkRows; i++)
            {
                dGrDrink = drinkDataGridView.Rows[i];
                if (cbo_ThucUong.Text == dGrDrink.Cells["Tên Đồ Uống"].Value.ToString())
                {
                    tienDrink = Convert.ToInt32(dGrDrink.Cells["Giá(VND)"].Value.ToString()) * Convert.ToInt32(num_ThucUong.Value.ToString());
                }
            }
            TongTien = tienDrink + tienFood;
            if (Convert.ToInt32(num_MonAn.Value.ToString()) > 0 && Convert.ToInt32(num_ThucUong.Value.ToString()) > 0)
            {
                //Hien Label Food
                lbl_MonAn.Text    = cbo_MonAn.Text;
                lbl_FooDSL.Text   = num_MonAn.Value.ToString();
                lbl_TienFood.Text = tienFood.ToString() + " VND";

                //Hien Label Drink
                lbl_DoUong.Text    = cbo_ThucUong.Text;
                lbl_DrinkSL.Text   = num_ThucUong.Value.ToString();
                lbl_TienDrink.Text = tienDrink.ToString() + " VND";
            }
            else if (Convert.ToInt32(num_MonAn.Value.ToString()) > 0 && Convert.ToInt32(num_ThucUong.Value.ToString()) == 0)
            {
                //Hien Label Food
                lbl_MonAn.Text    = cbo_MonAn.Text;
                lbl_FooDSL.Text   = num_MonAn.Value.ToString();
                lbl_TienFood.Text = tienFood.ToString() + " VND";

                //Hien Label Drink
                lbl_DoUong.Text    = "";
                lbl_DrinkSL.Text   = "";
                lbl_TienDrink.Text = "";
            }
            else if (Convert.ToInt32(num_MonAn.Value.ToString()) == 0 && Convert.ToInt32(num_ThucUong.Value.ToString()) > 0)
            {
                //Hien Label Food
                lbl_MonAn.Text    = "";
                lbl_FooDSL.Text   = "";
                lbl_TienFood.Text = "";

                //Hien Label Drink
                lbl_DoUong.Text    = cbo_ThucUong.Text;
                lbl_DrinkSL.Text   = num_ThucUong.Value.ToString();
                lbl_TienDrink.Text = tienDrink.ToString() + " VND";
            }
            else if (Convert.ToInt32(num_MonAn.Value.ToString()) == 0 && Convert.ToInt32(num_ThucUong.Value.ToString()) == 0)
            {
                //Label
                lbl_TongTien.Text  = "";
                lbl_MonAn.Text     = "";
                lbl_FooDSL.Text    = "";
                lbl_TienFood.Text  = "";
                lbl_DoUong.Text    = "";
                lbl_DrinkSL.Text   = "";
                lbl_TienDrink.Text = "";
                TongTien           = 0;
            }
            //Hien Labal Tong Tien
            lbl_TongTien.Text = TongTien.ToString() + " VND";
        }
Esempio n. 4
0
        private void btn_TinhTien_Click(object sender, EventArgs e)
        {
            bool isSimiliar = false;

            for (int i = 0; i < customerRows; i++)
            {
                dGrCustomer = sellingDataGridView.Rows[i];
                if (txt_MaPhieu.Text == dGrCustomer.Cells["MaPhieu"].Value.ToString())
                {
                    isSimiliar = true;
                    MessageBox.Show("Không thể thanh toán vì trùng Mã Phiếu:  " + txt_MaPhieu.Text);
                }
            }
            if (isSimiliar == false && TongTien > 0 && txt_MaPhieu.Text.Length > 0)
            {
                DialogResult dialog = MessageBox.Show("Đồng Ý Thanh Toán", "Xác Nhận Thanh Toán", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialog == DialogResult.Yes)
                {
                    if (Convert.ToInt32(num_MonAn.Value.ToString()) > 0 && Convert.ToInt32(num_ThucUong.Value.ToString()) > 0)
                    {
                        DataRow dr      = sellingTable.NewRow();
                        string  truyVan = string.Format("Insert into SellingInfo(MaPhieu, FoodName, SLFood, DrinkName, SLDrink, TongTien) values (@MaPhieu, @FoodName, @SLFood, @DrinkName, @SLDrink, @TongTien)", sqlConnect);
                        cmd = new SqlCommand(truyVan, sqlConnect);

                        cmd.Parameters.Add("@MaPhieu", SqlDbType.NVarChar, 50, "MaPhieu");
                        cmd.Parameters.Add("@FoodName", SqlDbType.NVarChar, 50, "FoodName");
                        cmd.Parameters.Add("@SLFood", SqlDbType.Int, 10, "SLFood");
                        cmd.Parameters.Add("@DrinkName", SqlDbType.NVarChar, 50, "DrinkName");
                        cmd.Parameters.Add("@SLDrink", SqlDbType.Int, 10, "SLDrink");
                        cmd.Parameters.Add("@TongTien", SqlDbType.Int, 10, "TongTien");

                        dr[0] = txt_MaPhieu.Text;
                        dr[1] = cbo_MonAn.Text;
                        dr[2] = num_MonAn.Value.ToString();
                        dr[3] = cbo_ThucUong.Text;
                        dr[4] = num_ThucUong.Value.ToString();
                        dr[5] = TongTien.ToString();
                        sellingTable.Rows.Add(dr);

                        sqlDaSelling.InsertCommand = cmd;
                        sqlDaSelling.Update(sellingTable);
                    }
                    else if (Convert.ToInt32(num_MonAn.Value.ToString()) > 0 && Convert.ToInt32(num_ThucUong.Value.ToString()) == 0)
                    {
                        DataRow dr      = sellingTable.NewRow();
                        string  truyVan = string.Format("Insert into SellingInfo(MaPhieu, FoodName, SLFood, DrinkName, SLDrink, TongTien) values (@MaPhieu, @FoodName, @SLFood, @DrinkName, @SLDrink, @TongTien)", sqlConnect);
                        cmd = new SqlCommand(truyVan, sqlConnect);

                        cmd.Parameters.Add("@MaPhieu", SqlDbType.NVarChar, 50, "MaPhieu");
                        cmd.Parameters.Add("@FoodName", SqlDbType.NVarChar, 50, "FoodName");
                        cmd.Parameters.Add("@SLFood", SqlDbType.Int, 10, "SLFood");
                        cmd.Parameters.Add("@DrinkName", SqlDbType.NVarChar, 50, "DrinkName");
                        cmd.Parameters.Add("@SLDrink", SqlDbType.Int, 10, "SLDrink");
                        cmd.Parameters.Add("@TongTien", SqlDbType.Int, 10, "TongTien");

                        dr[0] = txt_MaPhieu.Text;
                        dr[1] = cbo_MonAn.Text;
                        dr[2] = num_MonAn.Value.ToString();
                        dr[3] = "Không";
                        dr[4] = num_ThucUong.Value.ToString();
                        dr[5] = TongTien.ToString();
                        sellingTable.Rows.Add(dr);

                        sqlDaSelling.InsertCommand = cmd;
                        sqlDaSelling.Update(sellingTable);
                    }
                    else if (Convert.ToInt32(num_MonAn.Value.ToString()) == 0 && Convert.ToInt32(num_ThucUong.Value.ToString()) > 0)
                    {
                        DataRow dr      = sellingTable.NewRow();
                        string  truyVan = string.Format("Insert into SellingInfo(MaPhieu, FoodName, SLFood, DrinkName, SLDrink, TongTien) values (@MaPhieu, @FoodName, @SLFood, @DrinkName, @SLDrink, @TongTien)", sqlConnect);
                        cmd = new SqlCommand(truyVan, sqlConnect);

                        cmd.Parameters.Add("@MaPhieu", SqlDbType.NVarChar, 50, "MaPhieu");
                        cmd.Parameters.Add("@FoodName", SqlDbType.NVarChar, 50, "FoodName");
                        cmd.Parameters.Add("@SLFood", SqlDbType.Int, 10, "SLFood");
                        cmd.Parameters.Add("@DrinkName", SqlDbType.NVarChar, 50, "DrinkName");
                        cmd.Parameters.Add("@SLDrink", SqlDbType.Int, 10, "SLDrink");
                        cmd.Parameters.Add("@TongTien", SqlDbType.Int, 10, "TongTien");

                        dr[0] = txt_MaPhieu.Text;
                        dr[1] = "Không";
                        dr[2] = num_MonAn.Value.ToString();
                        dr[3] = cbo_ThucUong.Text;
                        dr[4] = num_ThucUong.Value.ToString();
                        dr[5] = TongTien.ToString();
                        sellingTable.Rows.Add(dr);

                        sqlDaSelling.InsertCommand = cmd;
                        sqlDaSelling.Update(sellingTable);
                    }
                }
            }
            if (isSimiliar == false && TongTien == 0)
            {
                MessageBox.Show("Vui lòng chọn món");
            }
            if (isSimiliar == false && txt_MaPhieu.Text.Length == 0)
            {
                MessageBox.Show("Vui lòng nhập mã Phiếu");
            }
            txt_MaPhieu.Text = "";
        }