Exemple #1
0
 private void iconButton4_Click(object sender, EventArgs e)
 {
     if (Int32.Parse(lbKho.Text) > Int32.Parse(txtSL.Text))
     {
         txtSL.Text     = (Int32.Parse(txtSL.Text) + 1).ToString();
         soluong        = Int32.Parse(txtSL.Text);
         lbTienChu.Text = Ham.ChuyenSo((giaban * soluong).ToString()) + " đồng";
     }
 }
Exemple #2
0
 private void txtSL_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (Int32.Parse(lbKho.Text) < Int32.Parse(txtSL.Text))
         {
             txtSL.Text     = lbKho.Text;
             soluong        = Int32.Parse(txtSL.Text);
             lbTienChu.Text = Ham.ChuyenSo((giaban * soluong).ToString()) + " đồng";
         }
     }
     catch (Exception)
     {
         txtSL.Text = "1";
         MessageBox.Show("Nhập số?", "Thông báo!");
     }
 }
Exemple #3
0
        private void getSP()
        {
            var data = conn.getDataTable("select s.id,s.ten,s.soluong,s.giaban,s.giaKM,s.mausac, s.manhinh,s.camera,s.cpu,s.ram,s.rom,s.baohanh,s.phukiendikem,s.ngaynhap,s.mota,s.luotxem,s.danhgia,l.ten from SanPham s join loaisanpham l on s.loaispId = l.id where s.id = " + Id);

            if (data.Rows.Count > 0)
            {
                lbTen.Text = data.Rows[0][1].ToString() + " - " + data.Rows[0][10].ToString() + " GB";
                if (data.Rows[0][4].ToString() == "0")
                {
                    lbGiaKM.Text = String.Format("{0:#,##0.##}", Int32.Parse(data.Rows[0][3].ToString())) + " đồng";
                    giaban       = Int32.Parse(data.Rows[0][3].ToString());
                }
                else
                {
                    lbGiaKM.Text  = String.Format("{0:#,##0.##}", Int32.Parse(data.Rows[0][4].ToString())) + " đồng";
                    lbgiaBan.Text = String.Format("{0:#,##0.##}", Int32.Parse(data.Rows[0][3].ToString())) + " đồng";
                    giaban        = Int32.Parse(data.Rows[0][4].ToString());
                }
                lbTienChu.Text = Ham.ChuyenSo((giaban * Int32.Parse(txtSL.Text)).ToString()) + " đồng";
                lbMauSac.Text  = data.Rows[0][5].ToString();
                if (data.Rows[0][2].ToString() == "0")
                {
                    lbKho.Text         = "Hết hàng";
                    btnDatHang.Enabled = false;
                    btnGiam.Enabled    = false;
                    btnTang.Enabled    = false;
                    txtSL.Enabled      = false;
                }
                else
                {
                    lbKho.Text = data.Rows[0][2].ToString();
                }

                lbMota.Text        = data.Rows[0][14].ToString();
                lbManHinh.Text     = data.Rows[0][6].ToString() + " INCH FULLHD";
                lbCamera.Text      = data.Rows[0][7].ToString();
                lbCPU.Text         = data.Rows[0][8].ToString();
                lbRam.Text         = data.Rows[0][9].ToString() + "GB";
                lbRom.Text         = data.Rows[0][10].ToString() + "GB";
                lbLoaiSanPham.Text = data.Rows[0][17].ToString();
            }
        }
        // LAY THÔNG TIN CHI TIẾT PHIẾU ĐỔ VÀO DATATABLE
        private void getChiTietPhieu()
        {
            string sql = "SELECT ct.id as 'Mã',ct.spId as 'Mã SP',s.ten as 'Tên', ls.ten as 'Loại',ct.soluong as 'Số lượng',ct.dongia as 'Đơn giá'" +
                         "from chitietphieu ct join sanpham s on ct.spId = s.id left join nhacungcap ls on s.nccId = ls.id where phieuId =" + phieuId;
            DataTable dt = cn.getDataTable(sql);

            dataGridView1.DataSource = dt;
            if (dt.Rows.Count > 0)
            {
                int sl       = 0;
                int tongtien = 0;
                foreach (DataRow item in dt.Rows)
                {
                    sl       += Int32.Parse(item[4].ToString());
                    tongtien += Int32.Parse((Int32.Parse(item[4].ToString()) * Int32.Parse(item[5].ToString())).ToString());
                }
                lbSoLuong.Text  = sl.ToString();
                lbtongtien.Text = tongtien.ToString();
                lbtongchu.Text  = Ham.ChuyenSo(tongtien.ToString()) + " đồng.";
            }
        }