private void buttonOK_Click(object sender, EventArgs e) { if (ValidateForm()) { Model_Category cate = (Model_Category)cbxSanPham.SelectedItem; Model_Color color = (Model_Color)cbxMauSac.SelectedItem; Model_Object obj = (Model_Object)cbxDoituong.SelectedItem; Model_RawMaterial material = (Model_RawMaterial)cbxChatLieu.SelectedItem; Model_Season season = (Model_Season)cbxMua.SelectedItem; Model_Size size = (Model_Size)cbxKichco.SelectedItem; int quantity = int.Parse(textBox_soluong.Text); string Name = textBox_TenSP.Text; decimal priceEntry = decimal.Parse(textBox_GiaNhap.Text); decimal priceSell = decimal.Parse(textBox_GiaBan.Text); Model_Manufactured manufactured = (Model_Manufactured)cbxNSX.SelectedItem; Model_Product model = new Model_Product(Name, cate, size, material, color, obj, season, manufactured, quantity, priceEntry, priceSell); if (textBoxAddpicture.Text != "") { model.Picture = fileName; } try { if (isAdjust == false) { GlobalConfig.Connection.InsertNewProduct(model); MessageBox.Show("Thêm Sản Phẩm Thành Công !", "Thông Báo", MessageBoxButtons.OK); this.Dispose(); } else { //dòng 319 chưa có ID nên lúc sửa phải gán lại ID , biến ID là biến toàn cục model.ID = ID; //nếu thay đổi ảnh thì vào chỗ if này if (textBoxAddpicture.Text != "") { model.Picture = fileName; } else { //nếu k có thay đổi gì thì lấy link ảnh từ db model.Picture = GlobalConfig.Connection.find_anh(model.ID); } //update thôi GlobalConfig.Connection.UpdateProduct(model); MessageBox.Show("Sửa Sản Phẩm Thành Công !", "Thông Báo", MessageBoxButtons.OK); this.Dispose(); } } catch { MessageBox.Show("Lỗi Thêm Nhân viên vào Database Liên hệ Thảo để fix :)", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } }
public void DeleteSize(Model_Size model) { DynamicParameters p = new DynamicParameters(); p.Add("@ID", model.ID); using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.ConnectionString("Clothes"))) { connection.Execute("DeleteSize", p, commandType: CommandType.StoredProcedure); } }
public Model_Size CreateNew_Size(Model_Size model) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.ConnectionString("Clothes"))) { var p = new DynamicParameters(); p.Add("@Size", model.Size); p.Add("@id", 0, DbType.Int32, direction: ParameterDirection.Output); connection.Execute("dbo.NewSize", p, commandType: CommandType.StoredProcedure); model.ID = p.Get <int>("@id"); return(model); } }
public Model_Product(string name, Model_Category category, Model_Size size, Model_RawMaterial material, Model_Color color, Model_Object @object, Model_Season season, Model_Manufactured manufactured, int quantity, decimal priceEntry, decimal priceSell) { Name = name; Category = category; Size = size; Material = material; Color = color; Object = @object; Season = season; Manufactured = manufactured; Quantity = quantity; PriceEntry = priceEntry; PriceSell = priceSell; }
private void btnSuaKichCo_Click(object sender, EventArgs e) { Model_Size ob = new Model_Size(); ob.ID = int.Parse(txtMaKichCo.Text); ob.Size = txtTenKichCo.Text; try { GlobalConfig.Connection.UpdateSize(ob); } catch { } WireData(); }
private void btnXoaKichCo_Click(object sender, EventArgs e) { if (txtMaKichCo.Text != "") { try { Model_Size ob = new Model_Size(); ob.ID = int.Parse(txtMaKichCo.Text); ob.Size = txtTenKichCo.Text; GlobalConfig.Connection.DeleteSize(ob); WireData(); } catch (Exception t) { MessageBox.Show($"Co loi xay ra{t.ToString()}"); } } else { MessageBox.Show("Hay chon Size can xoa"); } }
private void buttonOK_Click(object sender, EventArgs e) { if (textbox_Input.Text != "") { //Category if (Type == 1) { Model_Category model = new Model_Category(); model.Name = textbox_Input.Text; try { GlobalConfig.Connection.CreateNew_Category(model); } catch { MessageBox.Show("Lỗi Câu lệnh SQL Thêm loại Sản Phẩm :( We are sorry about this", "Thông Báo", MessageBoxButtons.OK); return; } } //Color else if (Type == 2) { Model_Color model = new Model_Color(); model.Name = textbox_Input.Text; try { GlobalConfig.Connection.CreateNew_Color(model); } catch { MessageBox.Show("Lỗi Câu lệnh SQL Thêm Màu Sắc :( We are sorry about this", "Thông Báo", MessageBoxButtons.OK); return; } } //Manufactured else if (Type == 3) { Model_Manufactured model = new Model_Manufactured(); model.Name = textbox_Input.Text; try { GlobalConfig.Connection.CreateNew_Manufactured(model); } catch { MessageBox.Show("Lỗi Câu lệnh SQL Thêm Nhà Sản Xuất :( We are sorry about this", "Thông Báo", MessageBoxButtons.OK); return; } } //Material else if (Type == 4) { Model_RawMaterial model = new Model_RawMaterial(); model.Name = textbox_Input.Text; try { GlobalConfig.Connection.CreateNew_RawMaterial(model); } catch { MessageBox.Show("Lỗi Câu lệnh SQL Thêm Nguyên Liệu :( We are sorry about this", "Thông Báo", MessageBoxButtons.OK); return; } } //Object else if (Type == 5) { Model_Object model = new Model_Object(); model.Name = textbox_Input.Text; try { GlobalConfig.Connection.CreateNew_Object(model); } catch { MessageBox.Show("Lỗi Câu lệnh SQL Thêm Đối Tượng :( We are sorry about this", "Thông Báo", MessageBoxButtons.OK); return; } } //Season else if (Type == 6) { Model_Season model = new Model_Season(); model.Name = textbox_Input.Text; try { GlobalConfig.Connection.CreateNew_Season(model); } catch { MessageBox.Show("Lỗi Câu lệnh SQL Thêm Mùa :( We are sorry about this", "Thông Báo", MessageBoxButtons.OK); return; } } //Size else if (Type == 7) { Model_Size model = new Model_Size(); model.Size = textbox_Input.Text; try { GlobalConfig.Connection.CreateNew_Size(model); } catch { MessageBox.Show("Lỗi Câu lệnh SQL Thêm Kích cỡ :( We are sorry about this", "Thông Báo", MessageBoxButtons.OK); return; } } //Role else if (Type == 8) { Model_Role model = new Model_Role(); model.Name = textbox_Input.Text; try { GlobalConfig.Connection.CreateNew_Role(model); } catch { MessageBox.Show("Lỗi Câu lệnh SQL Thêm Chức Vụ :( We are sorry about this", "Thông Báo", MessageBoxButtons.OK); return; } } MessageBox.Show("Nhập Thông tin Thành Công ", "Thông Báo", MessageBoxButtons.OK); this.Dispose(); } else { MessageBox.Show("Xin hãy kiểm tra lại thông tin ", "Thông Báo", MessageBoxButtons.OK); } }
private void dataGridViewhanghoa_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.Rows.Count == 0) { return; } //het hang if (int.Parse(dataGridViewhanghoa.CurrentRow.Cells[9].Value.ToString()) == 0) { MessageBox.Show("Sản phẩm đã hết", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //sp đã đc chọn if (checkma(dataGridViewhanghoa.CurrentRow.Cells[0].Value.ToString()) == false) { MessageBox.Show("Sản phẩm đã được chọn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { idhang.Add(dataGridViewhanghoa.CurrentRow.Cells[0].Value.ToString()); Model_Product product = new Model_Product(); DataGridViewRow currentRow = new DataGridViewRow(); currentRow = dataGridViewhanghoa.CurrentRow; product.ID = currentRow.Cells[0].Value.ToString(); product.Name = currentRow.Cells[1].Value.ToString(); Model_Color cloColor = new Model_Color(); cloColor.Name = currentRow.Cells[5].Value.ToString(); product.Color = cloColor; Model_Size modelSize = new Model_Size(); modelSize.Size = currentRow.Cells[3].Value.ToString(); product.Size = modelSize; product.PriceSell = decimal.Parse(currentRow.Cells[10].Value.ToString()); DataGridViewRow addRow = (DataGridViewRow)dataGridView1.Rows[0].Clone(); addRow.Cells[0].Value = product.ID; addRow.Cells[1].Value = product.Name; addRow.Cells[2].Value = product.Size.Size; addRow.Cells[3].Value = product.Color.Name; addRow.Cells[4].Value = 1; addRow.Cells[5].Value = product.PriceSell; addRow.Cells[6].Value = 0; addRow.Cells[7].Value = product.PriceSell; dataGridView1.Rows.Add(addRow); int dem = 0; float tongtien = 0; for (var VARIABLE = 0; VARIABLE <= dataGridView1.Rows.Count - 1; VARIABLE++) { if (dataGridView1.Rows[VARIABLE].Cells[4].Value != null) { dem += int.Parse(dataGridView1.Rows[VARIABLE].Cells[4].Value.ToString()); } if (dataGridView1.Rows[VARIABLE].Cells[7].Value != null) { tongtien += float.Parse(dataGridView1.Rows[VARIABLE].Cells[7].Value.ToString()); } } labeltongsoluong.Text = " " + (dem); labeltongtien.Text = " " + tongtien; labelkhachtra.Text = float.Parse(labeltongtien.Text) - float.Parse(labelgiamgia.Text) + ""; } }