public void AddRowGridviewVariable() { ConfigFileFormatNameParm parm = listmodelParm.Find(c => c.Name == TxtFormatVariable.Text.Trim()); if (parm != null) { listmodelParm.Remove(parm); parm.Name = TxtFormatVariable.Text.Trim(); parm.VariableType = DropDownListVariable.SelectedValue; parm.DataSource = DropDownListDataSource.SelectedValue; parm.Connector = DropDownListConnector.SelectedValue; listmodelParm.Add(parm); } else { //不存在添加行记录 ConfigFileFormatNameParm model = new ConfigFileFormatNameParm(); model.Name = TxtFormatVariable.Text.Trim(); model.VariableType = DropDownListVariable.SelectedValue; model.DataSource = DropDownListDataSource.SelectedValue; model.Connector = DropDownListConnector.SelectedValue; listmodelParm.Add(model); } TxtFormatVariable.Text = ""; gridviewVariable.DataSource = listmodelParm; gridviewVariable.DataBind(); }
protected void btnCheckout_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtVoluntarilyTime.Text.Trim())) { txtVoluntarilyTime.Focus(); MessageBox.Show(this, "执行时间不能为空"); return; } else if (string.IsNullOrEmpty(TextBoxValidateDate.Text.Trim())) { TextBoxValidateDate.Focus(); MessageBox.Show(this, "首次执行日期不能为空"); return; } else if (string.IsNullOrEmpty(TextBoxFileFormatName.Text.Trim())) { TextBoxFileFormatName.Focus(); MessageBox.Show(this, "格式化文件名称不能为空"); return; } //else if (gridviewVariable.Rows.Count <= 0) //{ // TxtFormatVariable.Focus(); // MessageBox.Show(this, "请添加格式名称变量!"); // return; //} else { Config model = new Config(); string voltime = TextBoxValidateDate.Text.Trim() + " " + txtVoluntarilyTime.Text.Trim(); model.VoluntarilyTime = Convert.ToDateTime(voltime); model.FileFormatName = TextBoxFileFormatName.Text.Trim(); model.BecomeValidateDate = Convert.ToDateTime(TextBoxValidateDate.Text.Trim()); model.NextVoluntarilyTime = DateTime.Now; List <ConfigFileFormatNameParm> parm = new List <ConfigFileFormatNameParm>(); 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); } DAL_Execute bll = new DAL_Execute(); txtCheckFileName.Text = bll.GetFileFormatName(parm, model); } }
protected void gridviewVariable_RowCommand(object sender, GridViewCommandEventArgs e) { string id = e.CommandArgument.ToString(); if (e.CommandName == "Delete") { ConfigFileFormatNameParm cp = listmodelParm.Find(c => c.Name == id); if (cp != null) { listmodelParm.Remove(cp); if (listmodelParm.Count <= 0) { lblVariable.Visible = false; } MessageBox.Show(this, "删除成功"); } else { MessageBox.Show(this, "删除失败"); } TxtFormatVariable.Text = ""; gridviewVariable.DataSource = listmodelParm; gridviewVariable.DataBind(); } //else if (e.CommandName == "Update") //{ // huaruncms.Model.DdiConfigFileFormatNameParm cp = listmodelParm.Find(c => c.Name == id); // TxtFormatVariable.Text = cp.Name; // DropDownListVariable.SelectedValue = cp.VariableType; // DropDownListDataSource.SelectedValue = cp.DataSource; // DropDownListConnector.SelectedValue = cp.Connector; // TxtFormatVariable.Focus(); // gridviewVariable.DataSource = listmodelParm; // gridviewVariable.DataBind(); //} }
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; } } }
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 } } }