Пример #1
0
        public ActionResult Add(string id, string idkehoach)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            //year = year == null ? DateTime.Now.Year : year < DateTime.Now.Year ? DateTime.Now.Year : year;

            BaoKyXuatBanModel baoKyXuatBanModel = db.getBaoKyXuatBanModel(id);

            //BKeHoachXuatBan _xuatban = db.getBKeHoachXuatBan(id, Convert.ToInt32(year));

            KeHoachXuatBanModel _kehoach = new KeHoachXuatBanModel();
            _kehoach.Id = baoKyXuatBanModel.Id;
            _kehoach.KyConfig = baoKyXuatBanModel.KyConfig;
            _kehoach.LoaiKy = baoKyXuatBanModel.LoaiKy;
            _kehoach.MaBao = baoKyXuatBanModel.MaBao;
            _kehoach.TenBao = baoKyXuatBanModel.TenBao;
            if (idkehoach == null)
            {
                _kehoach.Nam = db.getBKeHoachXuatBanYearLast(id);
                _kehoach.SoBatDau = -1;
                _kehoach.IdKeHoachXuatBan = "-1";
                _kehoach.detailKHXB = new List<BKeHoachXuatBanDetail>();
            }
            else
            {
                BKeHoachXuatBan _xuatban = db.getBKeHoachXuatBan(idkehoach);
                if (_xuatban == null)
                    return RedirectToAction("add/" + id);
                _kehoach.IdKeHoachXuatBan = idkehoach;
                _kehoach.Nam = _xuatban.Nam;
                _kehoach.SoBatDau = 1;
            }
            _kehoach.khxb = db.getKHXBByID(id);
            if (_kehoach == null)
            {
                return HttpNotFound();
            }
            if (HttpContext.Request.IsAjaxRequest())
                return PartialView("_Add", _kehoach);
            return View(_kehoach);
        }
Пример #2
0
        public ActionResult ChiTiet(string id, string idkehoach)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            BKeHoachXuatBan _xuatban = db.getBKeHoachXuatBan(idkehoach);
            if (_xuatban == null)
                return RedirectToAction("add/" + id);
            BaoKyXuatBanModel baoKyXuatBanModel = db.getBaoKyXuatBanModel(id);
            KeHoachXuatBanModel _kehoach = new KeHoachXuatBanModel();
            _kehoach.Id = baoKyXuatBanModel.Id;
            _kehoach.KyConfig = baoKyXuatBanModel.KyConfig;
            _kehoach.LoaiKy = baoKyXuatBanModel.LoaiKy;
            _kehoach.MaBao = baoKyXuatBanModel.MaBao;
            _kehoach.TenBao = baoKyXuatBanModel.TenBao;
            _kehoach.IdKeHoachXuatBan = idkehoach;
            _kehoach.Nam = _xuatban.Nam;
            _kehoach.SoBatDau = _xuatban.SoBatDau;
            _kehoach.detailKHXB = db.getBKeHoachXuatBanDetail(id, Convert.ToInt32(_xuatban.Nam));

            _kehoach.data.Add("BDieuChinhKHXB", JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(JsonConvert.SerializeObject((from p in db.getBDieuChinhKHXB(id, Convert.ToInt32(_xuatban.Nam)) select new { p.Id, p.ThongTinBaoId, p.ModifyDate, p.Quy, ModifyBy = (from u in db.getDBSelect().UserInfoes where u.Id.Equals(p.ModifyBy) select u.DislayName).FirstOrDefault() }))));

            if (_kehoach == null)
            {
                return HttpNotFound();
            }
            return View(_kehoach);
        }
Пример #3
0
        public ActionResult DieuChinhKeHoachXuatBan(string id, string idkehoach)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            BKeHoachXuatBan _xuatban = db.getBKeHoachXuatBan(idkehoach);
            if (_xuatban == null)
            {
                return RedirectToAction("add/" + id);
            }
            BaoKyXuatBanModel baoKyXuatBanModel = db.getBaoKyXuatBanModel(id);
            KeHoachXuatBanModel _kehoach = new KeHoachXuatBanModel();
            _kehoach.Id = baoKyXuatBanModel.Id;
            _kehoach.KyConfig = baoKyXuatBanModel.KyConfig;
            _kehoach.LoaiKy = baoKyXuatBanModel.LoaiKy;
            _kehoach.MaBao = baoKyXuatBanModel.MaBao;
            _kehoach.TenBao = baoKyXuatBanModel.TenBao;
            _kehoach.IdKeHoachXuatBan = idkehoach;
            _kehoach.Nam = _xuatban.Nam;
            _kehoach.SoBatDau = _xuatban.SoBatDau;
            if (_xuatban.Nam < DateTime.Now.Year)
                return Redirect(Request.UrlReferrer.ToString());
            //return RedirectToAction("Index");
            int[] quyCSDL = db.getBDieuChinhKHXB(id, Convert.ToInt32(_xuatban.Nam)).Select(d => d.Quy).ToArray();
            int month = DateTime.Now.Year == _xuatban.Nam ? DateTime.Now.Month : 1;
            int quyNow = month >= 1 && month <= 3 ? 1 : month > 3 && month <= 6 ? 2 : month > 6 && month <= 9 ? 3 : 4;
            quyNow = quyCSDL.Length > 0 && quyCSDL[0] >= quyNow ? quyCSDL[0] : quyNow - 1;
            List<int> arQuy = new List<int>();
            if (quyNow + 1 <= 4)
                arQuy.Add(quyNow + 1);
            //for (int i = quyNow + 1; i <= 4; i++)
            //{
            //    arQuy.Add(i);
            //}
            if (arQuy.Count <= 0)
                return Redirect(Request.UrlReferrer.ToString());
            //return RedirectToAction("Index");
            _kehoach.data.Add("arrayquy", arQuy);

            if (_kehoach == null)
            {
                return HttpNotFound();
            }
            return View(_kehoach);
        }
