protected void BindGv() { DataTable dtbByProviceId = new BasicCityService().GetDtbByProviceId(this.hdProvinceID.Value); this.gvCity.DataSource = dtbByProviceId; this.gvCity.DataBind(); }
protected void showInfoCity(string cityID) { BasicCity basicCity = new BasicCity(); if (!string.IsNullOrEmpty(cityID)) { basicCity = new BasicCityService().GetCityByCityID(cityID); this.txtCityName.Text = basicCity.Name; this.txtCityCode.Text = basicCity.Code; } }
protected void btnDel_Click(object sender, EventArgs e) { string value = this.hfldCityID.Value; if (!string.IsNullOrEmpty(value)) { BasicCityService basicCityService = new BasicCityService(); BasicCity cityByCityID = basicCityService.GetCityByCityID(value); try { basicCityService.Delete(cityByCityID); this.BindGv(); base.RegisterScript("top.ui.show('系统提示:\\n\\n删除成功!');"); } catch { base.RegisterScript("top.ui.alert('系统提示:\\n\\n删除失败!');"); } } }
public void bindCity() { this.dropcity.Items.Clear(); DataTable dataTable = new DataTable(); string text = "请选择|"; if (!string.IsNullOrEmpty(this.dropprovince.SelectedItem.Text)) { dataTable = new BasicCityService().GetDtbByProviceId(this.dropprovince.SelectedItem.Value); for (int i = 0; i < dataTable.Rows.Count; i++) { DataRow dataRow = dataTable.Rows[i]; text = text + dataRow["Name"].ToString() + "|"; } } text = text.Substring(0, text.Length - 1); string[] array = text.Split(new char[] { '|' }); for (int j = 0; j < array.Length; j++) { if (array[j] == "请选择") { this.dropcity.Items.Add(new ListItem("请选择", "")); } else { this.dropcity.Items.Add(new ListItem(array[j], j.ToString())); if (array[j] == this.hfldCity.Value) { this.dropcity.Items[j].Selected = true; } } } }
protected void btnSave_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.action)) { BasicCity basicCity = new BasicCity(); BasicCityService basicCityService = new BasicCityService(); DataTable dataTable = new DataTable(); if (this.action == "Add") { string cmdText = "SELECT * FROM Basic_City WHERE Name='" + this.txtCityName.Text + "'"; dataTable = basicCityService.ExecuteQuery(cmdText, new SqlParameter[0]); if (dataTable.Rows.Count > 0) { base.RegisterScript("top.ui.alert('系统提示:\\n\\n 该城市名称已经存在!');"); return; } cmdText = "SELECT * FROM Basic_City WHERE Code='" + this.txtCityCode.Text + "'"; dataTable = basicCityService.ExecuteQuery(cmdText, new SqlParameter[0]); if (dataTable.Rows.Count > 0) { base.RegisterScript("top.ui.alert('系统提示:\\n\\n 该城市编码已经存在!');"); return; } cmdText = "SELECT MAX(OrderNo) FROM Basic_City WHERE ProvinceId='" + this.hlfdProvinceID.Value + "'"; dataTable = basicCityService.ExecuteQuery(cmdText, new SqlParameter[0]); string value = dataTable.Rows[0][0].ToString(); int num = 0; if (!string.IsNullOrEmpty(value)) { num = Convert.ToInt32(value); } basicCity.Id = Guid.NewGuid(); basicCity.Name = this.txtCityName.Text.Trim(); basicCity.Code = this.txtCityCode.Text.Trim(); basicCity.ProvinceId = new Guid(this.hlfdProvinceID.Value); basicCity.OrderNo = new int?(num + 1); basicCityService.Add(basicCity); base.RegisterScript("top.ui.tabSuccess({ parentName: '_cityEdit' });"); return; } else { if (this.action == "Edit") { string cmdText = string.Concat(new string[] { "SELECT * FROM Basic_City WHERE Name='", this.txtCityName.Text, "' AND Id NOT IN('", this.hlfdCityID.Value, "')" }); dataTable = basicCityService.ExecuteQuery(cmdText, new SqlParameter[0]); if (dataTable.Rows.Count > 0) { base.RegisterScript("top.ui.alert('系统提示:\\n\\n 该城市名称已经存在!');"); return; } cmdText = string.Concat(new string[] { "SELECT * FROM Basic_City WHERE Code='", this.txtCityCode.Text, "' AND Id NOT IN('", this.hlfdCityID.Value, "')" }); dataTable = basicCityService.ExecuteQuery(cmdText, new SqlParameter[0]); if (dataTable.Rows.Count > 0) { base.RegisterScript("top.ui.alert('系统提示:\\n\\n 该城市编码已经存在!');"); return; } basicCity = basicCityService.GetCityByCityID(this.hlfdCityID.Value); basicCity.Name = this.txtCityName.Text.Trim(); basicCity.Code = this.txtCityCode.Text.Trim(); basicCityService.Update(basicCity); base.RegisterScript("top.ui.tabSuccess({ parentName: '_cityEdit' });"); } } } }