コード例 #1
0
        public JsonResult deleteOrder(string strOrderID)
        {
            List <FPT_CIR_HOLDING_GET_ALL_Result> list = le.FPT_CIR_HOLDING_GET_ALL().ToList();

            strOrderID = strOrderID.Trim();
            strOrderID = strOrderID.Substring(0, strOrderID.LastIndexOf(','));
            string[] orderArr = strOrderID.Split(',');
            foreach (string item in orderArr)
            {
                le.ExcuteSQL("update CIR_HOLDING set CheckMail=1, InTurn=0 where id =" + item);
            }

            return(Json("", JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public PartialViewResult CheckOut(
            string strPatronCode,
            string strDueDate,
            int intLoanMode,
            int intHoldIgnore,
            string strCopyNumbers,
            string strCheckOutDate,
            bool boolAllowDuplacate
            )
        {
            string      PatronCode = strPatronCode.Trim();
            bool        duplicate  = false;
            int         PatronID   = db.CIR_PATRON.Where(a => a.Code == PatronCode).First().ID;
            var         cIR_LOANs  = db.CIR_LOAN.Where(a => a.PatronID == PatronID).ToList();
            string      CopyNumber = strCopyNumbers.Trim();
            List <int?> ItemIds    = new List <int?>();

            Getpatrondetail(PatronCode);
            int     onloan   = db.SP_GET_PATRON_ONLOAN_COPIES(PatronID).ToList <SP_GET_PATRON_ONLOAN_COPIES_Result>().Count();
            HOLDING itemHold = new HOLDING();

            if (db.HOLDINGs.Where(a => a.CopyNumber == CopyNumber).Count() != 0)
            {
                itemHold = (HOLDING)db.HOLDINGs.Where(a => a.CopyNumber == CopyNumber).First();
            }
            //int b = db.HOLDINGs.Where(a => (a.ItemID == itemHold.ItemID) && (a.InUsed == false)).Count();
            //int c = db.CIR_HOLDING.Where(a => (a.ItemID == itemHold.ItemID) && (((a.CheckMail == true) && (a.InTurn == true)) || ((a.CheckMail == false) && (a.InTurn == true)))).Count();
            //kiểm tra cùng 1 người thực hiện ghi mượn
            if (patroncode != PatronCode)
            {
                strTransactionIDs = "0";
            }
            if (db.HOLDINGs.Where(a => a.CopyNumber == CopyNumber).Count() == 0)
            {
                ViewBag.message = "ĐKCB không đúng";
                ViewBag.HiddenCheckduplicate = "";
            }
            else if (db.CIR_LOAN.Where(a => a.CopyNumber == CopyNumber).Count() != 0)
            {
                ViewBag.message = "ĐKCB đang được ghi mượn";
                ViewBag.HiddenCheckduplicate = "";
            }
            else if (db.CIR_HOLDING.Where(a => (a.PatronCode == PatronCode) && (a.ItemID == itemHold.ItemID)).Count() != 0)
            {
                if (!Checkonloanquota(PatronID, intLoanMode))
                {
                    ViewBag.message = "Hết hạn ngạch tối đa có thể mượn";
                    ViewBag.HiddenCheckduplicate = "";
                }
                else
                {
                    int ItemID = db.HOLDINGs.Where(a => a.CopyNumber == CopyNumber).First().ItemID;
                    foreach (CIR_LOAN loan in cIR_LOANs)
                    {
                        ItemIds.Add(loan.ItemID);
                    }
                    foreach (int?id in ItemIds)
                    {
                        if (ItemID == id)
                        {
                            duplicate = true;
                        }
                    }
                    if (duplicate == true && boolAllowDuplacate == false)
                    {
                        ViewBag.HiddenCheckduplicate = "duplicate";
                    }
                    else
                    {
                        int success = db.SP_CHECKOUT(PatronCode, (int)Session["UserID"], intLoanMode, CopyNumber, strDueDate, strCheckOutDate, intHoldIgnore,
                                                     new ObjectParameter("intOutValue", typeof(int)),
                                                     new ObjectParameter("intOutID", typeof(int)));
                        string lastid = db.CIR_LOAN.Max(a => a.ID).ToString();

                        if (success == -1)
                        {
                            ViewBag.message = "Ghi mượn thất bại";
                        }
                        else
                        {
                            if (patroncode == PatronCode)
                            {
                                strTransactionIDs = strTransactionIDs + "," + lastid;
                            }
                            else
                            {
                                strTransactionIDs = lastid;
                            }
                            db.ExcuteSQL("update CIR_HOLDING set CheckMail=1, InTurn=0 where PatronCode='" + patroncode + "' and ItemID= " + itemHold.ItemID);
                        }
                        ViewBag.HiddenCheckduplicate = "";
                    }
                }
            }

            else if ((db.HOLDINGs.Where(a => (a.ItemID == itemHold.ItemID) && (a.InUsed == false) && ((a.LibID == 81) || (a.LocationID == 13) || (a.LocationID == 15) || (a.LocationID == 16) || (a.LocationID == 27))).Count() <= db.CIR_HOLDING.Where(a => (a.ItemID == itemHold.ItemID) && (((a.CheckMail == true) && (a.InTurn == true)) || ((a.CheckMail == false) && (a.InTurn == true)))).Count()))
            {
                ViewBag.message = "Cuốn này đang được đặt mượn";
                ViewBag.HiddenCheckduplicate = "";
            }


            else
            {
                if (!Checkonloanquota(PatronID, intLoanMode))
                {
                    ViewBag.message = "Hết hạn ngạch tối đa có thể mượn";
                    ViewBag.HiddenCheckduplicate = "";
                }
                else
                {
                    int ItemID = db.HOLDINGs.Where(a => a.CopyNumber == CopyNumber).First().ItemID;
                    foreach (CIR_LOAN loan in cIR_LOANs)
                    {
                        ItemIds.Add(loan.ItemID);
                    }
                    foreach (int?id in ItemIds)
                    {
                        if (ItemID == id)
                        {
                            duplicate = true;
                        }
                    }
                    if (duplicate == true && boolAllowDuplacate == false)
                    {
                        ViewBag.HiddenCheckduplicate = "duplicate";
                    }
                    else
                    {
                        int success = db.SP_CHECKOUT(PatronCode, (int)Session["UserID"], intLoanMode, CopyNumber, strDueDate, strCheckOutDate, intHoldIgnore,
                                                     new ObjectParameter("intOutValue", typeof(int)),
                                                     new ObjectParameter("intOutID", typeof(int)));
                        string lastid = db.CIR_LOAN.Max(a => a.ID).ToString();

                        if (success == -1)
                        {
                            ViewBag.message = "Ghi mượn thất bại";
                        }
                        else
                        {
                            if (patroncode == PatronCode)
                            {
                                strTransactionIDs = strTransactionIDs + "," + lastid;
                            }
                            else
                            {
                                strTransactionIDs = lastid;
                            }
                        }
                        ViewBag.HiddenCheckduplicate = "";
                    }
                }
            }
            ViewBag.HiddenDuplicateCopyNumber = CopyNumber;
            Getcurrentloandetail();
            patroncode = PatronCode;
            return(PartialView("_checkoutSuccess"));
        }