protected void formView_ItemCommand(object sender, FormViewCommandEventArgs e)
    {
        Guid corpId = Guid.Empty;

        Guid.TryParse(hfCorpId.Value, out corpId);

        if (e.CommandName == "UpdateCorp")
        {
            YC.SQLServerDAL.Corporation record = bll_CorpManage.GetCorporationById(corpId);

            // 公司所在地
            TextBox tbDistrict = formView.FindControl("tbDistrict") as TextBox;
            record.District = tbDistrict.Text;

            // 公司名称
            TextBox tbCorpName = formView.FindControl("tbCorpName") as TextBox;
            record.CorpName = tbCorpName.Text;

            // 公司简称
            TextBox tbAbbr = formView.FindControl("tbAbbr") as TextBox;
            record.Abbr = tbAbbr.Text;

            // 公司类别
            DropDownList ddlCorpType = formView.FindControl("ddlCorpType") as DropDownList;
            record.CorpType = ddlCorpType.SelectedValue;

            // 联系人姓名
            TextBox tbLinkmanName = formView.FindControl("tbLinkmanName") as TextBox;
            record.LinkmanName = tbLinkmanName.Text;

            // 固定电话
            record.Telephone = (formView.FindControl("tbTelephone") as TextBox).Text;

            // 手机号码
            TextBox tbMobilePhone = formView.FindControl("tbMobilePhone") as TextBox;
            record.MobilePhone = tbMobilePhone.Text;

            // 手机短号
            TextBox tbMobileShort = formView.FindControl("tbMobileShort") as TextBox;
            record.MobileShort = tbMobileShort.Text;

            // 邮件地址
            record.Email = (formView.FindControl("tbEmail") as TextBox).Text;

            bll_CorpManage.UpdateCorporation(record);
            if (Updated != null)
            {
                Updated(this, new EventArgs());
            }
        }

        if (e.CommandName == "InsertCorp")
        {
            YC.SQLServerDAL.Corporation record = new YC.SQLServerDAL.Corporation();

            // 公司所在地
            TextBox tbDistrict = formView.FindControl("tbDistrict") as TextBox;
            record.District = tbDistrict.Text;

            // 公司名称
            TextBox tbCorpName = formView.FindControl("tbCorpName") as TextBox;
            record.CorpName = tbCorpName.Text;

            // 联系人姓名
            TextBox tbLinkmanName = formView.FindControl("tbLinkmanName") as TextBox;
            record.LinkmanName = tbLinkmanName.Text;

            // 固定电话
            record.Telephone = (formView.FindControl("tbTelephone") as TextBox).Text;

            // 手机号码
            TextBox tbMobilePhone = formView.FindControl("tbMobilePhone") as TextBox;
            record.MobilePhone = tbMobilePhone.Text;

            // 手机短号
            TextBox tbMobileShort = formView.FindControl("tbMobileShort") as TextBox;
            record.MobileShort = tbMobileShort.Text;

            // 邮件地址
            record.Email = (formView.FindControl("tbEmail") as TextBox).Text;

            YC.SQLServerDAL.Corporation corp = bll_CorpManage.NewCorporation(record);
            if (CorporationCreated != null)
            {
                hfCorpId.Value = corp.CorpId.ToString();
                CorporationInsertedEventArgs args = new CorporationInsertedEventArgs(corp);
                CorporationCreated(this, args);
            }
        }

        if (e.CommandName == "DeleteCorporation")
        {
            bll_CorpManage.DeleteCorporation(corpId);
            if (Deleted != null)
            {
                Deleted(this, new EventArgs());
            }
        }

        if (e.CommandName == "CancelUpdate" || e.CommandName == "CancelInsert")
        {
            if (Canceled != null)
            {
                Canceled(this, new EventArgs());
            }
        }
    }
Beispiel #2
0
 private void SEA_Corporation1_CorpCreated(object sender, CorporationInsertedEventArgs e)
 {
     Response.Redirect("CorpList.aspx");
 }