public Form1() { InitializeComponent(); this.cblist = new System.Windows.Forms.ComboBox(); // // cblist // this.cblist.FormattingEnabled = true; cblist.Items.AddRange(ThietBiBUS.Loaitb()); this.cblist.Location = new System.Drawing.Point(0, 36); this.cblist.Name = "cblist"; this.cblist.Size = new System.Drawing.Size(121, 24); this.cblist.TabIndex = 4; this.Controls.Add(this.cblist); //datatable DataTable table = new DataTable(); table.Columns.Add("Weight", typeof(int)); table.Columns.Add("Name", typeof(string)); table.Columns.Add("Breed", typeof(string)); table.Columns.Add("Date", typeof(DateTime)); object[] array = new object[4]; array[0] = 7; array[1] = "Candy"; array[2] = "Yorkshire Terrier"; array[3] = DateTime.Now; table.Rows.Add(array); }
protected void Page_Load(object sender, EventArgs e) { List <ThietBi> tb = ThietBiBUS.ListTB(); foreach (var item in tb) { HtmlTableRow row = new HtmlTableRow(); HtmlTableCell cell = new HtmlTableCell(); cell.InnerText = item.Matb; HtmlTableCell cell1 = new HtmlTableCell(); cell1.InnerText = item.Tentb; HtmlTableCell cell2 = new HtmlTableCell(); cell2.InnerText = item.Loaitb; HtmlTableCell cell3 = new HtmlTableCell(); cell3.InnerText = item.Dongia.ToString(); HtmlTableCell cell4 = new HtmlTableCell(); cell4.InnerText = item.SL.ToString(); row.Controls.Add(cell); row.Controls.Add(cell1); row.Controls.Add(cell2); row.Controls.Add(cell3); row.Controls.Add(cell4); tbl_ThietBi.Controls.Add(row); } }
private void cbbLoai_SelectedValueChanged(object sender, EventArgs e) { if (cbbLoai.SelectedValue != null) { dgvSanPham.DataSource = ThietBiBUS.GetThietBiTheoLoai(cbbLoai.SelectedValue as String); dgvSanPham.Columns[0].Visible = false; dgvSanPham.Columns[1].HeaderText = "Tên thiết bị"; dgvSanPham.Columns[2].HeaderText = "Số Lượng"; dgvSanPham.Columns[3].HeaderText = "Giá"; dgvSanPham.Columns[4].HeaderText = "Loại"; } }
private void LoadThietBi() { List <ThietBi> list = ThietBiBUS.ListTB(); if (list.Count > 0) { dgvSanPham.DataSource = list; dgvSanPham.Columns[0].Visible = false; dgvSanPham.Columns[1].HeaderText = "Tên thiết bị"; dgvSanPham.Columns[2].HeaderText = "Số Lượng"; dgvSanPham.Columns[3].HeaderText = "Giá"; dgvSanPham.Columns[4].HeaderText = "Loại"; } else { dgvSanPham.DataSource = null; } }
private void dgvSanPham_CellEndEdit(object sender, DataGridViewCellEventArgs e) { DialogResult re = MessageBox.Show("Bạn có muốn lưu không?", "Thông báo", MessageBoxButtons.YesNo); if (re == DialogResult.Yes) { ThietBi tb = (dgvSanPham.DataSource as List <ThietBi>)[e.RowIndex]; if (ThietBiBUS.EditThietBi(tb) == 0) { MessageBox.Show("Kiểm tra lại kết nối của bạn.", "Thông báo"); LoadThietBi(); } } else { dgvSanPham[e.ColumnIndex, e.RowIndex].Value = beedit; } }
public static List <ThietBiDTO> GetByType(int Id) { ThietBiBUS tbBus_gbt = new ThietBiBUS(); List <ThietBiDTO> rs = new List <ThietBiDTO>(); DataTable tb = tbBus_gbt.GetByType(Id); foreach (DataRow row in tb.Rows) { int TBId = int.Parse(row.ItemArray[0].ToString()); string TBName = row.ItemArray[1].ToString(); int LTBId = int.Parse(row.ItemArray[2].ToString()); int Price = int.Parse(row.ItemArray[3].ToString()); int Qty = int.Parse(row.ItemArray[4].ToString()); ThietBiDTO temp = new ThietBiDTO(TBId, TBName, LTBId, Price, Qty); rs.Add(temp); } return(rs); }
private void btnLuu_Click(object sender, EventArgs e) { // Kiểm tra thông tin rỗng if (!CheckEmpty()) { MessageBox.Show("Vui lòng nhập đầy đủ thông tin.", "Thông báo"); return; } // Thực hiện thêm thiết bị ThietBi tbMoi = new ThietBi(String.Empty, txbTen.Text, txbLoai.Text, Int32.Parse(txbSoLuong.Text), Int32.Parse(txbGia.Text)); if (ThietBiBUS.AddThietBi(tbMoi) > 0) { this.Close(); } else { MessageBox.Show("Lưu không thành công.", "Thông báo"); } }
private void updateProduct(object sender, EventArgs e) { int rs; if (txtEditProduct.Text.ToString() == "" || txtEditProductQty.Text.ToString() == "" || txtEditProductPrice.Text.ToString() == "") { MessageBox.Show("Không được để trống"); } else if (int.TryParse(txtEditProductQty.Text.ToString(), out rs) == false || int.TryParse(txtEditProductPrice.Text.ToString(), out rs) == false) { MessageBox.Show("Giá và số lượng phải nhập số"); } else if (Convert.ToInt32(txtEditProductQty.Text.ToString()) < 0 || Convert.ToInt32(txtEditProductPrice.Text.ToString()) < 0) { MessageBox.Show("Giá và số lượng phải là số dương"); } else { int idEditProduct = Convert.ToInt32(lblId.Text.ToString()); string NameEditProduct = txtEditProduct.Text.ToString(); int TypeProductEdit = cbxEditProductType.SelectedIndex + 1; int EditProductQty = Convert.ToInt32(txtEditProductQty.Text.ToString()); int EditProductPrice = Convert.ToInt32(txtEditProductPrice.Text.ToString()); ThietBiDTO thietBiDTO = new ThietBiDTO(idEditProduct, NameEditProduct, TypeProductEdit, EditProductPrice, EditProductQty); ThietBiBUS thietBiBUS = new ThietBiBUS(); thietBiBUS.Edit(thietBiDTO); grvProduct.Rows.Clear(); getProduct(); lblId.Text = ""; txtEditProduct.Text = ""; cbxEditProductType.DataSource = null; cbxEditProductType.Items.Clear(); txtEditProductQty.Text = ""; txtEditProductPrice.Text = ""; } }
public void getProduct() { ThietBiBUS thietBiBus = new ThietBiBUS(); DataTable dtTB = new DataTable(); dtTB = thietBiBus.GetAll(); List <string> listLoaiThietBi = getLoaiThietBi(); foreach (DataRow row in dtTB.Rows) { int n = grvProduct.Rows.Add(); grvProduct.Rows[n].Cells[0].Value = row[0].ToString(); grvProduct.Rows[n].Cells[1].Value = row[1].ToString(); var cellComboBox = new DataGridViewComboBoxCell(); cellComboBox.DataSource = listLoaiThietBi; grvProduct.Rows[n].Cells[2] = cellComboBox; grvProduct.Rows[n].Cells[2].Value = listLoaiThietBi[Convert.ToInt32(row[2].ToString()) - 1]; grvProduct.Rows[n].Cells[3].Value = row[3].ToString(); grvProduct.Rows[n].Cells[4].Value = row[4].ToString(); } }
private void addProduct(object sender, EventArgs e) { int rs; if (txtThietBiName.Text.ToString() == "" || cbxAddProduct.SelectedIndex == 0 || txtQtyAdd.Text.ToString() == "" || txtPriceAdd.Text.ToString() == "") { MessageBox.Show("Không được để trống"); } else if (int.TryParse(txtQtyAdd.Text.ToString(), out rs) == false || int.TryParse(txtPriceAdd.Text.ToString(), out rs) == false) { MessageBox.Show("Giá và số lượng phải nhập số"); } else if (Convert.ToInt32(txtQtyAdd.Text.ToString()) < 0 || Convert.ToInt32(txtPriceAdd.Text.ToString()) < 0) { MessageBox.Show("Giá và số lượng phải là số dương"); } else { int TBId = 0; string TBName = txtThietBiName.Text.ToString(); int LTBAdd = cbxAddProduct.SelectedIndex; int QtyAdd = Convert.ToInt32(txtQtyAdd.Text.ToString()); int PriceAdd = Convert.ToInt32(txtPriceAdd.Text.ToString()); ThietBiDTO thietBiDTO = new ThietBiDTO(TBId, TBName, LTBAdd, PriceAdd, QtyAdd); ThietBiBUS thietBiBUS = new ThietBiBUS(); thietBiBUS.Add(thietBiDTO); grvProduct.Rows.Clear(); getProduct(); txtThietBiName.Text = ""; cbxAddProduct.SelectedIndex = 0; txtQtyAdd.Text = ""; txtPriceAdd.Text = ""; } }
public static List <ThietBiDTO> GetByName(string keyword) { List <ThietBiDTO> rs = new List <ThietBiDTO>(); ThietBiBUS _tbBus = new ThietBiBUS(); DataTable tb = _tbBus.GetAll(); //if(keyword=="") //{ // foreach (DataRow row in tb.Rows) // { // int TBId = int.Parse(row.ItemArray[0].ToString()); // string TBName = row.ItemArray[1].ToString(); // int LTBId = int.Parse(row.ItemArray[2].ToString()); // int Price = int.Parse(row.ItemArray[3].ToString()); // int Qty = int.Parse(row.ItemArray[4].ToString()); // ThietBiDTO temp = new ThietBiDTO(TBId, TBName, LTBId, Price, Qty); // rs.Add(temp); // } // return rs; //} foreach (DataRow row in tb.Rows) { if (row.ItemArray[1].ToString().ToUpper().Contains(keyword.ToUpper())) { int TBId = int.Parse(row.ItemArray[0].ToString()); string TBName = row.ItemArray[1].ToString(); int LTBId = int.Parse(row.ItemArray[2].ToString()); int Price = int.Parse(row.ItemArray[3].ToString()); int Qty = int.Parse(row.ItemArray[4].ToString()); ThietBiDTO temp = new ThietBiDTO(TBId, TBName, LTBId, Price, Qty); rs.Add(temp); } } return(rs); }
private void LoadLoai() { String[] list = ThietBiBUS.Loaitb(); cbbLoai.DataSource = list; }
public static void UpdateTBQty(int id, int qty) { ThietBiBUS _tbbus = new ThietBiBUS(); _tbbus.UpdateQty(id, qty); }