private void LoadModelToPage(int id) { DAL_Config bll = new DAL_Config(); Config model = bll.GetModel(id); if (model != null) { DataSet ds = bll.GetSqlModel(id); if (ds != null) { listmodel.Clear(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ConfigToSqlParameter cp = new ConfigToSqlParameter(); if (listmodel != null) { cp.ParameterId = listmodel.Count + 1; } else { cp.ParameterId = 1; } cp.ParameterName = ds.Tables[0].Rows[i]["ParameterName"].ToString(); cp.ParameterType = ds.Tables[0].Rows[i]["ParameterType"].ToString(); cp.OrderBy = Convert.ToInt32(ds.Tables[0].Rows[i]["OrderBy"].ToString()); cp.Illustrate = ds.Tables[0].Rows[i]["Illustrate"].ToString(); listmodel.Add(cp); } gridview.DataSource = listmodel; gridview.DataBind(); listmodelParm.Clear(); for (int i = 0; i < ds.Tables[1].Rows.Count; i++) { //不存在添加行记录 ConfigFileFormatNameParm ddifilename = new ConfigFileFormatNameParm(); ddifilename.Name = ds.Tables[1].Rows[i]["Name"].ToString(); ddifilename.VariableType = ds.Tables[1].Rows[i]["VariableType"].ToString(); ddifilename.DataSource = ds.Tables[1].Rows[i]["DataSource"].ToString(); ddifilename.Connector = ds.Tables[1].Rows[i]["Connector"].ToString(); listmodelParm.Add(ddifilename); } gridviewVariable.DataSource = listmodelParm; gridviewVariable.DataBind(); } DropDownListType.SelectedValue = model.ConfigType.ToString(); DropDownListFileType.SelectedValue = model.FileType.ToString(); TextBoxBusinessName.Text = model.BusinessName; txtVoluntarilyTime.Text = setTimes(model.VoluntarilyTime.ToString()); TextBoxPathName.Text = model.PathName; DropDownListCycle.SelectedValue = model.Cycle; TextBoxFileFormatName.Text = model.FileFormatName; TextBoxRemark.Text = model.Remark; TextBoxSql.Value = model.DateSql; TextBoxValidateDate.Text = model.BecomeValidateDate.ToString("yyyy-MM-dd"); TextBoxLoseEfficacyDate.Text = model.LoseEfficacyDate.ToString("yyyy-MM-dd"); cbHead.Checked = model.IsHead; ServerTypeddl.SelectedValue = model.ServerType; if (model.ManualDownload == "1") { cbDownload.Checked = true; } else { cbDownload.Checked = false; } } }
private string btnSaveCheckSql() { string res = ""; DAL_Config bll = new DAL_Config(); if (this.TextBoxSql.Value.Length == 0) { MessageBox.Show(this, "[文件数据Sql]不能为空!"); res = "false"; return(res); } string sql = TextBoxSql.Value.Trim(); List <ConfigToSqlParameter> paramodel = new List <ConfigToSqlParameter>(); if (gridview.Rows.Count > 0) { foreach (GridViewRow row in gridview.Rows) { ConfigToSqlParameter para = new ConfigToSqlParameter(); para.ParameterType = row.Cells[3].Text.Trim(); para.ParameterName = row.Cells[2].Text.Trim(); para.OrderBy = Convert.ToInt32(row.Cells[1].Text.Trim()); para.Illustrate = row.Cells[4].Text.Trim(); paramodel.Add(para); } } ArrayList userinfo = (ArrayList)Session["user"]; if (userinfo == null) { string url = "window.top.location.href=\"../UsersLogin.aspx\";"; MessageBox.ResponseScript(this, url); } else { string result = ""; try { DataSet ds = bll.CheckConfigSql(sql, paramodel, ServerTypeddl.SelectedValue.ToString(), userinfo[3].ToString().ToLower().Trim(), out result); if (ds != null) { if (ds.Tables.Count > 0) { res = "true"; } else { res = "false"; MessageBox.Show(this, "查询语句错误请确认后再次操作:" + result); } } } catch (Exception ex) { res = "false"; MessageBox.Show(this, result + ": " + ex.Message.ToString()); } } return(res); }
protected void btnSave_Click(object sender, EventArgs e) { if (btnSaveCheckSql() == "true") { if (Validate()) { #region Config model = new Config(); model.ConfigType = Convert.ToInt32(DropDownListType.SelectedValue); model.FileType = int.Parse(DropDownListFileType.SelectedValue); model.BusinessName = TextBoxBusinessName.Text.Trim(); model.VoluntarilyTime = Convert.ToDateTime(txtVoluntarilyTime.Text.Trim()); model.PathName = TextBoxPathName.Text.Trim(); model.Cycle = DropDownListCycle.SelectedValue; model.Prefix = ""; //TextBoxPrefix.Text.Trim(); model.FileFormatName = TextBoxFileFormatName.Text.Trim(); model.Suffix = ""; //TextBoxSuffix.Text.Trim(); model.Remark = TextBoxRemark.Text.Trim(); model.DateSql = TextBoxSql.Value; model.IsDeleted = false; model.BecomeValidateDate = Convert.ToDateTime(TextBoxValidateDate.Text.Trim()); model.LoseEfficacyDate = Convert.ToDateTime(TextBoxLoseEfficacyDate.Text.Trim()); model.IsHead = this.cbHead.Checked; model.ServerType = ServerTypeddl.SelectedValue.Trim(); string strdt = model.BecomeValidateDate.ToString("yyyy-MM-dd") + " " + model.VoluntarilyTime.ToString("HH:mm:ss"); model.NextVoluntarilyTime = Convert.ToDateTime(strdt); if (cbDownload.Checked == true) { model.ManualDownload = "1"; } else { model.ManualDownload = "0"; } ArrayList userinfo = (ArrayList)Session["user"]; if (userinfo == null) { string url = "window.top.location.href=\"../UsersLogin.aspx\";"; MessageBox.ResponseScript(this, url); } else { model.OrgCode = userinfo[3].ToString().Trim(); } List <ConfigFileFormatNameParm> parm = new List <ConfigFileFormatNameParm>(); if (gridviewVariable.Rows.Count > 0) { foreach (GridViewRow row in gridviewVariable.Rows) { ConfigFileFormatNameParm para = new ConfigFileFormatNameParm(); para.Name = row.Cells[2].Text.Trim(); para.VariableType = row.Cells[3].Text.Trim(); para.DataSource = row.Cells[4].Text.Trim(); para.Connector = row.Cells[5].Text.Trim(); parm.Add(para); } } List <ConfigToSqlParameter> paramodel = new List <ConfigToSqlParameter>(); if (gridview.Rows.Count > 0) { foreach (GridViewRow row in gridview.Rows) { ConfigToSqlParameter para = new ConfigToSqlParameter(); para.ParameterType = row.Cells[3].Text.Trim(); para.ParameterName = row.Cells[2].Text.Trim(); para.OrderBy = Convert.ToInt32(row.Cells[1].Text.Trim()); para.Illustrate = row.Cells[4].Text.Trim(); paramodel.Add(para); } } DAL_Config bll = new DAL_Config(); int result = 0; if (HiddenFieldEdit.Value == "Add") { result = bll.Add(model, paramodel, parm); if (result >= 0) { MessageBox.Show(this, "保存成功!"); Response.Redirect("DdiConfigList.aspx", true); } else if (result == -1) { MessageBox.Show(this, "业务名称不能重复!"); } } else if (HiddenFieldEdit.Value == "Edit") { model.Id = Convert.ToInt32(HiddenFieldid.Value); result = bll.Update(model, paramodel, parm); if (result == 0) { MessageBox.Show(this, "编辑成功!"); Response.Redirect("DdiConfigList.aspx", true); } else if (result == 2) { MessageBox.Show(this, "业务名称不能重复"); } } #endregion } } }