private void DGV_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            indexClicked = e.RowIndex;

            DienThoai DT = new DienThoai(DGV.Rows[indexClicked]);

            DoDuLieuRa(DT);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sửa dữ liệu của MaSP cũ bằng dữ liệu của DT.
        /// </summary>
        public static void UpdateDuLieu(string MaSPCu, DienThoai DT)
        {
            string sql = "update DienThoai " +
                         "set MaSP = '" + DT.GSMaSP + "', TenSP = N'" + DT.GSTenSP + "', XuatSu = N'" + DT.GSXuatSu + "', DonGia = " + DT.GSDonGia + ", SoLuong = " + DT.GSSoLuong + ", ThanhTien = " + DT.ThanhTien() + " " +
                         "where MaSP = '" + MaSPCu + "'";

            Command(sql);
        }
 /// <summary>
 /// Đổ dữ liệu DT ra màn hình.
 /// </summary>
 private void DoDuLieuRa(DienThoai DT)
 {
     TB_MaSP.Text           = DT.GSMaSP;
     TB_TenSP.Text          = DT.GSTenSP;
     CB_XuatSu.SelectedItem = DT.GSXuatSu;
     TB_DonGia.Text         = DT.GSDonGia.ToString();
     NUD_SoLuong.Value      = DT.GSSoLuong;
 }
        private void BT_Them_Click(object sender, EventArgs e)
        {
            DienThoai DT = LayDuLieuVao();

            DBConnection.InsertDuLieu(DT);

            CapNhatDGV();

            XoaDuLieuNhap();
        }
        /// <summary>
        /// Lấy dữ liệu người dùng nhập vào và chuyển thành Object DienThoai.
        /// </summary>
        private DienThoai LayDuLieuVao()
        {
            DienThoai DT = new DienThoai();

            DT.GSMaSP    = TB_MaSP.Text;
            DT.GSTenSP   = TB_TenSP.Text;
            DT.GSXuatSu  = CB_XuatSu.SelectedItem.ToString();
            DT.GSDonGia  = Convert.ToDouble(TB_DonGia.Text);
            DT.GSSoLuong = Convert.ToInt32(NUD_SoLuong.Value);

            return(DT);
        }
        private void BT_Sua_Click(object sender, EventArgs e)
        {
            string MaSPCanSua = DGV.Rows[indexClicked].Cells[0].Value.ToString();

            DienThoai DT = LayDuLieuVao();

            DBConnection.UpdateDuLieu(MaSPCanSua, DT);

            CapNhatDGV();

            indexClicked = -1;

            XoaDuLieuNhap();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Insert dữ liệu DT vào DataBase.
        /// </summary>
        public static void InsertDuLieu(DienThoai DT)
        {
            string sql = "insert into DienThoai values('" + DT.GSMaSP + "', N'" + DT.GSTenSP + "', N'" + DT.GSXuatSu + "'," + DT.GSDonGia + "," + DT.GSSoLuong + "," + DT.ThanhTien() + ")";

            Command(sql);
        }