示例#1
0
 public JsonResult AddUser(User_Property objUserProp)
 {
     if (ModelState.IsValid)
     {
         if (objUserProp.ID <= 0 || objUserProp.ID == null)
         {
             objUserProp.Status      = "Active";
             objUserProp.Active      = 1;
             objUserProp.Operated_By = SessionManager.CurrentUser.ID;
             objUserBll = new User_BLL(objUserProp);
             DataTable d = objUserBll.CheckUserExistance();
             if (d.Rows.Count > 0)
             {
                 return(Json(new { success = false, statuscode = 501, msg = "Failed" }, JsonRequestBehavior.AllowGet));
             }
             var flag = objUserBll.Insert();
             if (flag)
             {
                 return(Json(new { success = true, statuscode = 200, msg = "Successfully inserted" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { success = false, statuscode = 500, msg = "Failed" }, JsonRequestBehavior.AllowGet));
             }
         }
         else
         {
             //objClientBLL = new Client_BLL(objClientProp);
             //var flag = objClientBLL.Update();
             //if (flag)
             //{
             //    return Json(new { success = true, statuscode = 200, msg = "Successfully inserted" }, JsonRequestBehavior.AllowGet);
             //}
             //else
             //{
             //    return Json(new { success = false, statuscode = 500, msg = "Failed" }, JsonRequestBehavior.AllowGet);
             //}
             return(Json(new { success = false, statuscode = 500, msg = "Failed" }, JsonRequestBehavior.AllowGet));
         }
     }
     else
     {
         return(Json(new { success = false, statuscode = 500, msg = "Please Enter According To Instructions" }, JsonRequestBehavior.AllowGet));
     }
 }
        public JsonResult AddUpdate(User_Property objuser)
        {
            if (Session["LOGGEDIN"] != null)
            {
                try
                {
                    if (objuser.idx > 0)
                    {
                        objuser.lastModifiedByUserIdx = 1;
                        objuser.lastModificationDate  = DateTime.Now.ToString("dd/MM/yyyy");
                        objUser = new User_BLL(objuser);

                        bool flag = objUser.Update();
                        return(Json(new { data = "Updated", success = flag, statuscode = 200 }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        objuser.companyIdx       = 1;
                        objuser.createdByUserIdx = 1;
                        objUser = new User_BLL(objuser);
                        //if (objUser.isMainBranch == 1)
                        //{
                        //    var check = objUser.MainBranch();
                        //    if (check.Rows.Count > 0)
                        //    {
                        //        return Json(new { data = "Main Branch Already Exist", success = false, statuscode = 500 }, JsonRequestBehavior.AllowGet);
                        //    }
                        //}

                        bool flag = objUser.Insert();
                        return(Json(new { data = "Inserted", success = flag, statuscode = 200 }, JsonRequestBehavior.AllowGet));
                    }
                }
                catch (Exception ex)
                {
                    return(Json(new { data = ex.Message, success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new { data = "Session Expired", success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet));
            }
        }