Пример #4
0
        public ActionResult View(string id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            BDieuChinhKHXBDetail _dieuchinhDetail = db.getDBSelect().BDieuChinhKHXBDetails.Where(d => d.Id.Equals(id)).FirstOrDefault();
            if (_dieuchinhDetail == null)
            {
                return HttpNotFound();
                //return Redirect(Request.UrlReferrer.ToString());
            }

            int typeDieuCHinh = _dieuchinhDetail.LoaiDieuChinh;
            BDieuChinhKHXB _dieuChinh = db.getDBSelect().BDieuChinhKHXBs.Where(d => d.Id.Equals(_dieuchinhDetail.DieuChinhKHXBId)).FirstOrDefault();
            BaoKyXuatBanModel baoKyXuatBanModel = db.getBaoKyXuatBanModel(_dieuChinh.ThongTinBaoId);
            KeHoachXuatBanModel _kehoach = new KeHoachXuatBanModel();
            _kehoach.Id = baoKyXuatBanModel.Id;
            _kehoach.KyConfig = _dieuChinh.ChiTietKy;
            _kehoach.LoaiKy = Convert.ToInt32(_dieuChinh.LoaiKy);
            _kehoach.MaBao = baoKyXuatBanModel.MaBao;
            _kehoach.TenBao = baoKyXuatBanModel.TenBao;
            _kehoach.IdKeHoachXuatBan = id;
            _kehoach.Nam = _dieuChinh.Nam;
            _kehoach.Quy = _dieuChinh.Quy;
            _kehoach.data.Add("IdDieuChinh", id);
            _kehoach.data.Add("TypeText", Enums.KieuDieuChinhKHXB((Enums.KeHoachXuatBan)typeDieuCHinh));
            _kehoach.data.Add("Type", typeDieuCHinh);
            dynamic dataConfig = JsonConvert.DeserializeObject<ExpandoObject>(_dieuchinhDetail.Config);
            _kehoach.data.Add("DataConfig", dataConfig);
            _kehoach.data.Add("SoBao", _dieuchinhDetail.SoBao);
            _kehoach.data.Add("DataNumber", db.getDBSelect().BKeHoachXuatBanDetails.Where(d => d.ThongTinBaoId.Equals(_dieuChinh.ThongTinBaoId) && d.Nam == _dieuChinh.Nam && d.Quy == d.Quy && (_dieuchinhDetail.SoBao.IndexOf("\"" + d.SoBao + "\"") > -1 || (d.Number == -1 && d.status == (int)Enums.KeHoachXuatBan.group))).ToList<BKeHoachXuatBanDetail>());
            ViewBag.ThongTinBaoId = _dieuChinh.Id;

            if (_kehoach == null)
            {
                return HttpNotFound();
            }
            return View(_kehoach);
        }
Пример #5
0
        // GET: Bao/DieuChinhKHXB
        public ActionResult Index(string id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            BDieuChinhKHXB _dieuChinh = db.getDBSelect().BDieuChinhKHXBs.Where(d=>d.Id.Equals(id)).FirstOrDefault();
            if (_dieuChinh == null)
            {
                return HttpNotFound();
                //return Redirect(Request.UrlReferrer.ToString());
            }
            //return RedirectToAction("bao/kehoachxuatban");
            int sDonSo = (int)Enums.KeHoachXuatBan.group;

            BaoKyXuatBanModel baoKyXuatBanModel = db.getBaoKyXuatBanModel(_dieuChinh.ThongTinBaoId);
            KeHoachXuatBanModel _kehoach = new KeHoachXuatBanModel();
            _kehoach.Id = baoKyXuatBanModel.Id;
            _kehoach.KyConfig = _dieuChinh.ChiTietKy;
            _kehoach.LoaiKy = Convert.ToInt32(_dieuChinh.LoaiKy);
            _kehoach.ThongTinBaoId = _dieuChinh.ThongTinBaoId;
            _kehoach.MaBao = baoKyXuatBanModel.MaBao;
            _kehoach.TenBao = baoKyXuatBanModel.TenBao;
            _kehoach.IdKeHoachXuatBan = id;
            _kehoach.Nam = _dieuChinh.Nam;
            _kehoach.Quy = _dieuChinh.Quy;
            _kehoach.detailKHXB = db.getDBSelect().BKeHoachXuatBanDetails.Where(d => d.ThongTinBaoId.Equals(_dieuChinh.ThongTinBaoId) && d.Nam == _dieuChinh.Nam && d.Quy == _dieuChinh.Quy && (d.status != sDonSo || d.Number < 0)).OrderBy(d => d.Thang).OrderBy(d => d.Ngay).ToList();
            _kehoach.dieuchinhdetailKHXB = db.getBKeHoachXuatBanDetailModel(_dieuChinh.Id).ToList();
            ViewBag.KyXuatBan = JsonConvert.DeserializeObject<ExpandoObject>(_dieuChinh.ChiTietKy);
            if (_kehoach == null)
            {
                return HttpNotFound();
            }

            return View(_kehoach);
        }
