/// <summary> /// 保存并新增报价 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void save_newAdd_Click(object sender, EventArgs e) { var param = GetParam(); string id = ""; if (isAdd) { var result = new OpportunityBLL().Insert(param, GetLoginUserId(), out id); // 根据参数插入商机 if (result == ERROR_CODE.PARAMS_ERROR) // 必填参数丢失,重写 { ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('必填参数丢失,请重新填写'); </script>"); //Response.Write("<script>alert('必填参数丢失,请重新填写'); </script>"); } else if (result == ERROR_CODE.USER_NOT_FIND) // 用户丢失 { Response.Write("<script>alert('查询不到用户,请重新登陆');</script>"); Response.Redirect("Login.aspx"); } else if (result == ERROR_CODE.SUCCESS) // 插入用户成功,刷新前一个页面 { if (!string.IsNullOrEmpty(callBackFiled)) { Response.Write("<script>debugger;window.opener." + callBackFiled + "('" + param.general.name + "','" + id + "');</script>"); } ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('添加商机成功!');self.opener.location.reload();window.close();window.open('../Quote/QuoteAddAndUpdate?quote_opportunity_id=" + id + "','" + (int)EMT.DoneNOW.DTO.OpenWindow.QuoteAdd + "','left= 200, top = 200, width = 960, height = 750', false);</script>"); //Response.Write("<script></script>"); //Response.Write("<script>alert('添加商机成功!');</script>"); // //Response.Redirect("../Quote/QuoteAddAndUpdate?opportunity_id="+id); } } else { param.general.id = opportunity.id; var result = new OpportunityBLL().Update(param, GetLoginUserId()); if (result == ERROR_CODE.PARAMS_ERROR) // 必填参数丢失,重写 { ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('必填参数丢失,请重新填写'); </script>"); } else if (result == ERROR_CODE.USER_NOT_FIND) // 用户丢失 { Response.Write("<script>alert('查询不到用户,请重新登陆');</script>"); Response.Redirect("Login.aspx"); } else if (result == ERROR_CODE.SUCCESS) // 插入用户成功,刷新前一个页面 { ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('修改商机成功!');self.opener.location.reload();window.close();window.open('../Quote/QuoteAddAndUpdate?quote_opportunity_id=" + opportunity.id + "','" + (int)EMT.DoneNOW.DTO.OpenWindow.QuoteAdd + "','left= 200, top = 200, width = 960, height = 750', false);</script>"); // Response.Redirect("../Quote/QuoteAddAndUpdate?quote_opportunity_id=" + opportunity.id); } } }
protected void finish_Click(object sender, EventArgs e) { var thisOppo = AssembleModel <crm_opportunity>(); opportunity.stage_id = thisOppo.stage_id; opportunity.resource_id = thisOppo.resource_id; opportunity.primary_product_id = thisOppo.primary_product_id; opportunity.competitor_id = thisOppo.competitor_id; opportunity.loss_reason_type_id = thisOppo.loss_reason_type_id; opportunity.loss_reason = thisOppo.loss_reason; var actual_closed_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); if (!string.IsNullOrEmpty(Request.Form["lostTime"])) { opportunity.actual_closed_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(Request.Form["lostTime"])); } //else // opportunity.actual_closed_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); // opportunity.resource_id = thisOppo.resource_id; // opportunity.resource_id = thisOppo.resource_id; LoseOpportunityDto dto = new LoseOpportunityDto() { opportunity = this.opportunity, notify = AssembleModel <com_notify_email>(), notifyTempId = !string.IsNullOrEmpty(Request.Form["notify_tmpl_id"]) ? int.Parse(Request.Form["notify_tmpl_id"]) : 0, }; var result = new OpportunityBLL().LoseOpportunity(dto, GetLoginUserId()); switch (result) { case ERROR_CODE.SUCCESS: ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>document.getElementsByClassName('Workspace1')[0].style.display = 'none';document.getElementsByClassName('Workspace4')[0].style.display = 'none';document.getElementsByClassName('Workspace5')[0].style.display = '';</script>"); break; case ERROR_CODE.ERROR: break; case ERROR_CODE.PARAMS_ERROR: ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('必填参数丢失,请重新填写');</script>"); break; case ERROR_CODE.USER_NOT_FIND: Response.Write("<script>alert('查询不到用户,请重新登陆');</script>"); Response.Redirect("../Login.aspx"); break; default: break; } }
/// <summary> /// 转移员工(更改员工的客户,商机,待办,活动) /// </summary> public bool TransResource(long fromResId, long toResId, long userId) { if (fromResId == toResId) { return(true); } var fromRes = GetResourceById(fromResId); var toRes = GetResourceById(toResId); if (fromRes == null || toRes == null) { return(false); } CompanyBLL accBll = new CompanyBLL(); List <crm_account> accList = accBll.GetBySql <crm_account>("SELECT * from crm_account a where a.delete_time =0 and a.resource_id = " + fromResId.ToString()); if (accList != null && accList.Count > 0) { accList.ForEach(_ => { _.resource_id = toResId; accBll.EditAccount(_, userId); }); } OpportunityBLL oppoBll = new OpportunityBLL(); List <crm_opportunity> oppoList = oppoBll.GetOppoBySql($"SELECT * from crm_opportunity where delete_time =0 and resource_id = {fromResId.ToString()} and status_id not in ({(int)DicEnum.OPPORTUNITY_STATUS.LOST},{(int)DicEnum.OPPORTUNITY_STATUS.CLOSED},{(int)DicEnum.OPPORTUNITY_STATUS.IMPLEMENTED})"); if (oppoList != null && oppoList.Count > 0) { oppoList.ForEach(_ => { _.resource_id = toResId; oppoBll.EdotOpportunity(_, userId); }); } ActivityBLL actBll = new ActivityBLL(); List <com_activity> actList = actBll.GetToListBySql($"select id,name,description from com_activity where delete_time =0 and resource_id = {fromResId.ToString()} and (status_id <> {(int)DicEnum.ACTIVITY_STATUS.COMPLETED} or status_id is null)"); if (actList != null && actList.Count > 0) { actList.ForEach(_ => { _.resource_id = toResId; actBll.EditActivity(_, userId); }); } return(true); }
/// <summary> /// 删除商机处理 /// </summary> /// <param name="context"></param> /// <param name="opportunity_id"></param> public void DeleteOpportunity(HttpContext context, long opportunity_id) { if (AuthBLL.GetUserOppAuth(LoginUserId, LoginUser.security_Level_id, opportunity_id).CanDelete == false) { return; } var result = new OpportunityBLL().DeleteOpportunity(opportunity_id, LoginUserId); if (result) { context.Response.Write("删除商机成功!"); } else { context.Response.Write("删除商机失败!"); } }
/// <summary> /// 根据合同Id获取相关信息,用横线隔开 /// </summary> public void GetSerList(HttpContext context, long contract_id) { var contract = new ctt_contract_dal().FindNoDeleteById(contract_id); if (contract != null) { var serviceList = new ctt_contract_service_dal().GetConSerList(contract.id); if (serviceList != null && serviceList.Count > 0) { StringBuilder services = new StringBuilder(); var oppBLL = new OpportunityBLL(); var serList = serviceList.Where(_ => _.object_type == 1).ToList(); var serBagList = serviceList.Where(_ => _.object_type == 2).ToList(); if (serList != null && serList.Count > 0) { foreach (var item in serList) { var name = oppBLL.ReturnServiceName(item.object_id); services.Append("<option value='" + item.id + "'>" + name + "</option>"); } if (serBagList != null && serBagList.Count > 0) { services.Append("<option>-------</option>"); } } if (serBagList != null && serBagList.Count > 0) { foreach (var item in serBagList) { var name = oppBLL.ReturnServiceName(item.object_id); services.Append("<option value='" + item.id + "'>" + name + "</option>"); } } context.Response.Write(services); } } }
/// <summary> /// 保存不关闭 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void save_Click(object sender, EventArgs e) { //var param = new OpportunityAddOrUpdateDto() //{ // general = AssembleModel<crm_opportunity>(), // notify = AssembleModel<com_notify_email>(), //}; //if (opportunity_udfList != null && opportunity_udfList.Count > 0) // 首先判断是否有自定义信息 //{ // var list = new List<UserDefinedFieldValue>(); // foreach (var udf in opportunity_udfList) // 循环添加 // { // var new_udf = new UserDefinedFieldValue() // { // id = udf.id, // value = Request.Form[udf.id.ToString()] == "" ? null : Request.Form[udf.id.ToString()], // }; // list.Add(new_udf); // } // param.udf = list; //} var param = GetParam(); if (isAdd) { var id = ""; var result = new OpportunityBLL().Insert(param, GetLoginUserId(), out id); // 根据参数插入商机 if (result == ERROR_CODE.PARAMS_ERROR) // 必填参数丢失,重写 { ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('必填参数丢失,请重新填写'); </script>"); //Response.Write("<script>alert('必填参数丢失,请重新填写'); </script>"); } else if (result == ERROR_CODE.USER_NOT_FIND) // 用户丢失 { Response.Write("<script>alert('查询不到用户,请重新登陆');</script>"); Response.Redirect("Login.aspx"); } else if (result == ERROR_CODE.SUCCESS) // 插入用户成功,刷新前一个页面 { // Response.Write("<script>alert('添加商机成功!');window.location.href=window.location.href;</script>"); // if (!string.IsNullOrEmpty(callBackFiled)) { Response.Write("<script>window.opener." + callBackFiled + "('" + param.general.name + "','" + id + "');</script>"); } ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('添加商机成功!');location.href='OpportunityAddAndEdit.aspx?opportunity_id=" + id + "';</script>"); //Response.Redirect("../Opportunity/OpportunityAddAndEdit.aspx?opportunity_id=" + id); } } else { param.general.id = opportunity.id; var result = new OpportunityBLL().Update(param, GetLoginUserId()); if (result == ERROR_CODE.PARAMS_ERROR) // 必填参数丢失,重写 { ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('必填参数丢失,请重新填写'); </script>"); } else if (result == ERROR_CODE.USER_NOT_FIND) // 用户丢失 { Response.Write("<script>alert('查询不到用户,请重新登陆');</script>"); Response.Redirect("Login.aspx"); } else if (result == ERROR_CODE.SUCCESS) // 插入用户成功,刷新前一个页面 { ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('修改商机成功!');location.href='OpportunityAddAndEdit.aspx?opportunity_id=" + opportunity.id + "';</script>"); //Response.Redirect("../Opportunity/OpportunityAddAndEdit.aspx?opportunity_id=" + opportunity.id); //Response.Write("<script>alert('修改商机成功!');window.close();</script>"); // 关闭添加页面的同时,刷新父页面 } } }
private crm_quote_item GetParam(out Dictionary <long, int> wareDic) { var quote_item = AssembleModel <crm_quote_item>(); quote_item.optional = Convert.ToUInt64(_optional.Checked ? 1 : 0); quote_item.period_type_id = quote_item.period_type_id == 0 ? null : quote_item.period_type_id; if (isAdd) { quote_item.type_id = int.Parse(Request.Form["ItemTypeId"]); quote_item.quote_id = int.Parse(Request.QueryString["quote_id"]); } else { quote_item.type_id = this.quote_item.type_id; quote_item.create_time = this.quote_item.create_time; quote_item.create_user_id = this.quote_item.create_user_id; quote_item.update_time = this.quote_item.update_time; quote_item.update_user_id = this.quote_item.update_user_id; quote_item.id = this.quote_item.id; quote_item.quote_id = this.quote_item.quote_id; quote_item.oid = this.quote_item.oid; } wareDic = new Dictionary <long, int>(); switch (quote_item.type_id) { case (int)QUOTE_ITEM_TYPE.WORKING_HOURS: break; case (int)QUOTE_ITEM_TYPE.COST: break; case (int)QUOTE_ITEM_TYPE.DEGRESSION: break; case (int)QUOTE_ITEM_TYPE.DISCOUNT: break; case (int)QUOTE_ITEM_TYPE.PRODUCT: var wareIds = Request.Form["wareIds"]; if (!string.IsNullOrEmpty(wareIds)) { var wareIdArr = wareIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var wareId in wareIdArr) { var thisAvailable = Request.Form[wareId + "_available"]; var hand = Request.Form[wareId + "_hand"]; var use = Request.Form[wareId + "_use"]; if (!string.IsNullOrEmpty(thisAvailable)) { wareDic.Add(long.Parse(wareId), int.Parse(thisAvailable)); } } } break; case (int)QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES: break; case (int)QUOTE_ITEM_TYPE.SERVICE: var opBLL = new OpportunityBLL(); if (quote_item.object_id != null) { if (opBLL.isServiceOrBag((long)quote_item.object_id) == 1) { var service = new ivt_service_dal().GetSinService((long)quote_item.object_id); if (service != null) { quote_item.period_type_id = service.period_type_id; } } else if (opBLL.isServiceOrBag((long)quote_item.object_id) == 2) { var serviceBundle = new ivt_service_bundle_dal().GetSinSerBun((long)quote_item.object_id); if (serviceBundle != null) { quote_item.period_type_id = serviceBundle.period_type_id; } } } break; case (int)QUOTE_ITEM_TYPE.START_COST: quote_item.period_type_id = (int)QUOTE_ITEM_PERIOD_TYPE.ONE_TIME; break; default: break; } return(quote_item); }
protected string GetDetailByAccount(long accId) { StringBuilder html = new StringBuilder(); crm_account thisAccount = accBll.GetCompany(accId); if (thisAccount == null) { return(""); } // html.Append("<div class='workspace'>"); #region 客户信息-地址信息 html.Append($"<p align='left' style='padding-left: 10px;' class='FieldLabels'>{thisAccount.name}"); if (!string.IsNullOrEmpty(thisAccount.phone)) { html.Append($"<span style='font-weight:normal;'> {thisAccount.phone} </span ><br />"); } else { html.Append($"<br />"); } var location = new LocationBLL().GetLocationByAccountId(accId); if (location != null) { if (!string.IsNullOrEmpty(location.address)) { html.Append($"<span style='font-weight:normal;'>{location.address} </span ><br />"); } if (!string.IsNullOrEmpty(location.additional_address)) { html.Append($"<span style='font-weight:normal;'>{location.additional_address} </span ><br />"); } var ddDal = new DAL.d_district_dal(); var thisPro = ddDal.FindById(location.province_id); if (thisPro != null) { html.Append($"<span style='font-weight:normal;'>{thisPro.name} </span > "); } var thisCity = ddDal.FindById(location.city_id); if (thisCity != null) { html.Append($"<span style='font-weight:normal;'>{thisCity.name} </span > "); } if (location.district_id != null) { var thisDis = ddDal.FindById((long)location.district_id); if (thisDis != null) { html.Append($"<span style='font-weight:normal;'>{thisDis.name} </span ><br />"); } } if (location.country_id != null) { var thisCoun = new DAL.d_country_dal().FindById((long)location.country_id); if (thisCoun != null) { html.Append($"<span style='font-weight:normal;'>{thisCoun.country_name_display} </span ><br />"); } } } html.Append("</p>"); #endregion html.Append("<div style='padding-left: 10px;'><table cellspacing='0' cellpadding='4' border='0' class='FieldLabels'><tbody>"); #region 联系人信息 html.Append("<tr><td align='left'>客户</td></tr>"); List <crm_contact> contactList = new ContactBLL().GetContactByCompany(accId); if (contactList != null && contactList.Count > 0) { contactList.ForEach(_ => { html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>{_.name}-手机号 : {_.phone}</td></tr>"); }); } #endregion #region 商机信息 html.Append("<tr><td align='left' style='padding-top:20px;'>商机</td></tr>"); List <crm_opportunity> oppoList = new OpportunityBLL().GetOppoBySql($"SELECT id,name from crm_opportunity where delete_time =0 and account_id = {accId.ToString()} "); // and status_id not in ({(int)DicEnum.OPPORTUNITY_STATUS.LOST},{(int)DicEnum.OPPORTUNITY_STATUS.CLOSED},{(int)DicEnum.OPPORTUNITY_STATUS.IMPLEMENTED}) if (oppoList != null && oppoList.Count > 0) { oppoList.ForEach(_ => { html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>{_.name}</td></tr>"); }); } #endregion #region 销售订单信息 销售订单没有name 使用商机name html.Append("<tr><td align='left' style='padding-top:20px;'>销售订单</td></tr>"); List <crm_opportunity> saleList = accBll.GetBySql <crm_opportunity>($"SELECT s.id,p.name from crm_sales_order s INNER JOIN crm_opportunity p on s.opportunity_id = p.id where s.delete_time = 0 and p.delete_time =0 and p.account_id = {accId.ToString()} "); if (saleList != null && saleList.Count > 0) { saleList.ForEach(_ => { html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>{_.name}</td></tr>"); }); } #endregion #region 采购订单信息 html.Append("<tr><td align='left' style='padding-top:20px;'>采购订单</td></tr>"); List <ivt_order> orderList = accBll.GetBySql <ivt_order>($"SELECT v.id from ivt_order v where v.delete_time = 0 and v.vendor_account_id = {accId.ToString()} "); html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>这个客户有{(orderList!=null? orderList.Count:0)}个采购订单</td></tr>"); #endregion #region 待办信息 html.Append("<tr><td align='left' style='padding-top:20px;'>待办</td></tr>"); List <com_activity> todoList = new ActivityBLL().GetToListBySql($"select id,name,description from com_activity where delete_time =0 and cate_id = {(int)DicEnum.ACTIVITY_CATE.TODO} and account_id = {accId.ToString()} and (status_id <> {(int)DicEnum.ACTIVITY_STATUS.COMPLETED} or status_id is null)"); if (todoList != null && todoList.Count > 0) { todoList.ForEach(_ => { html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>{_.description}</td></tr>"); }); } #endregion #region 活动信息 html.Append("<tr><td align='left' style='padding-top:20px;'>活动</td></tr>"); List <com_activity> actList = new ActivityBLL().GetToListBySql($"select id,name,description from com_activity where delete_time =0 and cate_id <> {(int)DicEnum.ACTIVITY_CATE.TODO} and account_id = {accId.ToString()} and (status_id <> {(int)DicEnum.ACTIVITY_STATUS.COMPLETED} or status_id is null)"); html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>这个客户有{(actList != null ? actList.Count : 0)}个活动</td></tr>"); #endregion #region 配置项信息 html.Append("<tr><td align='left' style='padding-top:20px;'>配置项</td></tr>"); List <ivt_product> insProList = accBll.GetBySql <ivt_product>($"SELECT i.id,p.name from crm_installed_product i INNER JOIN ivt_product p on i.product_id = p.id and i.delete_time =0 and p.delete_time =0 and i.account_id = {accId.ToString()}"); if (insProList != null && insProList.Count > 0) { insProList.ForEach(_ => { html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>{_.name}</td></tr>"); }); } #endregion #region 项目信息 html.Append("<tr><td align='left' style='padding-top:20px;'>项目</td></tr>"); List <pro_project> proList = accBll.GetBySql <pro_project>($"SELECT id,name from pro_project where delete_time= 0 and account_id = {accId.ToString()}"); if (proList != null && proList.Count > 0) { proList.ForEach(_ => { html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>{_.name}</td></tr>"); }); } #endregion #region 费用信息 html.Append("<tr><td align='left' style='padding-top:20px;'>费用</td></tr>"); List <sdk_expense> expList = accBll.GetBySql <sdk_expense>($"SELECT id from sdk_expense where delete_time= 0 and account_id = {accId.ToString()}"); html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>这个客户有{(expList != null ? expList.Count : 0)}个费用</td></tr>"); #endregion #region 工单信息 html.Append("<tr><td align='left' style='padding-top:20px;'>工单</td></tr>"); List <sdk_task> ticketList = accBll.GetBySql <sdk_task>($"SELECT id from sdk_task where type_id = 1809 and delete_time = 0 and account_id = {accId.ToString()}"); html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>这个客户有{(ticketList != null ? ticketList.Count : 0)}个工单</td></tr>"); #endregion #region 调查问卷信息 #endregion #region 任务或工单备注信息 html.Append("<tr><td align='left' style='padding-top:20px;'>任务或工单备注</td></tr>"); List <sdk_task> taskList = accBll.GetBySql <sdk_task>($"SELECT id from sdk_task where type_id = 1807 and delete_time = 0 and account_id = {accId.ToString()}"); List <com_activity> taskNoteList = accBll.GetBySql <com_activity>($"SELECT * from com_activity where delete_time =0 and cate_id = 1500 and account_id = {accId.ToString()}"); html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>这个客户有{((taskList != null ? taskList.Count : 0)+(taskNoteList != null ? taskNoteList.Count : 0))}个任务或工单备注</td></tr>"); #endregion #region 备注信息 html.Append("<tr><td align='left' style='padding-top:20px;'>备注</td></tr>"); List <com_activity> noteList = accBll.GetBySql <com_activity>($"SELECT * from com_activity where delete_time =0 and cate_id = 31 and account_id = {accId.ToString()}"); if (noteList != null && noteList.Count > 0) { noteList.ForEach(_ => { html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>{_.name}</td></tr>"); }); } #endregion #region 合同信息 html.Append("<tr><td align='left' style='padding-top:20px;'>合同</td></tr>"); List <ctt_contract> contractList = accBll.GetBySql <ctt_contract>($"SELECT id, name from ctt_contract where delete_time = 0 and account_id = { accId.ToString()}"); if (contractList != null && contractList.Count > 0) { contractList.ForEach(_ => { html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>{_.name}</td></tr>"); }); } #endregion #region 附件信息 html.Append("<tr><td align='left' style='padding-top:20px;'>附件</td></tr>"); List <com_attachment> attList = accBll.GetBySql <com_attachment>($"SELECT id from com_attachment where delete_time =0 and account_id = { accId.ToString()}"); html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>这个客户有{(attList != null ? attList.Count : 0)}个附件</td></tr>"); #endregion #region 务信息 html.Append("<tr><td align='left' style='padding-top:20px;'>服务</td></tr>"); List <ivt_service> serviceList = accBll.GetBySql <ivt_service>($"SELECT id,name from ivt_service where delete_time = 0 and vendor_account_id = { accId.ToString()}"); if (serviceList != null && serviceList.Count > 0) { serviceList.ForEach(_ => { html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>{_.name}</td></tr>"); }); } #endregion html.Append("</tbody></table></div>"); html.Append("</div>"); return(html.ToString()); }
protected void Page_Load(object sender, EventArgs e) { var contract_id = Convert.ToInt64(Request.QueryString["id"]); thisBookMark = new IndexBLL().GetSingBook(Request.RawUrl, LoginUserId); contract = bll.GetContractEdit(contract_id); Dictionary <string, object> dics = bll.GetField(); contractCate = dics["cate"] as List <DictionaryEntryDto>; periodType = dics["periodType"] as List <DictionaryEntryDto>; billPostType = dics["billPostType"] as List <DictionaryEntryDto>; contractTypeName = bll.GetContractTypeName(contract.contract.type_id); slaList = bll.GetSLAList(); udfList = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.CONTRACTS); udfValues = new UserDefinedFieldsBLL().GetUdfValue(DicEnum.UDF_CATE.CONTRACTS, contract_id, udfList); if (!IsPostBack) { // 绑定联系人列表 var contactList = new ContactBLL().GetContactByCompany(contract.contract.account_id); contact_id.DataTextField = "name"; contact_id.DataValueField = "id"; contact_id.DataSource = contactList; contact_id.DataBind(); if (contract.contract.contact_id == null) { contact_id.Items.Insert(0, new ListItem() { Value = "", Text = " ", Selected = true }); } else { contact_id.Items.Insert(0, new ListItem() { Value = "", Text = " " }); contact_id.SelectedValue = ((long)contract.contract.contact_id).ToString(); } // 绑定商机列表 var oppList = new OpportunityBLL().GetOpportunityByCompany(contract.contract.account_id); opportunity_id.DataTextField = "name"; opportunity_id.DataValueField = "id"; opportunity_id.DataSource = oppList; opportunity_id.DataBind(); if (contract.contract.opportunity_id == null) { opportunity_id.Items.Insert(0, new ListItem() { Value = "", Text = " ", Selected = true }); } else { opportunity_id.Items.Insert(0, new ListItem() { Value = "", Text = " " }); opportunity_id.SelectedValue = ((long)contract.contract.opportunity_id).ToString(); } // 绑定通知联系人列表 if (contract.contract.type_id == (int)DicEnum.CONTRACT_TYPE.SERVICE) { if (contract.contract.bill_to_account_id == null) { bill_to_contact_id.Enabled = false; } else { var billContact = new ContactBLL().GetContactByCompany(contract.contract.account_id); bill_to_contact_id.DataTextField = "name"; bill_to_contact_id.DataValueField = "id"; bill_to_contact_id.DataSource = billContact; bill_to_contact_id.DataBind(); if (contract.contract.bill_to_contact_id == null) { bill_to_contact_id.Items.Insert(0, new ListItem() { Value = "", Text = " ", Selected = true }); } else { bill_to_contact_id.Items.Insert(0, new ListItem() { Value = "", Text = " " }); bill_to_contact_id.SelectedValue = ((long)contract.contract.bill_to_contact_id).ToString(); } } } else { if (contract.contract.bill_to_account_id == null) { bill_to_contact_id1.Enabled = false; } else { var billContact = new ContactBLL().GetContactByCompany(contract.contract.account_id); bill_to_contact_id1.DataTextField = "name"; bill_to_contact_id1.DataValueField = "id"; bill_to_contact_id1.DataSource = billContact; bill_to_contact_id1.DataBind(); if (contract.contract.bill_to_contact_id == null) { bill_to_contact_id1.Items.Insert(0, new ListItem() { Value = "", Text = " ", Selected = true }); } else { bill_to_contact_id1.Items.Insert(0, new ListItem() { Value = "", Text = " " }); bill_to_contact_id1.SelectedValue = ((long)contract.contract.bill_to_contact_id).ToString(); } } } } else { SaveClose_Click(); } }
protected void Page_Load(object sender, EventArgs e) { try { var dic = new OpportunityBLL().GetField(); #region 拉框赋值 stage_id.DataTextField = "show"; stage_id.DataValueField = "val"; stage_id.DataSource = dic.FirstOrDefault(_ => _.Key == "opportunity_stage").Value; stage_id.DataBind(); resource_id.DataTextField = "show"; resource_id.DataValueField = "val"; resource_id.DataSource = dic.FirstOrDefault(_ => _.Key == "sys_resource").Value; resource_id.DataBind(); //opportunity_id.DataTextField = "name"; //opportunity_id.DataValueField = "id"; //opportunity_id.DataSource = new crm_opportunity_dal().FindOpHistoryByAccountId(opportunity.account_id); //opportunity_id.DataBind(); loss_reason_type_id.DataTextField = "show"; loss_reason_type_id.DataValueField = "val"; loss_reason_type_id.DataSource = dic.FirstOrDefault(_ => _.Key == "oppportunity_loss_reason_type").Value; loss_reason_type_id.DataBind(); loss_reason_type_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); // competition competitor_id competitor_id.DataTextField = "show"; competitor_id.DataValueField = "val"; competitor_id.DataSource = dic.FirstOrDefault(_ => _.Key == "competition").Value; competitor_id.DataBind(); competitor_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); #endregion var account_id = Request.QueryString["account_id"]; var opportunityId = Request.QueryString["id"]; if (!string.IsNullOrEmpty(opportunityId)) { if (string.IsNullOrEmpty(account_id)) { if (!IsPostBack) { opportunity_id.Enabled = false; } } opportunity = new crm_opportunity_dal().GetOpportunityById(long.Parse(opportunityId)); if (opportunity != null) { account = new CompanyBLL().GetCompany(opportunity.account_id); account_id = account.id.ToString(); ownRes = new UserResourceBLL().GetResourceById(opportunity.resource_id); } } if (!string.IsNullOrEmpty(account_id)) { account = new CompanyBLL().GetCompany(long.Parse(account_id)); var oppoList = new crm_opportunity_dal().FindOpHistoryByAccountId(long.Parse(account_id)); if (oppoList != null && oppoList.Count > 0) { opportunity_id.DataTextField = "name"; opportunity_id.DataValueField = "id"; opportunity_id.DataSource = oppoList; opportunity_id.DataBind(); } else { Response.Write("<script>alert('该客户还没有商机!');window.close();</script>"); } if (string.IsNullOrEmpty(opportunityId)) { opportunity = oppoList[0]; } opportunity_id.SelectedValue = opportunity.id.ToString(); } if (opportunity == null) { Response.End(); } // 商机已经关闭,丢失提示信息 if (!IsPostBack) { if (opportunity.status_id == (int)OPPORTUNITY_STATUS.CLOSED) { Response.Write("<script>alert('商机已关闭,继续则以前创建的已确认计费项和合同不会受影响!');</script>"); Response.Write("<script>if(!confirm('本操作将会改变商机状态,相关的销售订单将被取消,是否继续?')){window.close();}</script>"); } } stage_id.SelectedValue = opportunity.stage_id == null ? "0" : opportunity.stage_id.ToString(); resource_id.SelectedValue = opportunity.resource_id.ToString(); opportunity_id.SelectedValue = opportunity.id.ToString(); competitor_id.SelectedValue = opportunity.competitor_id == null ? "0" : opportunity.competitor_id.ToString(); } catch (Exception) { Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { thisBookMark = new IndexBLL().GetSingBook(Request.RawUrl, LoginUserId); actionTypeList = bll.GetCRMActionType(); resourceList = new UserResourceBLL().GetResourceList(); if (!IsPostBack) { long noteid; if (!string.IsNullOrEmpty(Request.QueryString["id"]) && long.TryParse(Request.QueryString["id"], out noteid)) { if (AuthBLL.GetUserNoteAuth(LoginUserId, LoginUser.security_Level_id, noteid).CanEdit == false) { Response.Write("<script>alert('您不能编辑此备注');</script>"); Response.End(); return; } note = bll.GetActivity(noteid); contactList = new ContactBLL().GetContactByCompany((long)note.account_id); opportunityList = new OpportunityBLL().GetOpportunityByCompany((long)note.account_id); var accountName = ""; if (note.account_id != null) { var account = new CompanyBLL().GetCompany((long)note.account_id); accountName = account == null ? "" : account.name; } var history = new sys_windows_history() { title = "备注:" + note.description + ":" + accountName, url = Request.RawUrl, }; new IndexBLL().BrowseHistory(history, LoginUserId); } if (long.TryParse(Request.QueryString["accountId"], out accountId)) { objType = (int)DicEnum.OBJECT_TYPE.CUSTOMER; objId = accountId; } if (long.TryParse(Request.QueryString["contactId"], out contactId)) { accountId = new ContactBLL().GetContact(contactId).account_id; objType = (int)DicEnum.OBJECT_TYPE.CONTACT; objId = contactId; } if (long.TryParse(Request.QueryString["opportunityId"], out opportunityId)) { objType = (int)DicEnum.OBJECT_TYPE.OPPORTUNITY; objId = opportunityId; var opp = new OpportunityBLL().GetOpportunity(opportunityId).general; accountId = opp.account_id; if (opp.contact_id != null) { contactId = (long)opp.contact_id; } } if (long.TryParse(Request.QueryString["saleorderId"], out saleOrderId)) { objType = (int)DicEnum.OBJECT_TYPE.SALEORDER; objId = saleOrderId; var saleOrder = new SaleOrderBLL().GetSaleOrder(saleOrderId); var opp = new OpportunityBLL().GetOpportunity(saleOrder.opportunity_id).general; opportunityId = opp.id; accountId = opp.account_id; if (opp.contact_id != null) { contactId = (long)opp.contact_id; } } } else { com_activity activity = AssembleModel <com_activity>(); if (activity.contact_id == 0) { activity.contact_id = null; } activity.start_date = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(Request.Form["start_date2"])); activity.end_date = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(Request.Form["end_date2"])); com_activity todo = null; if (!string.IsNullOrEmpty(Request.Form["action_type_id1"])) { todo = new com_activity(); todo.action_type_id = int.Parse(Request.Form["action_type_id1"]); todo.start_date = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(Request.Form["start_date1"])); todo.end_date = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(Request.Form["end_date1"])); todo.description = Request.Form["description1"]; if (!string.IsNullOrEmpty(Request.Form["resource_id1"])) { todo.resource_id = long.Parse(Request.Form["resource_id1"]); } } if (string.IsNullOrEmpty(Request.Form["id"])) { bll.AddCRMNote(activity, todo, GetLoginUserId()); } else { bll.EditCRMNote(activity, todo, GetLoginUserId()); } if (Request.Form["action"] != null && Request.Form["action"].Equals("SaveNew")) { Response.Write("<script>alert('保存备注成功');window.location.href='Notes.aspx';self.opener.location.reload();</script>"); } else { Response.Write("<script>alert('保存备注成功');window.close();self.opener.location.reload();</script>"); } } }
protected string GetDetailByContact(long conId) { StringBuilder html = new StringBuilder(); crm_contact thisContact = conBll.GetContact(conId); if (thisContact == null) { return(""); } html.Append("<div class='workspace'>"); html.Append("<div style='padding-left: 10px;'><table cellspacing='0' cellpadding='4' border='0' class='FieldLabels'><tbody>"); // #region 商机信息 html.Append("<tr><td align='left' style='padding-top:20px;'>商机</td></tr>"); List <crm_opportunity> oppoList = new OpportunityBLL().GetOppoBySql($"SELECT id,name from crm_opportunity where delete_time =0 and contact_id = {conId.ToString()} "); // and status_id not in ({(int)DicEnum.OPPORTUNITY_STATUS.LOST},{(int)DicEnum.OPPORTUNITY_STATUS.CLOSED},{(int)DicEnum.OPPORTUNITY_STATUS.IMPLEMENTED}) if (oppoList != null && oppoList.Count > 0) { oppoList.ForEach(_ => { html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>{_.name}</td></tr>"); }); } else { html.Append($"<tr><td class='errorSmall' align='left' style='padding-left:10px;text-align:left;font-weight :normal;'>该联系人下没有商机</td></tr>"); } #endregion #region 销售订单信息 销售订单没有name 使用商机name html.Append("<tr><td align='left' style='padding-top:20px;'>销售订单</td></tr>"); List <crm_opportunity> saleList = accBll.GetBySql <crm_opportunity>($"SELECT s.id,p.name from crm_sales_order s INNER JOIN crm_opportunity p on s.opportunity_id = p.id where s.delete_time = 0 and p.delete_time =0 and s.contact_id = {conId.ToString()} "); if (saleList != null && saleList.Count > 0) { saleList.ForEach(_ => { html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>{_.name}</td></tr>"); }); } else { html.Append($"<tr><td class='errorSmall' align='left' style='padding-left:10px;text-align:left;font-weight :normal;'>该联系人下没有销售订单</td></tr>"); } #endregion #region 待办信息 html.Append("<tr><td align='left' style='padding-top:20px;'>待办</td></tr>"); List <com_activity> todoList = new ActivityBLL().GetToListBySql($"select id,name,description from com_activity where delete_time =0 and cate_id = {(int)DicEnum.ACTIVITY_CATE.TODO} and contact_id = {conId.ToString()} and (status_id <> {(int)DicEnum.ACTIVITY_STATUS.COMPLETED} or status_id is null)"); if (todoList != null && todoList.Count > 0) { todoList.ForEach(_ => { html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>{_.description}</td></tr>"); }); } else { html.Append($"<tr><td class='errorSmall' align='left' style='padding-left:10px;text-align:left;font-weight :normal;'>该联系人下没有待办</td></tr>"); } #endregion #region 活动信息 html.Append("<tr><td align='left' style='padding-top:20px;'>活动</td></tr>"); List <com_activity> actList = new ActivityBLL().GetToListBySql($"select id,name,description from com_activity where delete_time =0 and cate_id <> {(int)DicEnum.ACTIVITY_CATE.TODO} and contact_id = {conId.ToString()} and (status_id <> {(int)DicEnum.ACTIVITY_STATUS.COMPLETED} or status_id is null)"); if (actList != null && actList.Count > 0) { actList.ForEach(_ => { html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>{_.description}</td></tr>"); }); } else { html.Append($"<tr><td class='errorSmall' align='left' style='padding-left:10px;text-align:left;font-weight :normal;'>该联系人下没有活动</td></tr>"); } #endregion #region 工单信息 html.Append("<tr><td align='left' style='padding-top:20px;'>工单</td></tr>"); List <sdk_task> ticketList = accBll.GetBySql <sdk_task>($"SELECT id from sdk_task where type_id = 1809 and delete_time = 0 and contact_id = {conId.ToString()}"); if (ticketList != null && ticketList.Count > 0) { ticketList.ForEach(_ => { html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>{_.no}-{_.title}</td></tr>"); }); } else { html.Append($"<tr><td class='errorSmall' align='left' style='padding-left:10px;text-align:left;font-weight :normal;'>该联系人下没有工单</td></tr>"); } #endregion #region 调查问卷信息 #endregion #region 任务信息 html.Append("<tr><td align='left' style='padding-top:20px;'>任务</td></tr>"); List <sdk_task> taskList = accBll.GetBySql <sdk_task>($"SELECT t.id,t.title,p.name as description from sdk_task t INNER JOIN pro_project p where t.type_id = 1807 and t.delete_time = 0 and p.delete_time =0 and t.contact_id = {conId.ToString()}"); // if (taskList != null && taskList.Count > 0) { taskList.ForEach(_ => { html.Append($"<tr><td style='padding-left:10px;'>项目: <span style='font-weight :normal;'>{_.description}</span> <br> 任务: < span style='font-weight :normal;'>{_.title}</span></td></tr>"); }); } else { html.Append($"<tr><td class='errorSmall' align='left' style='padding-left:10px;text-align:left;font-weight :normal;'>该联系人下没有任务</td></tr>"); } #endregion #region 联系人群组信息 html.Append("<tr><td align='left' style='padding-top:20px;'>联系人群组</td></tr>"); List <crm_contact_group> groupList = accBll.GetBySql <crm_contact_group>($"SELECT ccg.* from crm_contact_group ccg INNER JOIN crm_contact_group_contact ccgc on ccg.id = ccgc.contact_group_id where ccg.delete_time =0 and ccgc.delete_time = 0 and ccgc.contact_id = {conId.ToString()}"); if (groupList != null && groupList.Count > 0) { groupList.ForEach(_ => { html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>{_.name}</td></tr>"); }); } else { html.Append($"<tr><td class='errorSmall' align='left' style='padding-left:10px;text-align:left;font-weight :normal;'>该联系人下没有联系人群组</td></tr>"); } #endregion #region 合同信息 html.Append("<tr><td align='left' style='padding-top:20px;'>合同</td></tr>"); List <ctt_contract> contractList = accBll.GetBySql <ctt_contract>($"SELECT id, name from ctt_contract where delete_time = 0 and contact_id = { conId.ToString()}"); if (contractList != null && contractList.Count > 0) { contractList.ForEach(_ => { html.Append($"<tr><td style='padding-left: 10px; font-weight:normal;'>{_.name}</td></tr>"); }); } else { html.Append($"<tr><td class='errorSmall' align='left' style='padding-left:10px;text-align:left;font-weight :normal;'>该联系人下没有合同</td></tr>"); } #endregion html.Append("</tbody></table></div>"); html.Append("</div>"); return(html.ToString()); }