/// <summary>
        /// 修改收款单信息
        /// </summary>
        /// <param name="model">收款单实体</param>
        /// <returns>true 成功,false失败</returns>
        public static bool UpdateIncomeBill(IncomeBillModel model,decimal OldPrice)
        {
            if (model == null) return false;
            model.ModifiedUserID = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).UserID;
   

            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
            try
            {

                bool succ = false;
                string loginUserID = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).UserID;

                LogInfoModel logModel = InitLogInfo(model.InComeNo, 0);
                logModel.Element = ConstUtil.LOG_PROCESS_UPDATE;

                succ = IncomeBillDBHelper.UpdateIncomeBill(model, OldPrice);
                if (!succ)
                    logModel.Remark = ConstUtil.LOG_PROCESS_FAILED;
                else
                    logModel.Remark = ConstUtil.LOG_PROCESS_SUCCESS;
                LogDBHelper.InsertLog(logModel);
                return succ;

            }
            catch (Exception ex)
            {
                WriteSystemLog(userInfo, 0, ex);
                return false;
            }

        }
        /// <summary>
        /// 修改收款单信息
        /// </summary>
        /// <param name="model">收款单实体</param>
        /// <returns>true 成功,false失败</returns>
        public static bool UpdateIncomeBill(IncomeBillModel model,decimal OldPrice)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("update officedba.IncomeBill set ");
            sql.AppendLine("[AcceDate] =@AcceDate,");
            sql.AppendLine("[CustName] =@CustName,");
            sql.AppendLine("[BillingID] =@BillingID,");
            sql.AppendLine("[TotalPrice] =@TotalPrice,");
            sql.AppendLine("[AcceWay] =@AcceWay,");
            sql.AppendLine("[BankName] =@BankName,");
            sql.AppendLine("[Executor] =@Executor,");
            sql.AppendLine("[AccountNo] =@AccountNo,");
            sql.AppendLine("[ModifiedDate] =getdate(),");
            sql.AppendLine("[ModifiedUserID] = @ModifiedUserID,");
            sql.AppendLine("[Summary] = @Summary,");
            sql.AppendLine("[BlendingType] = @BlendingType,CurrencyType=@CurrencyType,CurrencyRate=@CurrencyRate,CustID=@CustID,FromTBName=@FromTBName,FileName=@FileName,ProjectID=@ProjectID");
            sql.AppendLine("where ID=@ID");


            SqlCommand comm = new SqlCommand();
            comm.CommandText = sql.ToString();

            comm.Parameters.AddWithValue("@AcceDate", SqlDbType.DateTime).Value = model.AcceDate;
            comm.Parameters.AddWithValue("@CustName", SqlDbType.VarChar).Value = model.CustName;
            comm.Parameters.AddWithValue("@BillingID", SqlDbType.Int).Value = model.BillingID;
            comm.Parameters.AddWithValue("@TotalPrice", SqlDbType.Decimal).Value = model.TotalPrice;
            comm.Parameters.AddWithValue("@AcceWay", SqlDbType.Char).Value = model.AcceWay;
            comm.Parameters.AddWithValue("@BankName", SqlDbType.VarChar).Value = model.BankName;
            comm.Parameters.AddWithValue("@Executor", SqlDbType.Int).Value = model.Executor;
            comm.Parameters.AddWithValue("@AccountNo", SqlDbType.VarChar).Value = model.AccountNo;
            comm.Parameters.AddWithValue("@ModifiedUserID", SqlDbType.VarChar).Value = model.ModifiedUserID;
            comm.Parameters.AddWithValue("@Summary", SqlDbType.VarChar).Value = model.Summary;
            comm.Parameters.AddWithValue("@BlendingType", SqlDbType.Char).Value = model.BlendingType;
            comm.Parameters.AddWithValue("@CurrencyType", SqlDbType.Int).Value = model.CurrencyType;
            comm.Parameters.AddWithValue("@CurrencyRate", SqlDbType.Decimal).Value = model.CurrencyRate;
            comm.Parameters.AddWithValue("@CustID", SqlDbType.Int).Value = model.CustID;
            comm.Parameters.AddWithValue("@FromTBName", SqlDbType.VarChar).Value = model.FromTBName;
            comm.Parameters.AddWithValue("@FileName", SqlDbType.VarChar).Value = model.FileName;
            comm.Parameters.AddWithValue("@ProjectID", SqlDbType.Int).Value = model.ProjectID;

            comm.Parameters.AddWithValue("@ID", SqlDbType.Int).Value = model.ID;

            ArrayList listCmd = new ArrayList();
            listCmd.Add(comm);

            if (model.BillingID > 0)
            {
                UpdateBillingPriceInfo(listCmd, model.BillingID, model.TotalPrice, OldPrice);
            }

            bool result = SqlHelper.ExecuteTransWithArrayList(listCmd);

            return result;
        }
        /// <summary>
        /// 添加收款单信息
        /// </summary>
        /// <param name="model">收款单实体</param>
        /// <returns>true 成功,false失败</returns>
        public static bool InsertIncomeBill(IncomeBillModel model, out int ID)
        {
            ID = 0;
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];

            model.CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;
            model.ModifiedUserID = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).UserID;
           

            try
            {

                bool succ = false;
                string loginUserID = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).UserID;

                LogInfoModel logModel = InitLogInfo(model.InComeNo, 0);

                logModel.Element = ConstUtil.LOG_PROCESS_UPDATE;

                succ = IncomeBillDBHelper.InsertIncomeBill(model, out ID);
                if (!succ)
                    logModel.Remark = ConstUtil.LOG_PROCESS_FAILED;
                else
                    logModel.Remark = ConstUtil.LOG_PROCESS_SUCCESS;
                LogDBHelper.InsertLog(logModel);
                return succ;


            }
            catch (Exception ex)
            {
                WriteSystemLog(userInfo, 0, ex);

                return false;
            }

        }
        /// <summary>
        /// 添加收款单信息
        /// </summary>
        /// <param name="model">收款单实体</param>
        /// <returns>true 成功,false失败</returns>
        public static bool InsertIncomeBill(IncomeBillModel model, out int ID)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("Insert into officedba.IncomeBill");
            sql.AppendLine("(CompanyCD,InComeNo,AcceDate,");
            sql.AppendLine("CustName,BillingID,TotalPrice,");
            sql.AppendLine("AcceWay,BankName,Executor,");
            sql.AppendLine("AccountNo,ModifiedDate,ModifiedUserID,Summary,BlendingType,CurrencyType,CurrencyRate,CustID,FromTBName,FileName,ProjectID)");
            sql.AppendLine("values(@CompanyCD,@InComeNo,@AcceDate,");
            sql.AppendLine("@CustName,@BillingID,@TotalPrice,@AcceWay,");
            sql.AppendLine("@BankName,@Executor,@AccountNo,getdate(),@ModifiedUserID,@Summary,@BlendingType,@CurrencyType,@CurrencyRate,@CustID,@FromTBName,@FileName,@ProjectID)");
            sql.AppendLine("set @IntID= @@IDENTITY");

            SqlCommand comm = new SqlCommand();
            comm.CommandText = sql.ToString();
            comm.Parameters.AddWithValue("@CompanyCD", SqlDbType.VarChar).Value = model.CompanyCD;
            comm.Parameters.AddWithValue("@InComeNo", SqlDbType.VarChar).Value = model.InComeNo;
            comm.Parameters.AddWithValue("@AcceDate", SqlDbType.VarChar).Value = model.AcceDate;
            comm.Parameters.AddWithValue("@CustName", SqlDbType.VarChar).Value = model.CustName;
            comm.Parameters.AddWithValue("@BillingID", SqlDbType.VarChar).Value = model.BillingID;
            comm.Parameters.AddWithValue("@TotalPrice", SqlDbType.VarChar).Value = model.TotalPrice;
            comm.Parameters.AddWithValue("@AcceWay", SqlDbType.Char).Value = model.AcceWay;
            comm.Parameters.AddWithValue("@BankName", SqlDbType.VarChar).Value = model.BankName;
            comm.Parameters.AddWithValue("@Executor", SqlDbType.VarChar).Value = model.Executor;
            comm.Parameters.AddWithValue("@AccountNo", SqlDbType.VarChar).Value = model.AccountNo;
            comm.Parameters.AddWithValue("@ModifiedUserID", SqlDbType.VarChar).Value = model.ModifiedUserID;
            comm.Parameters.AddWithValue("@Summary", SqlDbType.VarChar).Value = model.Summary;
            comm.Parameters.AddWithValue("@BlendingType", SqlDbType.Char).Value = model.BlendingType;
            comm.Parameters.AddWithValue("@CurrencyType", SqlDbType.Int).Value = model.CurrencyType;
            comm.Parameters.AddWithValue("@CurrencyRate", SqlDbType.Decimal).Value = model.CurrencyRate;

            comm.Parameters.AddWithValue("@CustID", SqlDbType.Int).Value = model.CustID;
            comm.Parameters.AddWithValue("@FromTBName", SqlDbType.VarChar).Value = model.FromTBName;
            comm.Parameters.AddWithValue("@FileName", SqlDbType.VarChar).Value = model.FileName;
            comm.Parameters.AddWithValue("@ProjectID", SqlDbType.Int).Value = model.ProjectID;

            SqlParameter Ret = new SqlParameter("@IntID", SqlDbType.Int);//定义返回值参数 
            Ret.Direction = ParameterDirection.Output;
            comm.Parameters.Add(Ret);
            ArrayList listCmd = new ArrayList();
            listCmd.Add(comm);
            if (model.BillingID > 0)
            {
                UpdateBillingPrice(listCmd, model.BillingID, model.TotalPrice);
            }
            bool result = SqlHelper.ExecuteTransWithArrayList(listCmd);
            ID = Convert.ToInt32(Ret.Value);

            return result;
        }