Exemplo n.º 1
0
        public frmPrint(DataTable _dtData, Model.Guess _curGuess, Model.Employee _curEmploy, string _truePrice, string _discount, string _totalPrice)
        {
            InitializeComponent();
            dtData = _dtData;
            int order = 1;

            foreach (DataRow dr in _dtData.Rows)
            {
                dgvData.Rows.Add(order++, dr["name"], dr["outPrice"], dr["unitName"], dr["num"], dr["total"]);
            }

            myBillOutList = new List <Model.BillOut>();
            Connector.readBillOutList(myBillOutList);
            curEmploy = _curEmploy;
            curGuess  = _curGuess;

            // set label total
            lbTruePrice.Text  = _truePrice;
            lbDiscount.Text   = _discount;
            lbTotalPrice.Text = _totalPrice;
            makeToStr         = new MakeToString(Convert.ToDouble(_truePrice.Replace(".", "")));
            makeToStr.BlockProcessing();
            lbMoneyByWord.Text = makeToStr.ReadThis() + " đồng";
            setData();
        }
Exemplo n.º 2
0
        // Đối string là số lượng cần update, sử dụng khi thay đổi số lượng
        // Đối bool để kiểm tra xem có phải vừa thay số lượng hay không?
        // Vì khi combo box thêm vào không kiểm tra sẽ set hết số lượng về 1
        private void displayMoney(string number, string price, bool isUpdate)
        {
            // Lấy vị trí đang được chọn ở dgv, tìm vị trí tương ứng trong dataTable
            // rồi set lại số lượng
            try {
                int     index = dgvData.SelectedRows[0].Index;
                DataRow drow  = dtDgv.Rows[index];
                if (isUpdate)
                {
                    drow["num"]      = number;
                    drow["outPrice"] = price;
                    // Đặt lại thành tiền.
                    int outPrice = int.Parse(drow["outPrice"].ToString());
                    int num      = int.Parse(number);
                    drow["total"]      = (outPrice * num).ToString();
                    dgvData.DataSource = dtDgv;
                }


                // Lấy số lượng ra để tính toán --> Sai vì hắn cộng dồng.
                // Duyệt vòng lặp để tính

                foreach (DataRow dr in dtDgv.Rows)
                {
                    string strOutPrice = dr["outPrice"].ToString();
                    string strNum      = dr["num"].ToString();
                    int    num1        = int.Parse(strNum);
                    int    outPrice1   = int.Parse(strOutPrice);
                    totalPrice += num1 * outPrice1;
                }
                totalGood = dtDgv.Rows.Count;
                truePrice = totalPrice;

                // Hiển thị tổng hàng, tiền hàng, chiết khấu, tiền phải trả
                CultureInfo cul = CultureInfo.GetCultureInfo("vi-VN");
                lbTotalGood.Text  = totalGood.ToString();
                lbTotalPrice.Text = totalPrice.ToString("#,###", cul.NumberFormat);

                // Hiển thị tiền bằng chữ
                MakeToString makeToStr = new MakeToString(Convert.ToDouble(truePrice));
                makeToStr.BlockProcessing();
                rtbMoneyByWord.Text = makeToStr.ReadThis() + " đồng";
            }


            catch (Exception) {
                MessageBox.Show("Phải có ít nhất một mặt hàng");
            }
        }