Пример #6
0
        // GET: Bao/DieuChinhKHXB/Create
        public ActionResult Create(string type, string id)
        {
            if (type == null || id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            BDieuChinhKHXB _dieuChinh = db.getDBSelect().BDieuChinhKHXBs.Where(d => d.Id.Equals(id)).FirstOrDefault();
            if (_dieuChinh == null)
            {
                return HttpNotFound();
                //return Redirect(Request.UrlReferrer.ToString());
            }

            BaoKyXuatBanModel baoKyXuatBanModel = db.getBaoKyXuatBanModel(_dieuChinh.ThongTinBaoId);
            KeHoachXuatBanModel _kehoach = new KeHoachXuatBanModel();
            _kehoach.Id = baoKyXuatBanModel.Id;
            _kehoach.KyConfig = _dieuChinh.ChiTietKy;
            _kehoach.LoaiKy = Convert.ToInt32(_dieuChinh.LoaiKy);
            _kehoach.MaBao = baoKyXuatBanModel.MaBao;
            _kehoach.TenBao = baoKyXuatBanModel.TenBao;
            _kehoach.IdKeHoachXuatBan = id;
            _kehoach.Nam = _dieuChinh.Nam;
            _kehoach.Quy = _dieuChinh.Quy;
            _kehoach.data.Add("TypeText", Enums.KieuDieuChinhKHXB(Enums.getKeHoachXuatBan(type)));
            int typeDieuCHinh = ((int)Enums.getKeHoachXuatBan(type));
            _kehoach.data.Add("Type", typeDieuCHinh);
            if (_kehoach.LoaiKy >= 0 && _kehoach.LoaiKy <= 3)
            {
                List<string> listConfig = JsonConvert.DeserializeObject<List<string>>((JsonConvert.DeserializeObject<dynamic>(_kehoach.KyConfig)).data.ToString());
                if (_kehoach.LoaiKy == 0)
                    listConfig = (new string[] { "2", "3", "4", "5", "6", "7", "8" }).ToList();
                List<string> ngayThuLoai = new List<string>();

                foreach (string _item in db.getDBSelect().BDieuChinhKHXBDetails.Where(d => d.DieuChinhKHXBId.Equals(id) && d.LoaiDieuChinh == (int)Enums.KeHoachXuatBan.cancel && d.NgayOrThu != null).Select(d => d.NgayOrThu))
                {
                    int[] itemArr = JsonConvert.DeserializeObject<int[]>(_item);
                    foreach (string itemC in listConfig)
                    {
                        if (itemArr.Contains(Convert.ToInt32(itemC)) && !ngayThuLoai.Contains(itemC))
                            ngayThuLoai.Add(itemC);
                    }

                }
                if (typeDieuCHinh != (int)Enums.KeHoachXuatBan.cancel)
                {
                    foreach (string _item in db.getDBSelect().BDieuChinhKHXBDetails.Where(d => d.DieuChinhKHXBId.Equals(id) && d.LoaiDieuChinh == typeDieuCHinh && d.NgayOrThu != null).Select(d => d.NgayOrThu))
                    {
                        int[] itemArr = JsonConvert.DeserializeObject<int[]>(_item);
                        foreach (string itemC in listConfig)
                        {
                            if (itemArr.Contains(Convert.ToInt32(itemC)) && !ngayThuLoai.Contains(itemC))
                                ngayThuLoai.Add(itemC);
                        }

                    }
                }
                else
                {
                    foreach (string _item in db.getDBSelect().BDieuChinhKHXBDetails.Where(d => d.DieuChinhKHXBId.Equals(id) && d.LoaiDieuChinh == (int)Enums.KeHoachXuatBan.group && d.NgayOrThu != null).Select(d => d.NgayOrThu))
                    {
                        int[] itemArr = JsonConvert.DeserializeObject<int[]>(_item);
                        foreach (string itemC in listConfig)
                        {
                            if (itemArr.Contains(Convert.ToInt32(itemC)) && !ngayThuLoai.Contains(itemC))
                                ngayThuLoai.Add(itemC);
                        }

                    }
                }
                foreach (var item in ngayThuLoai)
                {
                    listConfig.Remove(item);
                }
                _kehoach.data.Add("KyConfig", listConfig.ToArray());
            }
            if (_kehoach == null)
            {
                return HttpNotFound();
            }
            return View(_kehoach);
        }