/// <summary> /// 修改客户单位,返回1成功 /// </summary> /// <param name="info">客户单位信息业务实体</param> /// <returns></returns> public int Update(Model.CrmStructure.MCrm info) { DbCommand cmd = _db.GetStoredProcCommand("proc_Crm_Update"); _db.AddOutParameter(cmd, "RetCode", DbType.Int32, 4); _db.AddInParameter(cmd, "CrmId", DbType.AnsiStringFixedLength, info.CrmId); _db.AddInParameter(cmd, "CompanyId", DbType.AnsiStringFixedLength, info.CompanyId); _db.AddInParameter(cmd, "AttachXML", DbType.String, CreateHeZuoXieYiXML(info.AttachModel)); _db.AddInParameter(cmd, "BanksXML", DbType.String, CreateBanksXML(info.BankList)); _db.AddInParameter(cmd, "LxrsXML", DbType.String, CreateLxrsXML(info.LinkManList)); _db.AddInParameter(cmd, "CountryId", DbType.Int32, info.CountryId); _db.AddInParameter(cmd, "ProvinceId", DbType.Int32, info.ProvinceId); _db.AddInParameter(cmd, "CityId", DbType.Int32, info.CityId); _db.AddInParameter(cmd, "DistrictId", DbType.Int32, info.CountyId); _db.AddInParameter(cmd, "CrmName", DbType.String, info.Name); _db.AddInParameter(cmd, "Address", DbType.String, info.Address); _db.AddInParameter(cmd, "JGCode", DbType.String, info.OrganizationCode); _db.AddInParameter(cmd, "DengJiBH", DbType.Int32, info.LevId); _db.AddInParameter(cmd, "FaRen", DbType.String, info.LegalRepresentative); _db.AddInParameter(cmd, "FaRenTelephone", DbType.String, info.LegalRepresentativePhone); _db.AddInParameter(cmd, "FaRenMobile", DbType.String, info.LegalRepresentativeMobile); _db.AddInParameter(cmd, "LicenseCode", DbType.String, info.License); _db.AddInParameter(cmd, "CaiWu", DbType.String, info.FinancialName); _db.AddInParameter(cmd, "CaiWuTelephone", DbType.String, info.FinancialPhone); _db.AddInParameter(cmd, "CaiWuMobile", DbType.String, info.FinancialMobile); _db.AddInParameter(cmd, "FanLiZehngCe", DbType.String, info.RebatePolicy); _db.AddInParameter(cmd, "ZeRenXiaoShouBH", DbType.AnsiStringFixedLength, info.SellerId); _db.AddInParameter(cmd, "BriefCode", DbType.String, info.BrevityCode); _db.AddInParameter(cmd, "QianKuanEDu", DbType.Decimal, info.AmountOwed); _db.AddInParameter(cmd, "ZhangLingQiXian", DbType.Int32, info.Deadline); _db.AddInParameter(cmd, "IsXieYi", DbType.AnsiStringFixedLength, info.IsSignContract ? "1" : "0"); _db.AddInParameter(cmd, "OperatorId", DbType.AnsiStringFixedLength, info.OperatorId); _db.AddInParameter(cmd, "XieYiFuJianType", DbType.Byte, EyouSoft.Model.EnumType.ComStructure.AttachItemType.客户合作协议); _db.AddInParameter(cmd, "LxrType", DbType.Byte, EyouSoft.Model.EnumType.ComStructure.LxrType.客户单位); int sqlExceptionCode = 0; try { DbHelper.RunProcedure(cmd, _db); } catch (System.Data.SqlClient.SqlException e) { sqlExceptionCode = 0 - e.Number; } if (sqlExceptionCode < 0) { return(sqlExceptionCode); } else { return(Convert.ToInt32(_db.GetParameterValue(cmd, "RetCode"))); } }
/// <summary> /// 修改客户单位,返回1成功 /// </summary> /// <param name="info">客户单位信息业务实体</param> /// <returns></returns> public int Update(Model.CrmStructure.MCrm info) { if (info == null || string.IsNullOrEmpty(info.CrmId)) { return(0); } if (string.IsNullOrEmpty(info.CompanyId)) { return(-1); } if (info.LinkManList == null || info.LinkManList.Count == 0) { return(-2); } if (info.BankList != null && info.BankList.Count > 0) { foreach (var item in info.BankList) { if (!string.IsNullOrEmpty(item.BankId)) { continue; } item.BankId = Guid.NewGuid().ToString(); } } foreach (var item in info.LinkManList) { if (!string.IsNullOrEmpty(item.Id)) { continue; } item.Id = Guid.NewGuid().ToString(); } int dalRetCode = dal.Update(info); if (dalRetCode == 1) { SysStructure.BSysLogHandle.Insert("修改客户单位信息,客户单位编号:" + info.CrmId + ",单位名称:" + info.Name + "。"); return(1); } return(dalRetCode); }
/// <summary> /// 获取客户单位信息业务实体 /// </summary> /// <param name="crmId">客户单位编号</param> /// <returns></returns> public Model.CrmStructure.MCrm GetInfo(string crmId) { Model.CrmStructure.MCrm info = null; DbCommand cmd = _db.GetSqlStringCommand(SQL_SELECT_GetInfo); _db.AddInParameter(cmd, "CrmId", DbType.AnsiStringFixedLength, crmId); using (IDataReader rdr = DbHelper.ExecuteReader(cmd, _db)) { if (rdr.Read()) { info = new EyouSoft.Model.CrmStructure.MCrm(); info.Address = rdr["Address"].ToString(); info.AmountOwed = rdr.GetDecimal(rdr.GetOrdinal("AmountOwed")); info.AttachModel = null; info.BankList = null; info.BrevityCode = rdr["BrevityCode"].ToString(); info.CityId = rdr.GetInt32(rdr.GetOrdinal("CityId")); info.CompanyId = rdr.GetString(rdr.GetOrdinal("CompanyId")); info.CountryId = rdr.GetInt32(rdr.GetOrdinal("CountryId")); info.CountyId = rdr.GetInt32(rdr.GetOrdinal("CountyId")); info.CrmId = crmId; info.Deadline = rdr.GetInt32(rdr.GetOrdinal("Deadline")); info.DeptId = rdr.GetInt32(rdr.GetOrdinal("DeptId")); info.FinancialMobile = rdr["FinancialMobile"].ToString(); info.FinancialName = rdr["FinancialName"].ToString(); info.FinancialPhone = rdr["FinancialPhone"].ToString(); info.IsDelete = rdr.GetString(rdr.GetOrdinal("IsDelete")) == "1"; info.IsSignContract = rdr.GetString(rdr.GetOrdinal("IsSignContract")) == "1"; info.IssueTime = rdr.GetDateTime(rdr.GetOrdinal("IssueTime")); info.LegalRepresentative = rdr["LegalRepresentative"].ToString(); info.LegalRepresentativeMobile = rdr["LegalRepresentativeMobile"].ToString(); info.LegalRepresentativePhone = rdr["LegalRepresentativePhone"].ToString(); info.LevId = rdr.GetInt32(rdr.GetOrdinal("LevId")); info.License = rdr["License"].ToString(); info.LinkManList = null; info.Name = rdr["Name"].ToString(); info.OperatorId = rdr.GetString(rdr.GetOrdinal("OperatorId")); info.OrganizationCode = rdr["OrganizationCode"].ToString(); info.PrintFooter = rdr["PrintFooter"].ToString(); info.PrintHeader = rdr["PrintHeader"].ToString(); info.PrintTemplates = rdr["PrintTemplates"].ToString(); info.ProvinceId = rdr.GetInt32(rdr.GetOrdinal("ProvinceId")); info.RebatePolicy = rdr["RebatePolicy"].ToString(); info.Seal = rdr["Seal"].ToString(); info.SellerId = rdr.GetString(rdr.GetOrdinal("SellerId")); info.SellerName = rdr["SellerName"].ToString(); info.Type = (EyouSoft.Model.EnumType.CrmStructure.CrmType)rdr.GetByte(rdr.GetOrdinal("Type")); } } if (info == null) { return(info); } info.BankList = GetCrmBanks(crmId); info.AttachModel = GetCrmXieYiFuJian(crmId); info.LinkManList = GetCrmLxrs(crmId); return(info); }