Example #1
0
        public ActionResult getData(String SUPPCD, String ORDERNO, String ORDERNOTO, String SEHMNO, String SEHMNOTO, String HMNM, String ORDERDTFR, String ORDERDTTO, String MAKERIPNM, String AGREEDFR, String AGREEDTO, String DELINM, String REQDELIDTFR, String REQDELIDTTO, String CHARGENM, String STATE1, String STATE2, String REPLYKBN1, String REPLYKBN2, String REPLYKBN3, String OrderSeachFlg, String ShmnoSeachFlg)
        {
            if (Session["LoginUserid"] == null)
            {
                ViewData["ID"] = "Login";
                return(RedirectToAction("Index", "Login"));
            }
            ViewData["LoginUsernm"] = Session["LoginUsernm"];

            ViewData["ID"]         = "納期回答画面";
            ViewData["pageMethod"] = "getData";

            var s0010 = db.S0010.SingleOrDefault();

            ViewBag.S0030List = null;

            if (s0010 != null)
            {
                var s0030 = db.S0030.Where(m => m.APPID == s0010.APPID && m.CALTYP == s0010.CALTYP && m.WKKBN == "2").Select(m => m.YMD).ToArray();
                if (s0030 != null)
                {
                    String[] S0030HolidayArr = new String[s0030.Length];
                    for (int i = 0; i < s0030.Length; i++)
                    {
                        S0030HolidayArr[i] = String.Format("{0:yyyy-MM-dd}", s0030[i]);
                    }
                    ViewBag.S0030List = S0030HolidayArr;
                }
            }

            var d3010 = db.D3010.Include(d => d.M0010).Include(d => d.M1050);

            //Comment this two line for testing purpose
            //d3010 = d3010.Where(m => m.PRTKBN1 == "2");
            //d3010 = d3010.Where(m => m.DECIKBN == "2");

            if (SUPPCD != null && SUPPCD != "")
            {
                d3010 = d3010.Where(m => m.SUPPCD == SUPPCD);
            }

            if (OrderSeachFlg == "1")
            {
                if (ORDERNO != null && ORDERNO != "")
                {
                    d3010 = d3010.Where(m => m.ORDERNO.Contains(ORDERNO));
                }
            }
            else
            {
                if (ORDERNO != null && ORDERNO != "")
                {
                    d3010 = d3010.Where(m => String.Compare(m.ORDERNO, ORDERNO) >= 0);
                }

                if (ORDERNOTO != null && ORDERNOTO != "")
                {
                    d3010 = d3010.Where(m => String.Compare(m.ORDERNO, ORDERNOTO) <= 0);
                }
            }

            if (ShmnoSeachFlg == "1")
            {
                if (SEHMNO != null && SEHMNO != "")
                {
                    d3010 = d3010.Where(m => m.M0010.SEHMNO.StartsWith(SEHMNO));
                }
            }
            else
            {
                if (SEHMNO != null && SEHMNO != "")
                {
                    d3010 = d3010.Where(m => String.Compare(m.M0010.SEHMNO, SEHMNO) >= 0);
                }

                if (SEHMNOTO != null && SEHMNOTO != "")
                {
                    d3010 = d3010.Where(m => String.Compare(m.M0010.SEHMNO, SEHMNOTO) <= 0);
                }
            }


            if (HMNM != null && HMNM != "")
            {
                d3010 = d3010.Where(m => m.M0010.HMNM.Contains(HMNM));
            }
            if (MAKERIPNM != null && MAKERIPNM != "")
            {
                d3010 = d3010.Where(m => m.M0010.MC0030.MAKERIPNM.Contains(MAKERIPNM));
            }
            if (DELINM != null && DELINM != "")
            {
                d3010 = d3010.Where(m => m.M1050.DELINM.Contains(DELINM));
            }
            if (CHARGENM != null && CHARGENM != "")
            {
                d3010 = d3010.Where(m => db.MC0060.Where(d => db.M5010.Where(t => t.CHARGENM.Contains(CHARGENM)).Select(f => f.CHARGECD).Contains(d.CHARGECD)).Select(f => f.JITANCD).Contains(m.JITANCD));
            }

            if (ORDERDTFR != null && ORDERDTFR != "")
            {
                var dt1 = DateTime.Parse(ORDERDTFR);
                d3010 = d3010.Where(m => dt1 <= m.ORDERDT);
            }
            if (ORDERDTTO != null && ORDERDTTO != "")
            {
                var dt2 = DateTime.Parse(ORDERDTTO);
                d3010 = d3010.Where(m => dt2 >= m.ORDERDT);
            }

            if (AGREEDFR != null && AGREEDFR != "")
            {
                var dt1 = DateTime.Parse(AGREEDFR);
                d3010 = d3010.Where(m => dt1 <= m.AGREED);
            }
            if (AGREEDTO != null && AGREEDTO != "")
            {
                var dt2 = DateTime.Parse(AGREEDTO);
                d3010 = d3010.Where(m => dt2 >= m.AGREED);
            }

            if (REQDELIDTFR != null && REQDELIDTFR != "")
            {
                var dt1 = DateTime.Parse(REQDELIDTFR);
                d3010 = d3010.Where(m => dt1 <= m.REQDELIDT);
            }
            if (REQDELIDTTO != null && REQDELIDTTO != "")
            {
                var dt2 = DateTime.Parse(REQDELIDTTO);
                d3010 = d3010.Where(m => dt2 >= m.REQDELIDT);
            }

            String STATE = "";

            if (STATE1 == "")
            {
                STATE1 = null;
            }
            if (STATE2 == "")
            {
                STATE2 = null;
            }

            if (STATE1 != null)
            {
                ViewData["STATE1"] = "checked";
                STATE = STATE1;
            }
            else
            {
                ViewData["STATE1"] = "";
            }
            if (STATE2 != null)
            {
                ViewData["STATE2"] = "checked";
                if (STATE != "")
                {
                    STATE = STATE + "," + STATE2;
                }
                else
                {
                    STATE = STATE2;
                }
            }
            else
            {
                ViewData["STATE2"] = "";
            }
            if (STATE != "")
            {
                String[] StateList = STATE.Split(',');
                d3010 = d3010.Where(m => StateList.Contains(m.STATE));
            }

            if (REPLYKBN1 == "")
            {
                REPLYKBN1 = null;
            }
            if (REPLYKBN2 == "")
            {
                REPLYKBN2 = null;
            }
            if (REPLYKBN3 == "")
            {
                REPLYKBN3 = null;
            }

            if (REPLYKBN1 != null && REPLYKBN2 == null && REPLYKBN3 == null)
            {
                d3010 = d3010.Where(m => !db.DC0060.Select(f => f.ORDERNO).Contains(m.ORDERNO));
            }
            else if (REPLYKBN2 != null && REPLYKBN1 == null && REPLYKBN3 == null)
            {
                d3010 = d3010.Where(m => db.DC0060.Select(f => f.ORDERNO).Contains(m.ORDERNO) && m.ORDERQTY > db.DC0060.Where(f => f.ORDERNO == m.ORDERNO).Select(f => f.DELISCHEQTY).Sum());
            }
            else if (REPLYKBN3 != null && REPLYKBN2 == null && REPLYKBN1 == null)
            {
                d3010 = d3010.Where(m => db.DC0060.Select(f => f.ORDERNO).Contains(m.ORDERNO) && m.ORDERQTY <= db.DC0060.Where(f => f.ORDERNO == m.ORDERNO).Select(f => f.DELISCHEQTY).Sum());
            }
            else if (REPLYKBN1 != null && REPLYKBN2 != null && REPLYKBN3 == null)
            {
                d3010 = d3010.Where(m => (!db.DC0060.Select(f => f.ORDERNO).Contains(m.ORDERNO)) || (db.DC0060.Select(f => f.ORDERNO).Contains(m.ORDERNO) && m.ORDERQTY > db.DC0060.Where(f => f.ORDERNO == m.ORDERNO).Select(f => f.DELISCHEQTY).Sum()));
            }
            else if (REPLYKBN2 != null && REPLYKBN1 == null && REPLYKBN3 != null)
            {
                d3010 = d3010.Where(m => db.DC0060.Select(f => f.ORDERNO).Contains(m.ORDERNO));
            }
            else if (REPLYKBN3 != null && REPLYKBN2 == null && REPLYKBN1 != null)
            {
                d3010 = d3010.Where(m => (db.DC0060.Select(f => f.ORDERNO).Contains(m.ORDERNO) && m.ORDERQTY <= db.DC0060.Where(f => f.ORDERNO == m.ORDERNO).Select(f => f.DELISCHEQTY).Sum()) || (!db.DC0060.Select(f => f.ORDERNO).Contains(m.ORDERNO)));
            }

            if (REPLYKBN1 != null)
            {
                ViewData["REPLYKBN1"] = "checked";
            }
            else
            {
                ViewData["REPLYKBN1"] = "";
            }
            if (REPLYKBN2 != null)
            {
                ViewData["REPLYKBN2"] = "checked";
            }
            else
            {
                ViewData["REPLYKBN2"] = "";
            }
            if (REPLYKBN3 != null)
            {
                ViewData["REPLYKBN3"] = "checked";
            }
            else
            {
                ViewData["REPLYKBN3"] = "";
            }

            ViewBag.M1010List         = db.M1010.ToList();
            ViewBag.M0010List         = db.M0010.ToList();
            ViewData["SUPPCD"]        = SUPPCD;
            ViewData["ORDERNO"]       = ORDERNO;
            ViewData["ORDERNOTO"]     = ORDERNOTO;
            ViewData["SEHMNO"]        = SEHMNO;
            ViewData["SEHMNOTO"]      = SEHMNOTO;
            ViewData["HMNM"]          = HMNM;
            ViewData["ORDERDTFR"]     = ORDERDTFR;
            ViewData["ORDERDTTO"]     = ORDERDTTO;
            ViewData["MAKERIPNM"]     = MAKERIPNM;
            ViewData["AGREEDFR"]      = AGREEDFR;
            ViewData["AGREEDTO"]      = AGREEDTO;
            ViewData["DELINM"]        = DELINM;
            ViewData["REQDELIDTFR"]   = REQDELIDTFR;
            ViewData["REQDELIDTTO"]   = REQDELIDTTO;
            ViewData["CHARGENM"]      = CHARGENM;
            ViewData["OrderSeachFlg"] = OrderSeachFlg;
            ViewData["ShmnoSeachFlg"] = ShmnoSeachFlg;


            ViewData["scrollTop"]     = Session["scrollTop"];
            ViewData["scrollGridVer"] = Session["scrollGridVer"];
            ViewData["scrollGridHor"] = Session["scrollGridHor"];

            Session["SUPPCD"]        = SUPPCD;
            Session["ORDERNO"]       = ORDERNO;
            Session["ORDERNOTO"]     = ORDERNOTO;
            Session["SEHMNO"]        = SEHMNO;
            Session["SEHMNOTO"]      = SEHMNOTO;
            Session["HMNM"]          = HMNM;
            Session["ORDERDTFR"]     = ORDERDTFR;
            Session["ORDERDTTO"]     = ORDERDTTO;
            Session["MAKERIPNM"]     = MAKERIPNM;
            Session["AGREEDFR"]      = AGREEDFR;
            Session["AGREEDTO"]      = AGREEDTO;
            Session["DELINM"]        = DELINM;
            Session["REQDELIDTFR"]   = REQDELIDTFR;
            Session["REQDELIDTTO"]   = REQDELIDTTO;
            Session["CHARGENM"]      = CHARGENM;
            Session["STATE1"]        = STATE1;
            Session["STATE2"]        = STATE2;
            Session["REPLYKBN1"]     = REPLYKBN1;
            Session["REPLYKBN2"]     = REPLYKBN2;
            Session["REPLYKBN3"]     = REPLYKBN3;
            Session["OrderSeachFlg"] = OrderSeachFlg;
            Session["ShmnoSeachFlg"] = ShmnoSeachFlg;

            var listd3010 = SetOrderData(d3010.ToList());

            return(View("Index", listd3010.OrderBy(m => m.ORDERNO)));
        }