//保存 protected void BtnSave_Click(object sender, EventArgs e) { TB_Sys_Organizations model = new TB_Sys_Organizations(); if (ViewState["id"] != null) { model = SysService.SysOrganizations.Get(ViewState["id"]); } else { List <Expression> expression = new List <Expression>(); expression.Add(new Expression("Code", "=", TbCode.Text.TrimEnd())); if (SysService.SysOrganizations.Search(expression).Count > 0) { MessageDiv.InnerHtml = CommonClass.Alert("此用户已存在,请重新输入"); return; } } model.Name = TbName.Text.Trim(); model.Code = TbCode.Text.Trim(); model.ConnectionString = TbConnStr.Text; model.State = CheckBoxState.Checked == false ? 0 : 1; model.Creater = AdminUserName; model.CreatedOn = DateTime.Now; ISysOrganizations sysOrgService = SysService.SysOrganizations; if (ViewState["id"] == null) { if (sysOrgService.Insert(model) == 1) { MessageDiv.InnerHtml = CommonClass.Reload("数据添加成功"); } else { MessageDiv.InnerHtml = CommonClass.Alert("数据添加失败"); } } else { if (sysOrgService.Update(model) == 1) { MessageDiv.InnerHtml = CommonClass.Reload("数据修改成功"); } else { MessageDiv.InnerHtml = CommonClass.Alert("数据修改失败"); } } }
//加载 public void LoadDataBind() { string id = CommonClass.ReturnRequestStr("id"); if (!string.IsNullOrEmpty(id)) { TB_Sys_Organizations model = SysService.SysOrganizations.Get(id); TbName.Text = model.Name; TbCode.Text = model.Code; TbConnStr.Text = model.ConnectionString; CheckBoxState.Checked = model.State == 1 ? true : false; ViewState["id"] = model.ID; } }
//保存 protected void BtnSave_Click(object sender, EventArgs e) { TB_Sys_Organizations model = new TB_Sys_Organizations(); if (ViewState["id"] != null) { model = SysOrganizationsService.OrganizationsService.Get(ViewState["id"]); } model.DbType = DDLDbType.SelectedValue; model.Name = TbName.Text.Trim(); model.Code = TbCode.Text.Trim(); model.Server = TbServer.Text.Trim(); model.DatabaseName = TbDatabaseName.Text.Trim(); model.UserName = TbUserName.Text.Trim(); model.Password = TbPassword.Text.Trim(); model.Port = TbPort.Text.Trim(); model.State = CheckBoxState.Checked ? 0 : 1; model.Creater = AdminUserName; model.CreatedOn = DateTime.Now; if (ViewState["id"] == null) { if (SysOrganizationsService.OrganizationsService.Insert(model) == 1) { MessageDiv.InnerHtml = CommonClass.Reload("数据添加成功"); } else { MessageDiv.InnerHtml = CommonClass.Alert("数据添加失败"); } } else { if (SysOrganizationsService.OrganizationsService.Update(model) == 1) { MessageDiv.InnerHtml = CommonClass.Reload("数据修改成功"); } else { MessageDiv.InnerHtml = CommonClass.Alert("数据修改失败"); } } }
//状态设置 protected void BtnStateSet_Click(object sender, EventArgs e) { foreach (RepeaterItem ri in RepList.Items) { CheckBox cb = ((CheckBox)ri.FindControl("CheckBoxChoose")); int ID = Convert.ToInt32(((HiddenField)ri.FindControl("HiddenFieldID")).Value); if (cb.Checked == true) { List <Expression> express = new List <Expression>(); express.Add(new Expression("ID", "=", ID.ToStr())); TB_Sys_Organizations model = SysService.SysOrganizations.Get(express); model.State = DDLState.SelectedValue.ToInt(); SysService.SysOrganizations.Update(model); } } //重新加载 LoadDataBind(); }