/// <summary> /// 添加客户联络信息的方法 /// </summary> /// <param name="ContactHistoryM">客户联络信息</param> /// <returns>返回bool值</returns> public static int ContactHistoryAdd(ContactHistoryModel ContactHistoryM) { UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"]; LogInfoModel logModel = new LogInfoModel(); //操作日志 int isSucc = 0;//定义返回变量 #region 设置操作日志内容 //设置公司代码 logModel.CompanyCD = userInfo.CompanyCD; //设置登陆用户ID logModel.UserID = userInfo.UserID; //设置模块ID 模块ID在ConstUtil中定义,以便维护 logModel.ModuleID = ConstUtil.MODULE_ID_CUST_CONTACT_ADD; //操作单据编号 联络编号 logModel.ObjectID = ContactHistoryM.ContactNo; //操作对象 操作的表信息 logModel.ObjectName = ConstUtil.TABLE_NAME_CONTACT; //涉及关键元素 涉及其他业务、表关系 logModel.Element = string.Empty; //备注 操作类型 logModel.Remark = ConstUtil.LOG_PROCESS_INSERT; #endregion try { isSucc = ContactHistoryDBHelper.ContactHistoryAdd(ContactHistoryM); } catch (System.Exception ex) { #region 操作失败时记录日志到文件 //定义变量 LogInfo logSys = new LogInfo(); //设置日志类型 需要指定为系统日志 logSys.Type = LogInfo.LogType.SYSTEM; //指定系统日志类型 出错信息 logSys.SystemKind = LogInfo.SystemLogKind.SYSTEM_ERROR; //指定登陆用户信息 logSys.UserInfo = userInfo; //设定模块ID logSys.ModuleID = ConstUtil.MODULE_ID_CUST_CONTACT_ADD; //描述 logSys.Description = ex.ToString(); //输出日志 LogUtil.WriteLog(logSys); #endregion } if (isSucc > 0)//操作成功 { logModel.Remark += "成功"; } else//操作失败 { logModel.Remark += "失败"; } //记录日志 LogDBHelper.InsertLog(logModel); return isSucc; }
/// <summary> /// 根据联络信息ID修改联络信息 /// </summary> /// <param name="ContactM">联络信息</param> /// <returns>操作记录数</returns> public static bool UpdateContact(ContactHistoryModel ContactM) { try { #region 拼写修改联系人信息SQL语句 StringBuilder sqlcontact = new StringBuilder(); sqlcontact.AppendLine("UPDATE officedba.CustContact set "); sqlcontact.AppendLine("CompanyCD = @CompanyCD, "); sqlcontact.AppendLine("CustID = @CustID, "); sqlcontact.AppendLine("CustLinkMan = @CustLinkMan, "); sqlcontact.AppendLine("Title = @Title, "); sqlcontact.AppendLine("LinkReasonID = @LinkReasonID, "); sqlcontact.AppendLine("LinkMode = @LinkMode, "); sqlcontact.AppendLine("LinkDate = @LinkDate, "); sqlcontact.AppendLine("Linker = @Linker, "); sqlcontact.AppendLine("Contents = @Contents, "); sqlcontact.AppendLine("CanViewUser = @CanViewUser, "); sqlcontact.AppendLine("CanViewUserName = @CanViewUserName, "); sqlcontact.AppendLine("ModifiedDate = @ModifiedDate, "); sqlcontact.AppendLine("ModifiedUserID = @ModifiedUserID "); sqlcontact.AppendLine(" WHERE "); sqlcontact.AppendLine("ID = @ID "); #endregion #region 设置修改联系人信息参数 SqlParameter[] param = new SqlParameter[14]; param[0] = SqlHelper.GetParameter("@ID", ContactM.ID); param[1] = SqlHelper.GetParameter("@CompanyCD", ContactM.CompanyCD); param[2] = SqlHelper.GetParameter("@CustID", ContactM.CustID); param[3] = SqlHelper.GetParameter("@CustLinkMan", ContactM.CustLinkMan); param[4] = SqlHelper.GetParameter("@Title", ContactM.Title); param[5] = SqlHelper.GetParameter("@LinkReasonID", ContactM.LinkReasonID); param[6] = SqlHelper.GetParameter("@LinkMode", ContactM.LinkMode); param[7] = SqlHelper.GetParameter("@LinkDate", ContactM.LinkDate == null ? SqlDateTime.Null : SqlDateTime.Parse(ContactM.LinkDate.ToString())); param[8] = SqlHelper.GetParameter("@Linker", ContactM.Linker); param[9] = SqlHelper.GetParameter("@Contents", ContactM.Contents); param[10] = SqlHelper.GetParameter("@ModifiedDate", ContactM.ModifiedDate == null ? SqlDateTime.Null : SqlDateTime.Parse(ContactM.ModifiedDate.ToString())); param[11] = SqlHelper.GetParameter("@ModifiedUserID", ContactM.ModifiedUserID); param[12] = SqlHelper.GetParameter("@CanViewUser", ContactM.CanViewUser); param[13] = SqlHelper.GetParameter("@CanViewUserName", ContactM.CanViewUserName); #endregion SqlHelper.ExecuteTransSql(sqlcontact.ToString(), param); return SqlHelper.Result.OprateCount > 0 ? true : false; } catch { return false; } }
/// <summary> /// 添加客户联络信息的方法 /// </summary> /// <param name="ContactHistoryM">客户联络信息</param> /// <returns>返回操作记录值</returns> public static int ContactHistoryAdd(ContactHistoryModel ContactHistoryM) { try { #region 设置参数 SqlParameter[] param = new SqlParameter[15]; param[0] = SqlHelper.GetParameter("@CompanyCD", ContactHistoryM.CompanyCD); param[1] = SqlHelper.GetParameter("@CustID", ContactHistoryM.CustID); param[2] = SqlHelper.GetParameter("@CustLinkMan", ContactHistoryM.CustLinkMan); param[3] = SqlHelper.GetParameter("@ContactNo", ContactHistoryM.ContactNo); param[4] = SqlHelper.GetParameter("@Title", ContactHistoryM.Title); param[5] = SqlHelper.GetParameter("@LinkReasonID", ContactHistoryM.LinkReasonID); param[6] = SqlHelper.GetParameter("@LinkMode", ContactHistoryM.LinkMode); param[7] = SqlHelper.GetParameter("@LinkDate", ContactHistoryM.LinkDate == null ? SqlDateTime.Null : SqlDateTime.Parse(ContactHistoryM.LinkDate.ToString())); param[8] = SqlHelper.GetParameter("@Linker", ContactHistoryM.Linker); param[9] = SqlHelper.GetParameter("@Contents", ContactHistoryM.Contents); param[10] = SqlHelper.GetParameter("@CanViewUser", ContactHistoryM.CanViewUser); param[11] = SqlHelper.GetParameter("@CanViewUserName", ContactHistoryM.CanViewUserName); param[12] = SqlHelper.GetParameter("@ModifiedDate", ContactHistoryM.ModifiedDate); param[13] = SqlHelper.GetParameter("@ModifiedUserID", ContactHistoryM.ModifiedUserID); SqlParameter paramid = new SqlParameter("@id", SqlDbType.Int); paramid.Direction = ParameterDirection.Output; param[14] = paramid; #endregion //创建命令 SqlCommand comm = new SqlCommand(); SqlHelper.ExecuteTransStoredProcedure("officedba.insertCustContact", comm, param); int contantid = Convert.ToInt32(comm.Parameters["@id"].Value); return contantid; } catch { return 0; } }
public static DataTable GetCustContactByCustID(ContactHistoryModel ContactHistoryM, int pageIndex, int pageCount, string ord, ref int TotalCount) { try { #region sql语句 StringBuilder strSql = new StringBuilder(); strSql.Append(" select a.ID,a.CompanyCD,a.CustID,a.Title Title_ll, "); strSql.Append(" Convert(varchar(20),a.LinkDate,23) LinkDate, "); strSql.Append(" b.LinkManName "); strSql.Append(" from officedba.CustContact a "); strSql.Append(" left join officedba.CustLinkMan b on b.ID = a.CustLinkMan "); strSql.Append(" where a.CustID = @CustID "); //定义查询的命令 SqlCommand comm = new SqlCommand(); //添加公司代码参数 comm.Parameters.Add(SqlHelper.GetParameterFromString("@CustID", ContactHistoryM.CustID.ToString())); #endregion comm.CommandText = strSql.ToString(); return SqlHelper.PagerWithCommand(comm, pageIndex, pageCount, ord, ref TotalCount); } catch (Exception ex) { string smeg = ex.Message; return null; } }
public static DataTable GetContactInfoBycondition(string CustName, string CustLinkMan, ContactHistoryModel ContactM, string LinkDateBegin, string txtLinkDateEnd, string ReasonId, int pageIndex, int pageCount, string ord, ref int TotalCount) { try { return ContactHistoryDBHelper.GetContactInfoBycondition(CustName, CustLinkMan, ContactM, LinkDateBegin, txtLinkDateEnd, ReasonId, pageIndex, pageCount, ord, ref TotalCount); } catch { return null; } }
/// <summary> /// 根据查询条件获取客户联络列表信息的方法 /// </summary> /// <param name="CustName">客户名称</param> /// <param name="CustClass">客户类型</param> /// <param name="ContactM">联络model</param> /// <param name="LinkDateBegin">开始时间</param> /// <param name="txtLinkDateEnd">结束时间</param> /// <returns>结果集</returns> public static DataTable GetContactInfoBycondition(string CustName, string CustLinkMan, ContactHistoryModel ContactM, string LinkDateBegin, string txtLinkDateEnd, string ReasonId, int pageIndex, int pageCount, string ord, ref int TotalCount) { try { string sql = "select c.ID,i.id custid,c.ContactNo,SubString(c.Title,1,12) Title,i.CustName CustNam," + " isnull(e.EmployeeName,'') Linker," + " isnull(CONVERT(varchar(100), c.LinkDate, 23),'') LinkDate,isnull(l.LinkManName,'') LinkManName " + " from " + " officedba.CustContact c " + " left join officedba.CustInfo i on c.custId = i.id" + " left join officedba.CustLinkMan l on l.id = c.CustLinkMan " + //" left join officedba.CodeCompanyType t on i.CustClass = t.id "+ " left join officedba.EmployeeInfo e on e.id = c.Linker " + " where " + " c.CompanyCD = '" + ContactM.CompanyCD + "'"; if (CustName != "") sql += " and i.id = '" + CustName + "'"; if (CustLinkMan != "") sql += " and e.id = '" + CustLinkMan + "'"; if (LinkDateBegin != "") sql += " and c.linkDate >= '" + LinkDateBegin.ToString() + "'"; if (txtLinkDateEnd != "") sql += " and c.linkDate <= '" + txtLinkDateEnd.ToString() + "'"; if (txtLinkDateEnd != "") sql += " and c.LinkReasonID = " + ReasonId.ToString() + " "; //return SqlHelper.ExecuteSql(sql); return SqlHelper.CreateSqlByPageExcuteSql(sql.ToString(), pageIndex, pageCount, ord, null, ref TotalCount); } catch { return null; } }
public static DataTable GetCustContactByCustID(ContactHistoryModel ContactHistoryM, int pageIndex, int pageCount, string ord, ref int TotalCount) { return CustCallDBHelper.GetCustContactByCustID(ContactHistoryM, pageIndex, pageCount, ord, ref TotalCount); }