Esempio n. 1
0
        /// <summary>
        /// 新增帐号
        /// </summary>
        /// <param name="data"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public long InsertAccount(Account data, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            //创建存储过程参数
            SqlParameter[] Params =
                {
                    MakeParam(ID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Output, (object)data.Id),
                    MakeParam(NAME_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.Name),
                    MakeParam(PASSWORD_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.Password),
                    MakeParam(ACCOUNTTYPE_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.AccountType),
                    MakeParam(ORGANID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.OrganId),
                    MakeParam(STAFFID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.StaffId),
                    MakeParam(STAFFNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.StaffName),
                    MakeParam(OPSTAFFID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)nOpStaffId),
                    MakeParam(OPSTAFFNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)strOpStaffName),
                };

            SqlParameterCollection outParams;
            if (Execute("InsertAccount", Params, out outParams, out strErrText) < 0)
            {
                return 0;
            }
            else
            {
                return (long)outParams[ID_PARAM].Value;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 新增帐号
        /// </summary>
        /// <param name="data"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public long InsertAccount(Account data, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            long nId = 0;

            try
            {
                //生成登录密码MD5码,密码默认为123456
                data.Password = Utils.GetMD5Hash(data.Name + "@" + "123456");

                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (AuthenticateDAO dao = new AuthenticateDAO())
                    {
                        nId = dao.InsertAccount(data, nOpStaffId, strOpStaffName, out strErrText);
                        if (nId <= 0)
                            return 0;
                    }
                    transScope.Complete();
                }
                return nId;
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return 0;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 新增登录日志记录
        /// </summary>
        /// <param name="data">登录帐号数据集</param>
        /// <param name="strErrText">出错信息</param>
        /// <returns>成功返回True,否则返回False</returns>
        public bool InsertLoginLog(Account data, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            //创建存储过程参数
            SqlParameter[] Params =
                {
                    MakeParam(ORGANID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.OrganId),
                    MakeParam(ORGANNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.OrganFullName),
                    MakeParam(STAFFID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.StaffId),
                    MakeParam(STAFFNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.StaffName),
                    MakeParam(HOSTIP_PARAM, SqlDbType.NVarChar, 30, ParameterDirection.Input, (object)string.Empty),
                    MakeParam(HOSTNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)string.Empty),
                    MakeParam(OPSTAFFID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)nOpStaffId),
                    MakeParam(OPSTAFFNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)strOpStaffName),
                };

            if (Execute("InsertLoginLog", Params, out strErrText) < 0)
                return false;
            else
                return true;
        }
Esempio n. 4
0
 /// <summary>
 /// 新增帐号
 /// </summary>
 /// <param name="data"></param>
 /// <param name="nOpStaffId"></param>
 /// <param name="strOpStaffName"></param>
 /// <param name="strErrText"></param>
 /// <returns></returns>
 public long InsertAccount(Account data, long nOpStaffId, string strOpStaffName, out string strErrText)
 {
     AuthenticateRule rule = new AuthenticateRule();
     return rule.InsertAccount(data, nOpStaffId, strOpStaffName, out strErrText);
 }
Esempio n. 5
0
 /// <summary>
 /// 修改帐号
 /// </summary>
 /// <param name="data"></param>
 /// <param name="nOpStaffId"></param>
 /// <param name="strOpStaffName"></param>
 /// <param name="strErrText"></param>
 /// <returns></returns>
 public bool UpdateAccount(Account data, long nOpStaffId, string strOpStaffName, out string strErrText)
 {
     try
     {
         using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
         {
             using (AuthenticateDAO dao = new AuthenticateDAO())
             {
                 if (!dao.UpdateAccount(data, nOpStaffId, strOpStaffName, out strErrText))
                     return false;
             }
             transScope.Complete();
         }
         return true;
     }
     catch (Exception e)
     {
         strErrText = e.Message;
         return false;
     }
 }
Esempio n. 6
0
        public ActionResult NewAccount(AccountViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.AccountType == InnoSoft.LS.Resources.Options.Staff)
                {
                    if (model.OrganId == 0)
                    {
                        return Json(InnoSoft.LS.Resources.Strings.NotSelectedOrgan);
                    }
                    if (model.StaffId == 0)
                    {
                        return Json(InnoSoft.LS.Resources.Strings.NotSelectedStaff);
                    }
                }
                else
                {
                    if (model.CustomerId == 0)
                    {
                        return Json(InnoSoft.LS.Resources.Strings.NotSelectedCustomer);
                    }
                    if (model.ContactName.Trim() == string.Empty)
                    {
                        return Json(InnoSoft.LS.Resources.Strings.NotEnterContactName);
                    }
                }

                //创建数据
                Account data = new Account();
                data.Name = model.Name;
                data.AccountType = model.AccountType;
                data.OrganId = model.AccountType == InnoSoft.LS.Resources.Options.Staff ? model.OrganId : model.CustomerId;
                data.StaffId = model.AccountType == InnoSoft.LS.Resources.Options.Staff ? model.StaffId : 0;
                data.StaffName = model.AccountType == InnoSoft.LS.Resources.Options.Staff ? string.Empty : model.ContactName;

                //保存数据
                string strErrText;
                AuthenticateSystem auth = new AuthenticateSystem();
                if (auth.InsertAccount(data, LoginAccountId, LoginStaffName, out strErrText) > 0)
                {
                    return Json(string.Empty);
                }
                else
                {
                    return Json(strErrText);
                }
            }
            return View(model);
        }
Esempio n. 7
0
        /// <summary>
        /// 修改帐号
        /// </summary>
        /// <param name="data"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool UpdateAccount(Account data, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            //创建存储过程参数
            SqlParameter[] Params =
                {
                    MakeParam(ID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.Id),
                    MakeParam(NAME_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.Name),
                    MakeParam(PASSWORD_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.Password),
                    MakeParam(ACCOUNTTYPE_PARAM, SqlDbType.NVarChar, 20, ParameterDirection.Input, (object)data.AccountType),
                    MakeParam(ORGANID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.OrganId),
                    MakeParam(STAFFID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.StaffId),
                    MakeParam(STAFFNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.StaffName),
                    MakeParam(ISCANCEL_PARAM, SqlDbType.Bit, 1, ParameterDirection.Input, (object)data.IsCancel),
                    MakeParam(OPSTAFFID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)nOpStaffId),
                    MakeParam(OPSTAFFNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)strOpStaffName),
                };

            if (Execute("UpdateAccount", Params, out strErrText) >= 0)
                return true;
            else
                return false;
        }