private void frmProduct_Load(object sender, EventArgs e) { enable_button(0); server = new LogicProduct(); DataSet dataset = server.getDataBase("SanPham"); dataGridView.DataSource = dataset.Tables[0]; dataGridView.Columns[0].HeaderText = "Mã sản phẩm"; dataGridView.Columns[1].HeaderText = "Mã loại"; dataGridView.Columns[2].HeaderText = "Mã nguồn cung cấp"; dataGridView.Columns[3].HeaderText = "Tên sản phẩm"; dataGridView.Columns[4].HeaderText = "Giá nhập"; dataGridView.Columns[5].HeaderText = "Giá bán"; dataGridView.Columns[6].HeaderText = "Đơn vị tính"; dataGridView.Columns[3].Width = 145; dataGridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; dataGridView.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView.Columns[6].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView.EnableHeadersVisualStyles = false; dataGridView.RowHeadersDefaultCellStyle.BackColor = Color.SkyBlue; dataGridView.ColumnHeadersDefaultCellStyle.BackColor = Color.SkyBlue; dataGridView.RowsDefaultCellStyle.BackColor = Color.WhiteSmoke; dataGridView.AlternatingRowsDefaultCellStyle.BackColor = Color.LightCyan; }
public IActionResult Cart(LogicProduct test) {//need fix quanity add and description add to show on cart string cookie = Request.Cookies["CartItems"]; Dictionary <int, int> winkelmandje = JsonConvert.DeserializeObject <Dictionary <int, int> >(cookie); List <Dataproduct> allproducts = test.Productlist().ToList(); List <Dataproduct> CartProducts = new List <Dataproduct>(); foreach ((int key, int value) in winkelmandje) { CartProducts = allproducts.Where(product => product.Id == key).ToList(); } return(View(CartProducts)); }
private void btnDelete_Click(object sender, EventArgs e) { DialogResult res = MessageBox.Show("Bạn có chắc muốn xóa loại sản phẩm này?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); button = "Delete"; if (res == DialogResult.Yes) { client = new ObjProduct(txtProductCode.Text, txtTypeCode.Text, txtProviderCode.Text, txtProductName.Text, txtImportPrice.Text, txtSalePrice.Text, txtUnit.Text); server = new LogicProduct(); server.setDataBase(client, button); DataSet dataset_AfterDeleting = server.getDataBase("SanPham"); dataGridView.DataSource = dataset_AfterDeleting.Tables[0]; } }
private void btnUpdate_Click(object sender, EventArgs e) { if (button == "Add") { client = new ObjProduct(txtProductCode.Text, txtTypeCode.Text, txtProviderCode.Text, txtProductName.Text, txtImportPrice.Text, txtSalePrice.Text, txtUnit.Text); server = new LogicProduct(); DataSet dataset_Check = server.getDataBase(client); if (dataset_Check.Tables[0].Rows.Count > 0) { MessageBox.Show("Sản phẩm này đã tồn tại trong danh sách", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { server.setDataBase(client, button); dataset_Check = server.getDataBase("SanPham"); dataGridView.DataSource = dataset_Check.Tables[0]; } enable_button(0); button = ""; return; } if (button == "Edit") { client_edited = new ObjProduct(txtProductCode.Text, txtTypeCode.Text, txtProviderCode.Text, txtProductName.Text, txtImportPrice.Text, txtSalePrice.Text, txtUnit.Text); server = new LogicProduct(); server.editDataBase(client, client_edited); DataSet dataset_edit = server.getDataBase("SanPham"); dataGridView.DataSource = dataset_edit.Tables[0]; enable_button(0); button = ""; return; } }