Beispiel #1
0
        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();
            }
        }