示例#1
0
 public ActionResult Create(HangHoa entity)
 {
     SetLoaiMH();
     SetMauSac();
     SetNuocSanXuat();
     SetDVT();
     if (ModelState.IsValid)
     {
         var    dao       = new HangHoaDao();
         var    cauhinhID = new CauHinhIDDao();
         var    chID      = cauhinhID.GetValueByID(entity.LoaiMH);
         string maHH      = CommonFunction.GenerateMaHang(entity.LoaiMH, chID.Value + 1);
         entity.MaHH        = maHH;
         entity.SoLuong     = 0;
         entity.Status      = true;
         entity.CreatedDate = DateTime.Now;
         if (entity.Anh == null)
         {
             entity.Anh = "/Data/images/no-image.jpg";
         }
         entity.CreateBy = Session["UserName"].ToString();
         dao.Insert(entity);
         cauhinhID.Update(entity.LoaiMH);//Tăng biến đếm
         SetAlert("Thêm hàng hóa thành công!", "success");
     }
     else
     {
         SetAlert("Lỗi thêm hàng hóa!", "error");
     }
     return(View());
 }
示例#2
0
        public ActionResult NhapTuNCC()
        {
            var         daoID       = new CauHinhIDDao();
            var         id          = daoID.GetValueByID("NH");
            string      ma_chung_tu = CommonFunction.GeneratedID("NH", id.Value + 1);
            NhapKhoView model       = new NhapKhoView()
            {
                chung_tu_nhap = new NhapHang()
                {
                    IDNhap = ma_chung_tu, CreatedDate = DateTime.Now, LoaiGiaoDichID = 3
                }
            };

            return(View(model));
        }
示例#3
0
        // GET: Admin/XuatHang
        public ActionResult Index()
        {
            var         daoID       = new CauHinhIDDao();
            var         id          = daoID.GetValueByID("BH");
            string      ma_chung_tu = CommonFunction.GeneratedID("BH", id.Value + 1);
            XuatKhoView model       = new XuatKhoView()
            {
                chung_tu_xuat = new XuatHang()
                {
                    IDXuat = ma_chung_tu, CreatedDate = DateTime.Now, LoaiGiaoDichID = 1
                }
            };

            return(View(model));
        }
示例#4
0
        public JsonResult CreatePNK(string ma, string ngay_nhap, string ma_ncc, string nguoi_lap_phieu, string nguoi_giao, string dien_giai, string tong_tien)
        {
            bool     success = true;
            string   message = "Kết quả: Tạo phiếu nhập kho thành công!";
            var      dao     = new NhapHangDao();
            var      daoID   = new CauHinhIDDao();
            NhapHang obj     = new NhapHang();

            obj.IDNhap         = ma;
            obj.NgayNhap       = DateTime.ParseExact(ngay_nhap, "dd/MM/yyyy", null);
            obj.DoiTac         = int.Parse(ma_ncc);
            obj.NguoiLapPhieu  = nguoi_lap_phieu;
            obj.NguoiGiaoHang  = nguoi_giao;
            obj.DienGiai       = dien_giai;
            obj.LoaiGiaoDichID = 3;
            obj.TongTien       = decimal.Parse(tong_tien);
            obj.CreatedDate    = DateTime.Now;
            obj.CreateBy       = Session["UserName"].ToString();
            obj.TrangThai      = 1;

            try
            {
                dao.Insert(obj);
                daoID.Update("NH");
            }
            catch (Exception ex)
            {
                success = false;
                message = "Kết quả: " + ex.ToString() + ".";
            }

            return(Json(new
            {
                success = success,
                message = message
            }));
        }
示例#5
0
        public JsonResult CreatePXK(string khach_hang, string sdt, string dia_chi, string ngay_xuat, string ma,
                                    string thu_kho, string nguoi_lap_phieu, string dien_giai, string tong_tien)
        {
            bool   success = true;
            string message = "Kết quả: Tạo phiếu xuất kho thành công!";
            //Thêm khách hàng
            var       daoKH  = new KhachHangDao();
            KhachHang obj_kh = new KhachHang();

            obj_kh.TenKH       = khach_hang;
            obj_kh.SDT         = sdt;
            obj_kh.DiaChi      = dia_chi;
            obj_kh.CreatedDate = DateTime.Now;
            obj_kh.Status      = true;
            obj_kh.CreateBy    = Session["UserName"].ToString();
            int ma_kh = -1;

            try
            {
                ma_kh = daoKH.Insert(obj_kh);
            }
            catch (Exception ex)
            {
                success = false;
                message = "Kết quả: " + ex.ToString() + ".";
            }
            if (ma_kh != -1)
            {
                //Thêm phiếu xuất hàng
                var      dao   = new XuatHangDao();
                var      daoID = new CauHinhIDDao();
                XuatHang obj   = new XuatHang();
                obj.IDXuat         = ma;
                obj.KhachHang      = ma_kh;
                obj.NgayXuat       = DateTime.ParseExact(ngay_xuat, "dd/MM/yyyy", null);
                obj.ThuKho         = thu_kho;
                obj.NguoiLapPhieu  = nguoi_lap_phieu;
                obj.DienGiai       = dien_giai;
                obj.LoaiGiaoDichID = 1;
                obj.TongTien       = decimal.Parse(tong_tien);
                obj.CreatedDate    = DateTime.Now;
                obj.CreateBy       = Session["UserName"].ToString();
                obj.TrangThai      = 1;

                try
                {
                    dao.Insert(obj);
                    daoID.Update("BH");
                }
                catch (Exception ex)
                {
                    success = false;
                    message = "Kết quả: " + ex.ToString() + ".";
                }
            }
            return(Json(new
            {
                success = success,
                message = message
            }));
        }