/// <summary> /// 添加销售机会及阶段 /// </summary> /// <param name="sellChanceModel">销售机会表实体</param> /// <param name="sellChancePushModel">销售阶段表实体</param> /// <returns>是否添加成功</returns> public static bool InsertSellChance(Hashtable ht,SellChanceModel sellChanceModel, SellChancePushModel sellChancePushModel) { bool isSucc = false;//是否添加成功 TransactionManager tran = new TransactionManager(); tran.BeginTransaction(); try { int sellChID = InsertChanece(tran, sellChanceModel); //若是设置了手机提醒 则插入以下信息 if (sellChanceModel.IsMobileNotice == "1") { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into officedba.NoticeHistory("); strSql.Append(" CompanyCD,SourceFlag,SourceID,PlanNoticeDate ) "); strSql.Append(" values(@CompanyCD, @SourceFlag,@SourceID,@PlanNoticeDate ) "); SqlParameter[] param = { new SqlParameter("@CompanyCD",sellChanceModel.CompanyCD), new SqlParameter("@SourceFlag","4"), new SqlParameter("@SourceID",sellChID), new SqlParameter("@PlanNoticeDate",sellChanceModel.RemindTime) }; SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, strSql.ToString(), param);//.ExecuteTransWithCommand(commN); } //拓展属性 GetExtAttrCmd(sellChanceModel,ht, tran); InsertPush(tran, sellChancePushModel); tran.Commit(); isSucc = true; } catch (Exception ex) { tran.Rollback(); isSucc = false; throw ex; } return isSucc; }
/// <summary> /// 添加销售机会及阶段 /// </summary> /// <param name="sellChanceModel">销售机会表实体</param> /// <param name="sellChancePushModel">销售阶段表实体</param> /// <returns>是否添加成功</returns> public static bool UpdateSellChance(Hashtable ht,SellChanceModel sellChanceModel, SellChancePushModel sellChancePushModel) { bool isSucc = false;//是否添加成功 //定义变量 string remark = string.Empty; try { isSucc = SellChanceDBHelper.UpdateSellChance(ht,sellChanceModel, sellChancePushModel); //设置操作成功标识 remark = ConstUtil.LOG_PROCESS_SUCCESS; } catch (Exception ex) { //输出日志 SellLogCommon.WriteSystemLog(ex, LogInfo.LogType.SYSTEM, LogInfo.SystemLogKind.SYSTEM_ERROR, ConstUtil.MODULE_ID_SELLCHANCE_ADD); //设置操作成功标识 remark = ConstUtil.LOG_PROCESS_FAILED; } SellLogCommon.InsertLog(sellChanceModel.ChanceNo, ConstUtil.MODULE_ID_SELLCHANCE_ADD, ConstUtil.CODING_RULE_TABLE_SELLCHANCE, remark, ConstUtil.LOG_PROCESS_UPDATE); return isSucc; }
/// <summary> /// 修改销售机会及阶段 /// </summary> /// <param name="sellChanceModel">销售机会表实体</param> /// <param name="sellChancePushModel">销售阶段表实体</param> /// <returns>是否添加成功</returns> public static bool UpdateSellChance(Hashtable ht,SellChanceModel sellChanceModel, SellChancePushModel sellChancePushModel) { bool isSucc = false;//是否添加成功 string strSql = "delete from officedba.SellChancePush where ChanceNo=@ChanceNo and CompanyCD=@CompanyCD and Phase=@Phase"; SqlParameter[] paras = { new SqlParameter("@ChanceNo", sellChancePushModel.ChanceNo), new SqlParameter("@CompanyCD", sellChancePushModel.CompanyCD), new SqlParameter("@Phase",sellChancePushModel.Phase) }; TransactionManager tran = new TransactionManager(); tran.BeginTransaction(); try { UpdateChanece(tran, sellChanceModel); //拓展属性 GetExtAttrCmd(sellChanceModel, ht, tran); //若是设置了手机提醒 则插入以下信息 if ( sellChanceModel.IsMobileNotice == "1") { //若有未发送的记录则更新该未发送的记录,否则则插入新记录 if (IsExistedNoSendMsg(sellChanceModel.ID.ToString(), "0",sellChanceModel.CompanyCD)) { StringBuilder strSqlMb = new StringBuilder(); //strSqlMb.Append("delete from officedba.NoticeHistory where SourceID=@SourceID and SourceFlag =@SourceFlag "); // strSqlMb.Append("insert into officedba.NoticeHistory("); //strSqlMb.Append(" CompanyCD,SourceFlag,SourceID,PlanNoticeDate ) "); //strSqlMb.Append(" values(@CompanyCD, @SourceFlag,@SourceID,@PlanNoticeDate ) "); strSqlMb.AppendLine(" update officedba.NoticeHistory set PlanNoticeDate=@PlanNoticeDate "); strSqlMb.AppendLine(" where CompanyCD=@CompanyCD and SourceID=@SourceID and SourceFlag=@SourceFlag and RealNoticeDate is null"); SqlParameter[] param = { new SqlParameter("@CompanyCD",sellChanceModel.CompanyCD), new SqlParameter("@SourceFlag","4"), new SqlParameter("@SourceID",sellChanceModel.ID), new SqlParameter("@PlanNoticeDate",sellChanceModel.RemindTime) }; SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, strSqlMb.ToString(), param); } else { StringBuilder strSqlMb = new StringBuilder(); strSqlMb.Append("insert into officedba.NoticeHistory("); strSqlMb.Append(" CompanyCD,SourceFlag,SourceID,PlanNoticeDate ) "); strSqlMb.Append(" values(@CompanyCD, @SourceFlag,@SourceID,@PlanNoticeDate ) "); SqlParameter[] param = { new SqlParameter("@CompanyCD",sellChanceModel.CompanyCD), new SqlParameter("@SourceFlag","4"), new SqlParameter("@SourceID",sellChanceModel.ID), new SqlParameter("@PlanNoticeDate",sellChanceModel.RemindTime) }; SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, strSqlMb.ToString(), param); } } else { //若有未发送的记录则删除 if (IsExistedNoSendMsg(sellChanceModel.ID.ToString(), "0",sellChanceModel.CompanyCD)) { StringBuilder strSqlMb = new StringBuilder(); strSqlMb.Append("delete from officedba.NoticeHistory where SourceID=@SourceID and SourceFlag =@SourceFlag and CompanyCD=@CompanyCD "); SqlParameter[] param = { new SqlParameter("@CompanyCD",sellChanceModel.CompanyCD), new SqlParameter("@SourceFlag","4"), new SqlParameter("@SourceID",sellChanceModel.ID) }; SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, strSqlMb.ToString(), param); } } SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, strSql.ToString(), paras); InsertPush(tran, sellChancePushModel); tran.Commit(); isSucc = true; } catch (Exception ex) { tran.Rollback(); throw ex; } return isSucc; }
/// <summary> /// 为推进表更新数据 /// </summary> /// <param name="tran"></param> /// <param name="sellChancePushModel"></param> private static void InsertPush(TransactionManager tran, SellChancePushModel sellChancePushModel) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into officedba.SellChancePush("); strSql.Append("CompanyCD,ChanceNo,PushDate,Seller,Phase,State,Feasibility,DelayDate,Remark,ModifiedDate,ModifiedUserID)"); strSql.Append(" values ("); strSql.Append("@CompanyCD,@ChanceNo,@PushDate,@Seller,@Phase,@State,@Feasibility,@DelayDate,@Remark,getdate(),@ModifiedUserID)"); #region 参数 SqlParameter[] parameters = { new SqlParameter("@CompanyCD", SqlDbType.VarChar,8), new SqlParameter("@ChanceNo", SqlDbType.VarChar,50), new SqlParameter("@PushDate", SqlDbType.DateTime), new SqlParameter("@Seller", SqlDbType.Int,4), new SqlParameter("@Phase", SqlDbType.Char,1), new SqlParameter("@State", SqlDbType.Char,1), new SqlParameter("@Feasibility", SqlDbType.Int,4), new SqlParameter("@DelayDate", SqlDbType.Int,4), new SqlParameter("@Remark", SqlDbType.VarChar,1024), new SqlParameter("@ModifiedUserID", SqlDbType.VarChar,20)}; parameters[0].Value = sellChancePushModel.CompanyCD; parameters[1].Value = sellChancePushModel.ChanceNo; parameters[2].Value = sellChancePushModel.PushDate; parameters[3].Value = sellChancePushModel.Seller; parameters[4].Value = sellChancePushModel.Phase; parameters[5].Value = sellChancePushModel.State; parameters[6].Value = sellChancePushModel.Feasibility; parameters[7].Value = sellChancePushModel.DelayDate; parameters[8].Value = sellChancePushModel.Remark; parameters[9].Value = sellChancePushModel.ModifiedUserID; foreach (SqlParameter para in parameters) { if (para.Value == null) { para.Value = DBNull.Value; } } #endregion SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, strSql.ToString(), parameters); }