protected void Page_Load(object sender, EventArgs e) { udfList = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.CONTRACTS); resourceList = new DAL.sys_resource_dal().GetSourceList(); roleList = new DAL.sys_role_dal().GetList(); //if (!IsPostBack) //{ long id = 0; if (string.IsNullOrEmpty(Request.QueryString["id"]) || !long.TryParse(Request.QueryString["id"], out id)) { Response.Close(); return; } contractCopy = bll.GetContract(id); if (contractCopy.type_id != (int)DicEnum.CONTRACT_TYPE.SERVICE) { Response.Close(); return; } contractCopy.name = "[Renewal of]" + contractCopy.name; companyName = new CompanyBLL().GetCompany(contractCopy.account_id).name; if (contractCopy.contact_id != null && contractCopy.contact_id > 0) { contactList = new ContactBLL().GetContactByCompany(contractCopy.account_id); } udfValues = new UserDefinedFieldsBLL().GetUdfValue(DicEnum.UDF_CATE.CONTRACTS, id, udfList); serviceList = new ContractServiceBLL().GetServiceList(id); contractType = contractCopy.type_id; isFinish = 0; //} Dictionary <string, object> dics = bll.GetField(); contractCate = dics["cate"] as List <DictionaryEntryDto>; periodType = dics["periodType"] as List <DictionaryEntryDto>; periodType.Remove(periodType.Find(pt => pt.val.Equals(((int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.ONE_TIME).ToString()))); billPostType = dics["billPostType"] as List <DictionaryEntryDto>; slaList = bll.GetSLAList(); contractTypeName = bll.GetContractTypeName(contractType); }
protected void Page_Load(object sender, EventArgs e) { udfList = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.CONTRACTS); resourceList = new DAL.sys_resource_dal().GetSourceList(); roleList = new DAL.sys_role_dal().GetList(); long quoteId = 0; if (!string.IsNullOrEmpty(Request.QueryString["quoteId"]) && long.TryParse(Request.QueryString["quoteId"], out quoteId)) { quote = new QuoteBLL().GetQuote(quoteId); if (quote != null) { account = new CompanyBLL().GetCompany(quote.account_id); } } if (IsPostBack) { ContractAddDto dto = new ContractAddDto(); dto.contract = AssembleModel <ctt_contract>(); if (!string.IsNullOrEmpty(Request.Form["isSdtDefault"]) && Request.Form["isSdtDefault"].Equals("on")) { dto.contract.is_sdt_default = 1; } if (!string.IsNullOrEmpty(Request.Form["needTimeSheet"]) && Request.Form["needTimeSheet"].Equals("on")) { dto.contract.timeentry_need_begin_end = 1; } else { dto.contract.timeentry_need_begin_end = 0; } if (dto.contract.type_id == (int)DicEnum.CONTRACT_TYPE.BLOCK_HOURS) { if (!string.IsNullOrEmpty(Request.Form["enableOverage"]) && Request.Form["enableOverage"].Equals("on")) { dto.contract.enable_overage_billing_rate = 1; } } if (dto.contract.type_id == (int)DicEnum.CONTRACT_TYPE.FIXED_PRICE) { if (!string.IsNullOrEmpty(Request.Form["applyPayment"]) && Request.Form["applyPayment"].Equals("on")) { decimal price = 0; if (decimal.TryParse(Request.Form["alreadyReceived"], out price) && price > 0) { dto.alreadyReceived = price; } if (decimal.TryParse(Request.Form["toBeInvoiced"], out price) && price > 0) { dto.toBeInvoiced = price; } long code = 0; if (long.TryParse(Request.Form["defaultCostCode"], out code)) { dto.defaultCostCode = code; } } } if (udfList != null && udfList.Count > 0) // 首先判断是否有自定义信息 { var list = new List <UserDefinedFieldValue>(); foreach (var udf in 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); } dto.udf = list; } // 服务 dto.serviceList = new List <ServiceInfoDto>(); if (dto.contract.type_id == (int)DicEnum.CONTRACT_TYPE.SERVICE) { if (!string.IsNullOrEmpty(Request.Form["AddServiceIds"])) // 服务 { string[] ids = Request.Form["AddServiceIds"].Split(','); foreach (string id in ids) { ServiceInfoDto si = new ServiceInfoDto(); si.price = decimal.Parse(Request.Form["price" + id]); si.number = decimal.Parse(Request.Form["num" + id]); si.serviceId = long.Parse(id); si.type = 1; dto.serviceList.Add(si); } } if (!string.IsNullOrEmpty(Request.Form["AddSerBunIds"])) // 服务包 { string[] ids = Request.Form["AddSerBunIds"].Split(','); foreach (string id in ids) { ServiceInfoDto si = new ServiceInfoDto(); si.price = decimal.Parse(Request.Form["price" + id]); si.number = decimal.Parse(Request.Form["num" + id]); si.serviceId = long.Parse(id); si.type = 2; dto.serviceList.Add(si); } } } // 里程碑 dto.milestone = new List <ctt_contract_milestone>(); if (dto.contract.type_id == (int)DicEnum.CONTRACT_TYPE.FIXED_PRICE && (!string.IsNullOrEmpty(Request.Form["milestoneAddList"]))) { string[] ids = Request.Form["milestoneAddList"].Split(','); foreach (string id in ids) { ctt_contract_milestone mil = new ctt_contract_milestone(); mil.name = Request.Form["MilName" + id]; mil.description = Request.Form["MilDetail" + id]; decimal dollar = 0; if (!decimal.TryParse(Request.Form["MilAmount" + id], out dollar)) { dollar = 0; } mil.dollars = dollar; mil.due_date = DateTime.Parse(Request.Form["MilDate" + id]); mil.cost_code_id = long.Parse(Request.Form["MilCode" + id]); mil.status_id = int.Parse(Request.Form["isBill" + id]); dto.milestone.Add(mil); } } // 角色费率 dto.rateList = new List <ContractRateDto>(); if (dto.contract.type_id != (int)DicEnum.CONTRACT_TYPE.SERVICE && dto.contract.type_id != (int)DicEnum.CONTRACT_TYPE.PER_TICKET) { foreach (var role in roleList) { if (Request.Form["cbRoleRate" + role.id] != null && Request.Form["cbRoleRate" + role.id].Equals("on")) { var roleRate = new ContractRateDto(); roleRate.roleId = role.id; roleRate.rate = decimal.Parse(Request.Form["txtRoleRate" + role.id]); dto.rateList.Add(roleRate); } } } // 邮件通知 dto.notifyUserIds = new List <long>(); foreach (var res in resourceList) { if (Request.Form["notify" + res.id] != null && Request.Form["notify" + res.id].Equals("on")) { dto.notifyUserIds.Add(res.id); } } if (dto.notifyUserIds.Count != 0) { dto.notifySubject = Request.Form["notifyTitle"]; dto.notifyMessage = Request.Form["notifyContent"]; dto.notifyEmails = Request.Form["notifyEmails"]; } contractId = bll.Insert(dto, GetLoginUserId()); contractType = dto.contract.type_id; isFinish = 1; } else { if (!int.TryParse(Request.QueryString["type"], out contractType)) { contractType = 0; } isFinish = 0; } Dictionary <string, object> dics = bll.GetField(); contractCate = dics["cate"] as List <DictionaryEntryDto>; periodType = dics["periodType"] as List <DictionaryEntryDto>; periodType.Remove(periodType.Find(pt => pt.val.Equals(((int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.ONE_TIME).ToString()))); billPostType = dics["billPostType"] as List <DictionaryEntryDto>; slaList = bll.GetSLAList(); contractTypeName = bll.GetContractTypeName(contractType); }
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(); } }