/// <summary> /// “保存”按钮单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_ServerClick(object sender, EventArgs e) { if (btnAdd.Disabled == true) { if (ZY.HasZY(txtZymc.Value)) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('已存在相同专业名称');</script>"); txtZymc.Value = ""; } else { string zybh = selSsyx.Value; Hashtable queryItems = new Hashtable(); queryItems.Add("zybh", zybh); DataTable table = Gzl.BusinessLogicLayer.ZY.QueryZY(queryItems); string max; int count = table.Rows.Count; if (count < 9) { count += 1; max = "0" + Convert.ToString(count); } else { count += 1; max = Convert.ToString(count); } zybh = zybh + selZylx.Value + max; string zylx = ""; foreach (ListItem item in selZylx.Items) { if (item.Selected == true) { zylx = item.Text; } } //构造user信息哈希表 Hashtable hash = new Hashtable(); hash.Add("zybh", SqlStringConstructor.GetQuotedString(zybh)); hash.Add("zymc", SqlStringConstructor.GetQuotedString(txtZymc.Value.Trim())); hash.Add("zylx", SqlStringConstructor.GetQuotedString(zylx)); string zymc = txtZymc.Value; hash.Add("yxbz", Convert.ToInt32(selYxbz.Value)); Gzl.BusinessLogicLayer.ZY.Add(hash); txtZymc.Value = ""; txtZymc.Disabled = true; selSsyx.Disabled = true; selYxbz.Disabled = true; selZylx.Disabled = true; btnAdd.Disabled = false; btnSave.Disabled = true; btnCancel.Disabled = true; ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + zybh + zymc + "添加成功');</script>"); Query(); } } if (btnChag.Disabled == true) { string zylx = ""; foreach (ListItem item in selZylx.Items) { if (item.Selected == true) { zylx = item.Text; } } Hashtable ht = new Hashtable(); ArrayList selectedZY = GetSelected(); string zybh = selectedZY[0].ToString(); ht.Add("zymc", SqlStringConstructor.GetQuotedString(txtZymc.Value.Trim())); ht.Add("zylx", SqlStringConstructor.GetQuotedString(zylx)); ht.Add("yxbz", Convert.ToInt32(selYxbz.Value)); string where = "Where zybh = " + SqlStringConstructor.GetQuotedString(zybh); Gzl.BusinessLogicLayer.ZY.Update(ht, where); txtZymc.Value = ""; txtZymc.Disabled = true; selSsyx.Disabled = true; selYxbz.Disabled = true; selZylx.Disabled = true; btnChag.Disabled = false; btnSave.Disabled = true; btnCancel.Disabled = true; ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功');</script>"); Query(); } }