public JsonResult Create(UserType obj)
        {
            try
            {

                OrganizeType obj1 = NSession.Get<OrganizeType>(obj.DId);
                if (obj1 != null)
                {
                    obj.DepartmentName = obj1.ShortName;
                }
                OrganizeType obj2 = NSession.Get<OrganizeType>(obj.CId);
                if (obj2 != null)
                {
                    obj.CompanyName = obj2.ShortName;
                }
                obj.CreateOn = DateTime.Now;
                obj.LastVisit = DateTime.Now;

                NSession.SaveOrUpdate(obj);
                NSession.Flush();
            }
            catch (Exception ee)
            {
                return Json(new { IsSuccess = false, ErrorMsg = "出错了" });
            }
            return Json(new { IsSuccess = true });
        }
 public static void GetOrderRecord(int oid, string OrderNo, string recordType, string Content, UserType CurrentUser, ISession NSession)
 {
     OrderRecordType orderRecord = new OrderRecordType();
     orderRecord.OId = oid;
     orderRecord.OrderNo = OrderNo;
     orderRecord.RecordType = recordType;
     orderRecord.CreateBy = CurrentUser.Realname;
     orderRecord.Content = Content;
     orderRecord.CreateOn = DateTime.Now;
     NSession.Save(orderRecord);
     NSession.Flush();
 }
 private static void GetPurchasePlanRecord(int OId, string PlanNo, string SKU, string recordType, string Content, UserType CurrentUser, ISession NSession)
 {
     PurchasePlanRecordType obj = new PurchasePlanRecordType();
     obj.OId = OId;
     obj.SKU = SKU;
     obj.PlanNo = PlanNo;
     obj.RecordType = recordType;
     obj.Content = Content;
     obj.CreateBy = CurrentUser.Realname;
     obj.CreateOn = DateTime.Now;
     NSession.Save(obj);
     NSession.Flush();
 }
 private static void GetProductRecord(int OId, string OldSKU, string SKU, string recordType, string Content, UserType CurrentUser, ISession NSession)
 {
     ProductRecordType productrecoud = new ProductRecordType();
     productrecoud.OldSKU = OldSKU;
     productrecoud.SKU = SKU;
     productrecoud.OId = OId;
     productrecoud.RecordType = recordType;
     productrecoud.Content = Content;
     productrecoud.CreateBy = CurrentUser.Realname;
     productrecoud.CreateOn = DateTime.Now;
     NSession.Save(productrecoud);
     NSession.Flush();
 }
 public ActionResult Create()
 {
     UserType u = new UserType();
     u.Code = Utilities.GetUserNo(NSession);
     return View(u);
 }
        public ActionResult Edit(UserType obj)
        {

            try
            {
                OrganizeType obj1 = NSession.Get<OrganizeType>(obj.DId);
                if (obj1 != null)
                {
                    obj.DepartmentName = obj1.ShortName;
                }
                OrganizeType obj2 = NSession.Get<OrganizeType>(obj.CId);
                if (obj2 != null)
                {
                    obj.CompanyName = obj2.ShortName;
                }
                NSession.Update(obj);
                NSession.Flush();
            }
            catch (Exception ee)
            {
                return Json(new { IsSuccess = false, ErrorMsg = "出错了" });
            }
            return Json(new { IsSuccess = true });

        }
        public ActionResult Login(UserType user)
        {
            if (Session["__VCode"] == null || (Session["__VCode"] != null && user.ValidateCode != Session["__VCode"].ToString()))
            {
                ModelState.AddModelError("Username", "验证码错误!");
                return View();
            }

            bool iscon = Utilities.LoginByUser(user.Username, user.Password, NSession);
            if (iscon)
            {
                Utilities.CreateCookies(user.Username, user.Password);
                return RedirectToAction("Index", "Home");
            }

            ModelState.AddModelError("Username", "用户名或者密码出错。");
            return View();
        }
 private static void GetDisputeRecord(int OId,string recordType, string Content, UserType CurrentUser, ISession NSession)
 {
     DisputesRecordType obj = new DisputesRecordType();
     obj.DId = OId;
     obj.DealType = recordType;
     obj.Content = Content;
     obj.CreateBy = CurrentUser.Realname;
     obj.CreateOn = DateTime.Now;
     NSession.Save(obj);
     NSession.Flush();
 }
 //纠纷日志
 public static void GetDisputeRecord(DisputeType obj, string recordType, string Content, UserType CurrentUser, ISession NSession)
 {
     GetDisputeRecord(obj.Id,recordType, Content, CurrentUser, NSession);
 }
  //采购计划日志
 public static void GetPurchasePlanRecord(PurchasePlanType obj, string recordType, string Content, UserType CurrentUser, ISession NSession)
 {
     GetPurchasePlanRecord(obj.Id, obj.PlanNo, obj.SKU, recordType, Content, CurrentUser, NSession);
 }
        //商品日志
        public static void GetProductRecord(ProductType obj, string recordType, string Content,UserType CurrentUser,ISession NSession)
        {
            GetProductRecord(obj.Id, obj.OldSKU, obj.SKU, recordType, Content, CurrentUser, NSession);

        }
 //订单日志
 public static void GetOrderRecord(OrderType order, string recordType, string Content, UserType CurrentUser, ISession NSession)
 {
     GetOrderRecord(order.Id, order.OrderNo, recordType, Content, CurrentUser, NSession);
 }