public int InsertPDNNKChiTiet(eChiTietPhieuDeNghiNhapKho Chitiet) { var sp = from i in db.SanPhams where i.MaSP == Chitiet.MaSP select i; if (sp.Any()) { var c = from i in db.ChiTietPhieuDNNKs where i.MaSP == Chitiet.MaSP && i.MaPhieuDNNK == Chitiet.SoPDNNK select i; if (c.Any()) { throw new Exception("There have already"); } else { ChiTietPhieuDNNK newct = new ChiTietPhieuDNNK(); newct.MaPhieuDNNK = Chitiet.SoPDNNK; newct.MaSP = Chitiet.MaSP; newct.GhiChu = Chitiet.GhiChu; newct.SoLuong = Chitiet.SoLuong; db.ChiTietPhieuDNNKs.InsertOnSubmit(newct); db.SubmitChanges(); return(1); } } else { throw new Exception("Invaild SanPham ID"); } }
public List <eChiTietPhieuDeNghiNhapKho> GetALLCTPDNNKByMa(string SoPhieu) { var c = from i in db.ChiTietPhieuDNNKs join j in db.SanPhams on i.MaSP equals j.MaSP where i.MaPhieuDNNK == SoPhieu select i; List <eChiTietPhieuDeNghiNhapKho> ls = new List <eChiTietPhieuDeNghiNhapKho>(); foreach (ChiTietPhieuDNNK CT in c.ToList()) { eChiTietPhieuDeNghiNhapKho ct = new eChiTietPhieuDeNghiNhapKho(); ct.SoPDNNK = CT.MaPhieuDNNK; ct.MaSP = SetTensp(CT.MaSP); ct.SoLuong = Convert.ToInt32(CT.SoLuong); ct.GhiChu = ct.GhiChu; ls.Add(ct); } return(ls); }
private void themctpdnnk_Click(object sender, EventArgs e) { string s = @"^\d+$"; bool c = Regex.Match(slsp.Text, s).Success; try { if (cbsp1.SelectedValue == null || slsp.Text == null || trvpdnnk.SelectedNode.Tag.ToString() == null) { MessageBox.Show("Trừ Ghi Chú Ra Các Thông Tin Cần Nhập Cần Phải nhập"); } else if (!c) { MessageBox.Show("Sai định dạng số lượng"); slsp.Clear(); } else if (Convert.ToInt32(slsp.Text) <= 0 || Convert.ToInt32(slsp.Text) > Convert.ToInt32(slspdv.Text)) { MessageBox.Show("Error: Không Xác Định"); slsp.Clear(); } else { eChiTietPhieuDeNghiNhapKho ct = new eChiTietPhieuDeNghiNhapKho(); ct.MaSP = cbsp1.SelectedValue.ToString(); ct.SoPDNNK = trvpdnnk.SelectedNode.Text; ct.SoLuong = Convert.ToInt32(slsp.Text); ct.GhiChu = txtghichu.Text; dnnk.ThemCTPDNNK(ct); LoaddatagridviewPDNNK(); updatetextsoluongspdanhap(); updatesoluongsanphamcannhap(); updatetextsoluongspchuanhap(); } } catch (Exception ex) { MessageBox.Show("Error:" + ex.Message.ToString()); } }
public int ThemCTPDNNK(eChiTietPhieuDeNghiNhapKho Ct) { return(NK.InsertPDNNKChiTiet(Ct)); }