コード例 #1
0
 /// <summary>
 /// 插入一条新的数据,如果成功给Model.ID赋值主键,否则Model.ID="0"
 /// </summary>
 /// <param name="Model"></param>
 /// <returns></returns>
 public static bool InSert(InputCompanyRoyaltyModel Model)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.AppendLine("insert into officedba.InputCompanyRoyalty(");
     strSql.AppendLine("DeptID,CompanyCD,BusinessMoney,RecordDate,ModifiedUserID,CreateTime,ModifiedDate)");
     strSql.AppendLine(" values (");
     strSql.AppendLine("@DeptID,@CompanyCD,@BusinessMoney,@RecordDate,@ModifiedUserID,getdate(),getdate())");
     strSql.AppendLine(";set @IndexID= @@IDENTITY");
     SqlCommand comm = new SqlCommand();
     comm.CommandText = strSql.ToString();
     SqlParameter IndexID = new SqlParameter("@IndexID", SqlDbType.Int);
     IndexID.Direction = ParameterDirection.Output;
     comm.Parameters.Add(IndexID);
     SetSaveParameter(comm, Model);
     bool result = SqlHelper.ExecuteTransWithCommand(comm);
     if (result)
     {
         Model.ID = comm.Parameters["@IndexID"].Value.ToString();
     }
     else
     {
         Model.ID = "0";
     }
     return result;
 }
コード例 #2
0
        /// <summary>
        /// 查询公司提成录入信息
        /// </summary>
        /// <returns>DataTable</returns>
        public static DataTable GetInfo(InputCompanyRoyaltyModel model, string timeStart, string timeEnd, int pageIndex, int pageCount, string ord, ref int TotalCount)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.AppendLine("SELECT a.ID                                      ");
            strSql.AppendLine(",a.DeptID                                        ");
            strSql.AppendLine(",b.DeptName                                      ");
            strSql.AppendLine(",a.BusinessMoney                                 ");
            strSql.AppendLine(",Convert(Varchar(10),a.RecordDate,21) as RecordDate      ");
            strSql.AppendLine("FROM officedba.InputCompanyRoyalty a             ");
            strSql.AppendLine("inner join officedba.DeptInfo b on a.DeptID=b.ID ");
            strSql.AppendLine("where a.CompanyCD=@CompanyCD						");
            SqlCommand comm = new SqlCommand();
            //添加公司代码参数
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", model.CompanyCD));
            if (!string.IsNullOrEmpty(model.DeptID))
            {
                strSql.AppendLine(" and a.DeptID = @DeptID");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@DeptID", model.DeptID));
            }
            if (!string.IsNullOrEmpty(timeStart))
            {
                strSql.AppendLine(" and a.RecordDate>=@timeStart");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@timeStart", timeStart));
            }

            if (!string.IsNullOrEmpty(timeEnd))
            {
                strSql.AppendLine(" and a.RecordDate<=@timeEnd");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@timeEnd", Convert.ToDateTime(timeEnd).AddDays(1).ToString("yyyy-MM-dd")));
            }
            comm.CommandText = strSql.ToString();
            return SqlHelper.PagerWithCommand(comm, pageIndex, pageCount, ord, ref TotalCount);

        }
コード例 #3
0
        /// <summary>
        /// 查询公司提成录入信息
        /// </summary>
        /// <returns>DataTable</returns>
        public static DataTable GetInfo(InputCompanyRoyaltyModel model, string timeStart, string timeEnd, int pageIndex, int pageCount, string ord, ref int TotalCount)
        {
            try
            {
                return InputCompanyRoyaltyDBHelper.GetInfo(model, timeStart, timeEnd, pageIndex, pageCount, ord, ref TotalCount);
            }
            catch (Exception)
            {

                throw;
            }
        }
コード例 #4
0
        /// <summary>
        /// 插入一条新的数据,如果成功给Model.ID赋值主键,否则Model.ID="0"
        /// </summary>
        /// <param name="Model"></param>
        /// <returns></returns>
        public static bool InSert(InputCompanyRoyaltyModel Model)
        {
            //获取登陆用户信息
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
            //定义返回变量
            bool isSucc = false;
            /* 
             * 定义日志内容变量 
             * 增删改相关的日志,需要输出操作日志,该类型日志插入到数据库
             * 其他的 如出现异常时,需要输出系统日志,该类型日志保存到日志文件
             */
            try
            {
                isSucc = InputCompanyRoyaltyDBHelper.InSert(Model);
            }
            catch (Exception ex)
            {

                //输出日志
                WriteSystemLog(userInfo, ex);
            }
            string remark;
            //成功时
            if (isSucc)
            {
                //设置操作成功标识
                remark = ConstUtil.LOG_PROCESS_SUCCESS;
            }
            else
            {
                //设置操作成功标识 
                remark = ConstUtil.LOG_PROCESS_FAILED;
            }
            //操作日志
            LogInfoModel logModel = InitLogInfo(Model.DeptID);
            //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空
            logModel.Element = ConstUtil.LOG_PROCESS_INSERT;
            //设置操作成功标识
            logModel.Remark = remark;

            //登陆日志
            LogDBHelper.InsertLog(logModel);
            return isSucc;
        }
コード例 #5
0
        /// <summary>
        /// 保存时基本信息参数设置
        /// </summary>
        /// <param name="comm"></param>
        /// <param name="model"></param>
        private static void SetSaveParameter(SqlCommand comm, InputCompanyRoyaltyModel model)
        {
            if (!string.IsNullOrEmpty(model.ID))
            {
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@ID ", model.ID));//自动生成
            }
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@DeptID ", model.DeptID));//分公司ID
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD ", model.CompanyCD));//公司编码
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@BusinessMoney ", model.BusinessMoney));//数量
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@RecordDate ", model.RecordDate));//记录时间
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedUserID ", model.ModifiedUserID));//最后更新人

        }
コード例 #6
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="Model"></param>
        /// <returns></returns>
        public static bool Update(InputCompanyRoyaltyModel Model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.AppendLine("update officedba.InputCompanyRoyalty set ");
            strSql.AppendLine("DeptID=@DeptID,");
            strSql.AppendLine("CompanyCD=@CompanyCD,");
            strSql.AppendLine("BusinessMoney=@BusinessMoney,");
            strSql.AppendLine("RecordDate=@RecordDate,");
            strSql.AppendLine("ModifiedUserID=@ModifiedUserID,");
            strSql.AppendLine("ModifiedDate=getdate()");
            strSql.AppendLine(" where ID=@ID ");
            SqlCommand comm = new SqlCommand(strSql.ToString());
            SetSaveParameter(comm, Model);
            return SqlHelper.ExecuteTransWithCommand(comm);

        }