Пример #1
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public OU() : base()
        {
            base.Init(this.GetType().FullName, System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
            baseDal.OnOperationLog += new OperationLogEventHandler(WHC.Security.BLL.OperationLog.OnOperationLog);//如果需要记录操作日志,则实现这个事件

            this.ouDal = baseDal as IOU;
        }
Пример #2
0
        public ActionResult Create([Bind(Include = "lenderName ,amount ,statusId ,plannedReturnDt")] IOU iou)
        {
            if (ModelState.IsValid)
            {
                iou.takenDt         = DateTime.Today;
                iou.statusChangedDt = DateTime.Today;
                iou.userID          = User.Identity.Name;

                db.IOUs.Add(iou);
                db.SaveChanges();
                return(Json(iou));
            }
            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
        }
Пример #3
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public OU() : base()
        {
            if (isMultiDatabase)
            {
                base.Init(this.GetType().FullName, System.Reflection.Assembly.GetExecutingAssembly().GetName().Name, dicmultiDatabase[this.GetType().Name].ToString());
            }
            else
            {
                base.Init(this.GetType().FullName, System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
            }

            baseDal.OnOperationLog += new OperationLogEventHandler(OperationLog.OnOperationLog);//如果需要记录操作日志,则实现这个事件

            dal = baseDal as IOU;
        }
Пример #4
0
        public void TestSimpleNegativeAdd()
        {
            using (StringWriter sw = new StringWriter())
            {
                IOU myIou = new IOU();
                myIou.ChangeDebt("You", -69);

                TextWriter stdout = Console.Out;
                Console.SetOut(sw);
                Console.WriteLine(myIou.HowMuchDoIOweTo("You"));
                Console.SetOut(stdout);

                // Assert
                Assert.AreEqual("0\n", sw.ToString().Replace("\r\n", "\n"), "Initial negative should not add debt!");
            }
        }
Пример #5
0
        public void TestSimpleAdd()
        {
            using (StringWriter sw = new StringWriter())
            {
                IOU myIou = new IOU();
                myIou.ChangeDebt("You", 69);

                TextWriter stdout = Console.Out;
                Console.SetOut(sw);
                Console.WriteLine(myIou.HowMuchDoIOweTo("You"));
                Console.SetOut(stdout);

                // Assert
                Assert.AreEqual("69\n", sw.ToString().Replace("\r\n", "\n"), "Single Change should still update the value!");
            }
        }
Пример #6
0
        public ActionResult Delete(int IOUid)
        {
            IOU iOU = db.IOUs.Find(IOUid);

            db.IOUs.Remove(iOU);
            db.SaveChanges();
            //return RedirectToAction("Index");

            //ViewBag.statusId = new SelectList(db.IOUStatus, "statusID", "status", iOU.statusId);

            //var iOUs = db.IOUs
            // .Where(i => i.userID == User.Identity.Name)
            // .Include(i => i.status)
            // .Include(i => i.status.color);
            //var x = new IOUViewModel { iOU = null, allIOUsOfUser = iOUs.ToList() };
            //x.allIOUStatuses = db.IOUStatus.ToList();
            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
Пример #7
0
        public void TestExample()
        {
            using (StringWriter sw = new StringWriter())
            {
                IOU mattsIOU = new IOU();
                mattsIOU.ChangeDebt("Arthur", 51);
                mattsIOU.ChangeDebt("Michael", 30);

                TextWriter stdout = Console.Out;
                Console.SetOut(sw);
                Console.WriteLine(mattsIOU.HowMuchDoIOweTo("Arthur"));
                Console.WriteLine(mattsIOU.HowMuchDoIOweTo("Michael"));
                Console.WriteLine(mattsIOU.HowMuchDoIOweTo("Heikki"));
                Console.SetOut(stdout);

                // Assert
                Assert.AreEqual("51\n30\n0\n", sw.ToString().Replace("\r\n", "\n"), "The example should work!");
            }
        }
Пример #8
0
        public ActionResult Edit([Bind(Include = "IOUId,lenderName ,amount ,statusId ,plannedReturnDt")] IOU iOU)
        {
            if (ModelState.IsValid)
            {
                var _iou = db.IOUs.Find(iOU.IOUId);
                _iou.statusId = iOU.statusId;
                if (_iou.statusId != iOU.statusId)
                {
                    _iou.statusChangedDt = DateTime.Now;
                }
                _iou.plannedReturnDt = iOU.plannedReturnDt;
                _iou.lenderName      = iOU.lenderName;
                _iou.amount          = iOU.amount;

                iOU = _iou;
                db.Entry(iOU).State = EntityState.Modified;
                db.SaveChanges();
            }
            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
Пример #9
0
        // GET: AjaxIOUs/Create
        public ActionResult LoadPage()
        {
            ViewBag.statusId = new SelectList(db.IOUStatus, "statusID", "status");
            //return View();

            var iOU = new IOU {
                userID = User.Identity.Name, takenDt = DateTime.Today, statusChangedDt = DateTime.Today, statusId = db.IOUStatus.FirstOrDefault().statusID
            };

            var iOUs = db.IOUs
                       .Where(i => i.userID == User.Identity.Name)
                       .Include(i => i.status)
                       .Include(i => i.status.color);
            var x = new IOUViewModel {
                iOU = iOU, allIOUsOfUser = iOUs.ToList()
            };

            x.allIOUStatuses = db.IOUStatus.ToList();
            return(View(x));
        }
Пример #10
0
 public void TestMultipleChanges()
 {
     using (StringWriter sw = new StringWriter())
     {
         TextWriter stdout = Console.Out;
         Console.SetOut(sw);
         IOU mattsIOU = new IOU();
         mattsIOU.ChangeDebt("Heikki", 81);
         mattsIOU.ChangeDebt("Heikki", -30);
         Console.WriteLine(mattsIOU.HowMuchDoIOweTo("Heikki"));
         mattsIOU.ChangeDebt("Heikki", 20);
         Console.WriteLine(mattsIOU.HowMuchDoIOweTo("Heikki"));
         mattsIOU.ChangeDebt("Heikki", 80);
         Console.WriteLine(mattsIOU.HowMuchDoIOweTo("Heikki"));
         mattsIOU.ChangeDebt("Heikki", -121);
         Console.WriteLine(mattsIOU.HowMuchDoIOweTo("Heikki"));
         Console.SetOut(stdout);
         Assert.AreEqual("51\n71\n151\n30\n", sw.ToString().Replace("\r\n", "\n"), "Multiple changes should change the value multiple times!");
     }
 }
Пример #11
0
 public void TestSecondExample()
 {
     using (StringWriter sw = new StringWriter())
     {
         TextWriter stdout = Console.Out;
         Console.SetOut(sw);
         IOU mattsIOU = new IOU();
         mattsIOU.ChangeDebt("Arthur", -10);
         Console.WriteLine(mattsIOU.HowMuchDoIOweTo("Arthur"));
         mattsIOU.ChangeDebt("Arthur", 51);
         mattsIOU.ChangeDebt("Arthur", 30);
         Console.WriteLine(mattsIOU.HowMuchDoIOweTo("Arthur"));
         mattsIOU.ChangeDebt("Arthur", -30);
         Console.WriteLine(mattsIOU.HowMuchDoIOweTo("Arthur"));
         mattsIOU.ChangeDebt("Arthur", -80);
         Console.WriteLine(mattsIOU.HowMuchDoIOweTo("Arthur"));
         Console.SetOut(stdout);
         Assert.AreEqual("0\n81\n51\n0\n", sw.ToString().Replace("\r\n", "\n"), "The second example should work!");
     }
 }
    protected void GridView2_AddRetrievalList(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "addRetrievalList")
        {
            String      rowindex = e.CommandArgument.ToString();
            GridViewRow row      = GridView2.Rows[Convert.ToInt32(rowindex)];



            // int rowindex = ((sender as Button).namingcontainer as gridviewrow).rowindex;
            string description    = row.Cells[0].Text;
            string departmentname = row.Cells[1].Text;
            int    iouquantity    = Int32.Parse(row.Cells[2].Text);


            DateTime now  = DateTime.Now;
            DateTime date = now.Date;


            string itemNumber = ssis.Stationery_Catalogue.Where(x => x.Description == description).Select(x => x.Item_Number).FirstOrDefault().ToString();

            string depID = ssis.IOUs.Where(x => x.Item_Number == itemNumber).Select(x => x.Department_ID).FirstOrDefault();

            Department_Orders depOrdSelected = ssis.Department_Orders.Where(x => x.Department_ID == depID && x.Item_ID == itemNumber).FirstOrDefault();

            //string iouID = ssis.IOUs.Where(p => p.Item_Number == itemNumber && p.Department_ID == depID && p.Status == "'Processed'").Select(x=>x.IOU_ID).FirstOrDefault();

            IOU iou = ssis.IOUs.Where(p => p.Item_Number == itemNumber && p.Department_ID == depID && p.Status == "Unprocess").First <IOU>();
            if (depOrdSelected != null)
            {
                string   deptOrderID          = depOrdSelected.Department_ID;
                string   deptOrderIouNum      = depOrdSelected.Item_ID;
                int      deptOrderIouQuantity = (int)depOrdSelected.IOU_Quantity;
                DateTime deptDate             = (DateTime)depOrdSelected.Requisition_Date;
                //  int different = Int32.Parse( date - deptDate).ToString();
                int dateDept = (date - deptDate).Days;
                //DateTime deD= DateTime.Now.Date.AddDays(-7);
                if (depID == deptOrderID && deptOrderIouNum == itemNumber && dateDept < 3)
                {
                    iouquantity += deptOrderIouQuantity;
                    Department_Orders selectedDepOrd = ssis.Department_Orders.Where(x => x.Department_ID == depID && x.Item_ID == itemNumber).First <Department_Orders>();
                    selectedDepOrd.IOU_Quantity = iouquantity;
                    ssis.SaveChanges();
                }
                else
                {
                    Department_Orders deptOrder = new Department_Orders
                    {
                        Department_ID        = depID,
                        Item_ID              = itemNumber,
                        Requisition_Date     = date,
                        Requisition_Quantity = 0,
                        Fulfilled_Quantity   = 0,
                        IOU_Quantity         = iouquantity,
                        Return_Quantity      = 0
                    };

                    ssis.Department_Orders.Add(deptOrder);
                    ssis.SaveChanges();
                }
            }
            else
            {
                Department_Orders deptOrder = new Department_Orders
                {
                    Department_ID        = depID,
                    Item_ID              = itemNumber,
                    Requisition_Date     = date,
                    Requisition_Quantity = 0,
                    Fulfilled_Quantity   = 0,
                    IOU_Quantity         = iouquantity,
                    Return_Quantity      = 0
                };

                ssis.Department_Orders.Add(deptOrder);
                ssis.SaveChanges();
            }

            iou.Status = "Processed";
            ssis.SaveChanges();

            Response.Redirect("~/com.ssis.storeclerk/Store_ListofRequisitionForms.aspx");
        }
    }
Пример #13
0
 public OU()
 {
     base.Init(base.GetType().FullName, Assembly.GetExecutingAssembly().GetName().Name);
     this.iou_0 = base.baseDal as IOU;
 }