private void btnThem_Click(object sender, EventArgs e) { try { SIZEGIAY size = new SIZEGIAY(); size.MASP = comboBox1.SelectedValue.ToString(); size.SIZE = Convert.ToInt32(txt_size.Text.ToString()); size.SOLUONGSIZE = Convert.ToInt32(txt_slsize.Text.ToString()); if (sg.ktkc_sizegiay(size) == true) { if (sg.themsizegiay(size) == true) { MessageBox.Show("thêm thành công"); dataGridView1.DataSource = sg.loadsizeg(); } else { MessageBox.Show("thất bại"); } } else { MessageBox.Show("đã tồn tại"); } } catch { return; } }
private void btnThem_Click(object sender, EventArgs e) { SANPHAM sanp = new SANPHAM(); SIZEGIAY size = new SIZEGIAY(); KHO k = new KHO(); int b = 0; for (int i = 1; i <= dgv_sp.RowCount; i++) { b = i; } sanp.MASP = "SP" + (b + 1).ToString(); k.MASP = sanp.MASP; k.SOLUONG = 0; k.TRANGTHAI = cb_trangthaisp.Text.ToString(); size.MASP = sanp.MASP; size.SIZE = 0; size.SOLUONGSIZE = 0; sanp.TENSP = cb_tensp.Text.ToString(); sanp.MAU = txt_mau.Text.ToString(); sanp.CHATLIEU = txt_chatlieu.Text.ToString(); sanp.TINHTRANGSP = cb_trangthai.Text.ToString(); sanp.MALOAI = cb_loaigiay.SelectedValue.ToString(); sanp.MANCC = cb_ncc.SelectedValue.ToString(); if (sp.ktkc_sp(sanp) == true) { if (sp.themsp(sanp) == true) { MessageBox.Show("thêm thành công"); usercontrol_sanpham_Load(sender, e); if (sg.ktkc_sizegiay1(size) == true) { if (sg.themsizegiay(size) == true) { MessageBox.Show("thêm size giày thành công"); } } if (kh.ktkc_kho(k) == true) { if (kh.themkho(k) == true) { MessageBox.Show("thêm kho giày thành công"); } } usercontrol_sanpham_Load(sender, e); } else { MessageBox.Show("thất bại"); } } else { MessageBox.Show("sản phẩm này đã tồn tại"); } }
public bool them(SIZEGIAY pmh) { try { da.SIZEGIAYs.InsertOnSubmit(pmh); da.SubmitChanges(); return(true); } catch { return(false); } }
public bool xoa(SIZEGIAY pmh) { try { SIZEGIAY mh = da.SIZEGIAYs.Where(t => t.MASP == pmh.MASP.ToString() && t.SIZE == Convert.ToInt32(pmh.SIZE.ToString())).FirstOrDefault(); da.SIZEGIAYs.DeleteOnSubmit(mh); da.SubmitChanges(); return(true); } catch { return(false); } }
public bool sua(SIZEGIAY pmh) { try { SIZEGIAY thanhvien = da.SIZEGIAYs.Where(t => t.MASP == pmh.MASP.ToString() && t.SIZE == Convert.ToInt32(pmh.SIZE.ToString())).FirstOrDefault(); thanhvien.SOLUONGSIZE = pmh.SOLUONGSIZE; da.SubmitChanges(); return(true); } catch { return(false); } }
public bool ktkc1(SIZEGIAY pmh) { int r = da.SIZEGIAYs.Count(t => t.MASP == pmh.MASP.ToString()); try { if (r == 0) { return(true); } return(false); } catch { return(false); } }
public bool ktkc(SIZEGIAY pmh) { int r = da.SIZEGIAYs.Count(t => t.MASP == pmh.MASP.ToString() && t.SIZE == Convert.ToInt32(pmh.SIZE.ToString())); try { if (r == 0) { return(true); } return(false); } catch { return(false); } }
private void buttonX2_Click(object sender, EventArgs e) { SIZEGIAY size = new SIZEGIAY(); size.MASP = comboBox1.SelectedValue.ToString(); if (sg.ktkc_sizegiay(size) == false) { if (sg.xoasizegiay(size) == true) { MessageBox.Show("xóa thành công"); dataGridView1.DataSource = sg.loadsizeg(); } else { MessageBox.Show("thất bại"); } } else { MessageBox.Show("đã tồn tại"); } }
private void btnThemSize_Click(object sender, EventArgs e) { if (cboMaspsize.Text == "" || txtsosize.Text == "" || txtSLsizegiay.Text == "") { MessageBox.Show("Không được để trống"); return; } SIZEGIAY k = new SIZEGIAY(); var kt = from s in db.SIZEGIAYs where s.MASP == txtMaSP.Text && s.SOSIZE == Convert.ToInt16(txtsosize.Text) select s; if (kt.Count() > 0) { MessageBox.Show("Trùng khóa chính"); return; } k.MASP = cboMaspsize.Text; k.SOSIZE = Convert.ToInt16(txtsosize.Text); k.SOLUONGTON = Convert.ToInt16(txtSLsizegiay.Text); db.SIZEGIAYs.InsertOnSubmit(k); db.SubmitChanges(); frm_kho_Load(sender, e); MessageBox.Show("Thành công"); }
private void buttonX1_Click(object sender, EventArgs e) { SIZEGIAY size = new SIZEGIAY(); size.MASP = comboBox1.SelectedValue.ToString(); size.SIZE = Convert.ToInt32(comboBox2.Text.ToString()); size.SOLUONGSIZE = Convert.ToInt32(dataGridView1.CurrentRow.Cells[2].Value.ToString()) + Convert.ToInt32(txt_slsize.Text.ToString()); if (sg.ktkc_sizegiay(size) == false) { if (sg.suasizegiay(size) == true) { MessageBox.Show("Sửa thành công"); dataGridView1.DataSource = sg.loadsizeg(); } else { MessageBox.Show("thất bại"); } } else { MessageBox.Show("chưa tồn tại"); } }
public bool xoasizegiay(SIZEGIAY n) { return(dl.xoa(n)); }
public bool suasizegiay(SIZEGIAY n) { return(dl.sua(n)); }
public bool themsizegiay(SIZEGIAY n) { return(dl.them(n)); }
public bool ktkc_sizegiay1(SIZEGIAY n) { return(dl.ktkc1(n)); }