コード例 #1
0
 public bool addDetail(ChiTietPhieuNhap chitiet)
 {
     if (isDetailExisted(chitiet))
     {
         return(false);
     }
     _chitiet.Add(chitiet);
     return(true);
 }
コード例 #2
0
 public bool isDetailExisted(ChiTietPhieuNhap chitiet)
 {
     return _chitiet.Contains(chitiet);
 }
コード例 #3
0
 public bool isDetailExisted(ChiTietPhieuNhap chitiet)
 {
     return(_chitiet.Contains(chitiet));
 }
コード例 #4
0
 public ViewResult BlankEditorRow(int masonxb, int masosach = 0)
 {
     var nxb = NhaXuatBanManager.find((int)masonxb);
     var chitiet = new ChiTietPhieuNhap();
     if(masosach != 0)
     {
         chitiet.MaSoSach = (int)masosach;
         if (_phieu.ChiTiet.Contains(chitiet))
         {
             return null;
         }
     }
     else
     {
         var founded = false;
         foreach (Sach s in nxb.Sach)
         {
             chitiet.MaSoSach = s.MaSoSach;
             chitiet.Sach = s;
             if (_phieu.ChiTiet.Contains(chitiet))
             {
                 continue;
             }
             founded = true;
             break;
         }
         if (!founded)
         {
             return null;
         }
     }
     ViewBag.currentNXB = nxb;
     ViewBag.cultureInfo = CultureInfo;
     ViewBag.DMSach = new SelectList(nxb.Sach,
                                 nameof(SachManager.Properties.MaSoSach),
                                 nameof(SachManager.Properties.TenSach), "");
     chitiet.SoLuong = 1;
     chitiet.DonGia = chitiet.Sach.GiaNhap;
     _phieu.addDetail(chitiet);
     return View("ChiTietEditorRow", chitiet);
 }
コード例 #5
0
 public bool addDetail(ChiTietPhieuNhap chitiet)
 {
     if (isDetailExisted(chitiet))
     {
         return false;
     }
     _chitiet.Add(chitiet);
     return true;
 }
コード例 #6
0
 public JsonResult isDetailExisted(string masosach)
 {
     var key = Int32.Parse(masosach);
     var chitiet = new ChiTietPhieuNhap();
     chitiet.MaSoSach = key;
     if (_phieu.isDetailExisted(chitiet))
     {
         return Json(true,JsonRequestBehavior.AllowGet);
     }
     else
     {
         return Json(false, JsonRequestBehavior.AllowGet);
     }
 }
コード例 #7
0
 public static bool edit(ChiTietPhieuNhap chitiet)
 {
     try
     {
         using (EntitiesDataContext db = new EntitiesDataContext())
         {
             CHITIETPHIEUNHAP ct;
             ct = (from c in db.CHITIETPHIEUNHAPs
                   where c.masophieunhap.Equals(chitiet.MaSoPhieuNhap)
                   && c.masosach.Equals(chitiet.MaSoSach)
                   select c).SingleOrDefault();
             if (ct == null) return false;
             ct.soluong = chitiet.SoLuong;
             ct.trangthai = chitiet.TrangThai;
             db.SubmitChanges();
             return true;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return false;
     }
 }
コード例 #8
0
 public static bool add(ChiTietPhieuNhap chitiet,int masophieunhap)
 {
     try
     {
         using (EntitiesDataContext db = new EntitiesDataContext())
         {
             CHITIETPHIEUNHAP ct;
             ct = (from c in db.CHITIETPHIEUNHAPs
                   where c.masophieunhap.Equals(masophieunhap)
                   && c.masosach.Equals(chitiet.MaSoSach)
                   select c).SingleOrDefault();
             if (ct != null) return false;
             ct = new CHITIETPHIEUNHAP()
                 {
                     masosach = chitiet.Sach.MaSoSach,
                     dongia = chitiet.DonGia,
                     soluong = chitiet.SoLuong,
                     masophieunhap = masophieunhap,
                     trangthai = chitiet.TrangThai == null ? 0 : 1
             };
             db.CHITIETPHIEUNHAPs.InsertOnSubmit(ct);
             db.SubmitChanges();
             return true;
         }
     }catch(Exception ex)
     {
         Console.WriteLine(ex.Message);
         return false;
     }
 }
コード例 #9
0
 public static bool add(ChiTietPhieuNhap chitiet)
 {
     return add(chitiet, chitiet.MaSoPhieuNhap);
 }
コード例 #10
0
        //Khi Nhấn Lưu lại phiếu nhập
        private void btnLuu_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Bạn có muốn lưu phiếu nhập này", "Thông báo", MessageBoxButtons.YesNo);
            if (dialogResult == DialogResult.Yes)
            {
                decimal tongtien = 0;
                List<ChiTietPhieuNhap> list = new List<ChiTietPhieuNhap>();
                if (!txbNguoiGiao.Text.Equals(""))
                {
                    PhieuNhap pn = new PhieuNhap();
                    pn.MaSoNXB = int.Parse(cmbNhaXuatBan.SelectedValue.ToString());
                    pn.NgayLap = DateTime.Parse(dtpNgayLap.Value.ToString("yyyy-MM-dd"));
                    pn.NguoiGiao = txbNguoiGiao.Text.ToString();

                    for (int i = 0; i < gdvChiTiet.RowCount - 1; i++)
                    {
                        if (!String.IsNullOrEmpty(Convert.ToString(gdvChiTiet.Rows[i].Cells[0].Value)) && !String.IsNullOrEmpty(Convert.ToString(gdvChiTiet.Rows[i].Cells[1].Value)) && !String.IsNullOrEmpty(Convert.ToString(gdvChiTiet.Rows[i].Cells[2].Value)))
                        {
                            ChiTietPhieuNhap ctpn = new ChiTietPhieuNhap();
                            ctpn.MaSoSach = int.Parse(gdvChiTiet.Rows[i].Cells[0].Value.ToString());
                            ctpn.SoLuong = int.Parse(gdvChiTiet.Rows[i].Cells[1].Value.ToString());
                            ctpn.DonGia = int.Parse(gdvChiTiet.Rows[i].Cells[2].Value.ToString());
                            tongtien = tongtien + ctpn.SoLuong * ctpn.DonGia;
                            if(list.Any(s=>s.MaSoSach == ctpn.MaSoSach))
                            {
                                MessageBox.Show("Không được nhập trùng chi tiết");
                                return;
                            }
                            list.Add(ctpn);

                        }
                        else
                        {
                            if (String.IsNullOrEmpty(Convert.ToString(gdvChiTiet.Rows[i].Cells[0].Value)) || String.IsNullOrEmpty(Convert.ToString(gdvChiTiet.Rows[i].Cells[1].Value)) || String.IsNullOrEmpty(Convert.ToString(gdvChiTiet.Rows[i].Cells[2].Value)))
                            {
                                MessageBox.Show("Chưa nhập đủ thông tin vào bảng");
                                return;
                            }
                        }

                    }

                    pn.ChiTiet = list;

                        pn.TongTien = tongtien;
                        int x = PhieuNhapManager.add(pn);
                        if (x != 0)
                        {
                            MessageBox.Show("đã thêm thành công");
                            txbMaPhieuNhap.Text = x + "";
                        }
                        else
                            MessageBox.Show("Không thêm được");

                }
                else
                    MessageBox.Show("Bạn chưa nhập người giao hàng");
            }
            else if (dialogResult == DialogResult.No)
            {
                return;
            }
        }