Example #1
0
        /// <summary>
        /// 新增城市自定义数据
        /// </summary>
        /// <param name="data">城市自定义数据集</param>
        /// <param name="nOpStaffId">操作员工编码</param>
        /// <param name="strOpStaffName">操作员工姓名</param>
        /// <param name="strErrText">出错信息</param>
        /// <returns>成功返回true,否则返回false</returns>
        public bool InsertCity(City data, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            //创建存储过程参数
            SqlParameter[] Params =
                {
                    MakeParam(NAME_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.Name),
                    MakeParam(COUNTRYNAME_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.CountryName),
                    MakeParam(PROVINCENAME_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.ProvinceName),
                    MakeParam(REMARK_PARAM, SqlDbType.NVarChar, 100, ParameterDirection.Input, (object)data.Remark),
                    MakeParam(OPSTAFFID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)nOpStaffId),
                    MakeParam(OPSTAFFNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)strOpStaffName)
                };

            if (Execute("InsertCity", Params, out strErrText) >= 0)
                return true;
            else
                return false;
        }
Example #2
0
        public ActionResult NewCity(CityViewModel model)
        {
            if (ModelState.IsValid)
            {
                //创建数据
                City data = new City();
                data.Name = model.Name;
                data.CountryName = model.CountryName;
                data.ProvinceName = model.ProvinceName;
                data.Remark = model.Remark ?? string.Empty;

                //保存数据
                string strErrText;
                DDSystem city = new DDSystem();
                if (city.InsertCity(data, LoginAccountId, LoginStaffName, out strErrText))
                {
                    return Json(string.Empty);
                }
                else
                {
                    return Json(strErrText);
                }
            }
            return View(model);
        }
Example #3
0
 /// <summary>
 /// 新增城市自定义数据
 /// </summary>
 /// <param name="data">城市自定义数据集</param>
 /// <param name="nOpStaffId">操作员工编码</param>
 /// <param name="strOpStaffName">操作员工姓名</param>
 /// <param name="strErrText">出错信息</param>
 /// <returns>成功返回true,否则返回false</returns>
 public bool InsertCity(City data, long nOpStaffId, string strOpStaffName, out string strErrText)
 {
     try
     {
         using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
         {
             using (DDDAO dao = new DDDAO())
             {
                 if (!dao.InsertCity(data, nOpStaffId, strOpStaffName, out strErrText))
                     return false;
             }
             transScope.Complete();
         }
         return true;
     }
     catch (Exception e)
     {
         strErrText = e.Message;
         return false;
     }
 }