Example #1
0
        public ActionResult AddNewUserType(UserTypeModel userTypeModel)
        {
            if (!ModelState.IsValid)
            {
                return View(userTypeModel);
            }

            UserTypeTableAdapter userTypeTableAdapter = new UserTypeTableAdapter();

            try
            {
                string typeShortName = userTypeModel.typeShortName;
                string typeName = userTypeModel.typeName;
                int mealValue = userTypeModel.mealValue;
                int? moreMealValue = 0;

                if (!string.IsNullOrEmpty(userTypeModel.moreMealValue.ToString()))
                {
                    moreMealValue = userTypeModel.moreMealValue;
                }

                string description = userTypeModel.description;
                Boolean canDebt = userTypeModel.canDebt;
                Boolean canEatMore = userTypeModel.canEatMore;
                DateTime date = DateTime.Now;
                string updateBy = AccountInfo.GetUserName(Request);
                userTypeTableAdapter.InsertNewUserType(typeShortName, typeName, mealValue, moreMealValue, description, canDebt, canEatMore, date, updateBy, date);
                XmlSync.SaveUserTypeXml(typeShortName, typeName, mealValue, moreMealValue, description, canDebt, canEatMore, date, updateBy, date, null);
                Session["addUserType"] = "Thêm mới thành công!";
            }
            catch (Exception ex)
            {
                Log.ErrorLog(ex.Message);
                Session["addUserType"] = "Thêm mới thất bại!";
            }
            return RedirectToAction("AddNewUserType", "Account");
        }
Example #2
0
 public ActionResult EditUserType(string typeShortName)
 {
     UserTypeModel userTypeModel = new UserTypeModel();
     DataTable userTypeDataTable = new DataTable();
     UserTypeTableAdapter userTypeTableAdapter = new UserTypeTableAdapter();
     try
     {
         userTypeDataTable = userTypeTableAdapter.GetDataByTypeShortName(typeShortName);
         userTypeModel.typeShortName = Convert.ToString(userTypeDataTable.Rows[0]["TypeShortName"]);
         userTypeModel.typeName = Convert.ToString(userTypeDataTable.Rows[0]["TypeName"]);
         userTypeModel.mealValue = Convert.ToInt32(userTypeDataTable.Rows[0]["MealValue"]);
         userTypeModel.moreMealValue = Convert.ToInt32(userTypeDataTable.Rows[0]["MoreMealValue"]);
         userTypeModel.description = Convert.ToString(userTypeDataTable.Rows[0]["Description"]);
         userTypeModel.canDebt = Convert.ToBoolean(userTypeDataTable.Rows[0]["CanDebt"]);
         userTypeModel.canEatMore = Convert.ToBoolean(userTypeDataTable.Rows[0]["CanEatMore"]);
         userTypeModel.insertedDate = Convert.ToDateTime(userTypeDataTable.Rows[0]["InsertedDate"]);
         userTypeModel.lastUpdated = Convert.ToDateTime(userTypeDataTable.Rows[0]["LastUpdated"]);
         userTypeModel.updatedBy = Convert.ToString(userTypeDataTable.Rows[0]["UpdatedBy"]);
     }
     catch (Exception ex)
     {
         Log.ErrorLog(ex.Message);
         return RedirectToAction("Error", "Error");
     }
     return View(userTypeModel);
 }
Example #3
0
 public ActionResult DetailsUserType(string typeShortName)
 {
     UserTypeTableAdapter userTypeDataTableAdapter = new UserTypeTableAdapter();
     DataTable dt = userTypeDataTableAdapter.GetDataByTypeShortName(typeShortName);
     UserTypeModel userTypeModel = new UserTypeModel();
     try
     {
         userTypeModel.typeShortName = Convert.ToString(dt.Rows[0]["TypeShortName"]);
         userTypeModel.typeName = Convert.ToString(dt.Rows[0]["TypeName"]);
         userTypeModel.mealValue = Convert.ToInt32(dt.Rows[0]["MealValue"]);
         userTypeModel.moreMealValue = Convert.ToInt32(dt.Rows[0]["MoreMealValue"]);
         userTypeModel.description = Convert.ToString(dt.Rows[0]["Description"]);
         userTypeModel.canDebt = Convert.ToBoolean(dt.Rows[0]["CanDebt"]);
         userTypeModel.canEatMore = Convert.ToBoolean(dt.Rows[0]["CanEatMore"]);
     }
     catch (Exception ex)
     {
         Log.ErrorLog(ex.Message);
     }
     if (userTypeModel == null)
     {
         return HttpNotFound();
     }
     return View(userTypeModel);
 }