//数据绑定 private void bindcontrol(object obj, EventArgs e) { DropDownList ddlCountry = (DropDownList)CountryUC.FindControl("ddlCountry"); //获取国家下拉列表的值 int ID = -1; if (!int.TryParse(ddlCountry.SelectedItem.Value, out ID)) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('" + GetTran("004066", "请选择国家!!!") + "')</script>"); } string sql = " countryID=" + ID; ViewState["sqlE"] = "select id,Bank,countryID,BankBook,bankname from companybank where " + sql + " order by id desc"; this.Pager1.ControlName = "gwbankCard"; this.Pager1.key = "id"; this.Pager1.PageColumn = " id,Bank,countryID,BankBook,bankname "; this.Pager1.Pageindex = 0; this.Pager1.PageTable = "companybank"; this.Pager1.Condition = sql; this.Pager1.PageSize = 10; this.Pager1.PageCount = 0; this.Pager1.PageBind(); Translations(); }
protected void Page_Load(object sender, EventArgs e) { Permissions.ComRedirect(Page, Permissions.redirUrl); Response.Cache.SetExpires(DateTime.Now); Permissions.CheckManagePermission(EnumCompanyPermission.FinanceSetCompanyAccount); Response.Cache.SetExpires(DateTime.Now); DropDownList ddlCountry = (DropDownList)CountryUC.FindControl("ddlCountry"); ddlCountry.DataBound += new EventHandler(bindcontrol); ddlCountry.SelectedIndexChanged += new EventHandler(ddlCountry_SelectedIndexChanged); ddlCountry.AutoPostBack = true; if (!IsPostBack) { this.TranControls(this.but1, new string[][] { new string[] { "002047", "添 加" } }); } Translations(); }
/// <summary> /// 添加和修改功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void but1_Click(object sender, EventArgs e) { DropDownList ddlCountry = (DropDownList)CountryUC.FindControl("ddlCountry"); if (this.txtbank.Text.Trim().Length <= 0) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('" + GetTran("004092", "银行不能为空!") + "')</script>"); return; } if (this.txtname.Text.Trim().Length <= 0) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('" + GetTran("004090", "开户名不能为空!") + "')</script>"); return; } if (this.txtcard.Text.Trim().Length <= 0) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('" + GetTran("004089", "账号不能为空!") + "')</script>"); return; } CompanyBankModel mode = new CompanyBankModel(); mode.Bank = this.txtbank.Text.Trim(); mode.Bankname = this.txtname.Text.Trim(); mode.BankBook = this.txtcard.Text.Trim(); mode.CountryID = int.Parse(ddlCountry.SelectedItem.Value); //当为空时,此操作为添加;否则,修改操作 if (ViewState["ID"] != null) { mode.ID = int.Parse(ViewState["ID"].ToString()); string card = ViewState["bnakbook"].ToString(); //修改账号 ChangeLogs cl = new ChangeLogs("companybank", "ltrim(rtrim(str(id)))"); cl.AddRecord(mode.ID); if (CompanyBankBLL.UpdCompanyBank(mode) == 1) { cl.AddRecord(mode.ID); cl.ModifiedIntoLogs(ChangeCategory.company13, Session["Company"].ToString(), ENUM_USERTYPE.objecttype3); ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('" + GetTran("004086", "修改账户成功!") + "')</script>"); } else { ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('" + GetTran("004084", "修改账户失败!") + "')</script>"); } } else //添加 { //验证账号 if (CompanyBankBLL.ValidateCompanyBank(mode)) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('" + GetTran("004083", "此账号已存在!!!") + "')</script>"); return; } else { //添加账户 if (CompanyBankBLL.AddCompanyBank(mode)) { ViewState["ID"] = null; ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('" + GetTran("004081", "帐户添加成功!") + "')</script>"); } } } this.TranControls(this.but1, new string[][] { new string[] { "002047", "添 加" } }); this.txtcard.Text = string.Empty; ViewState["ID"] = null; bindcontrol(null, null); }