/// <summary> /// 保存事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { #region 赋值实体 Model.QB_ModelEL qbmodel = new Model.QB_ModelEL(); qbmodel.MainID = 0; qbmodel.Valid = 1; qbmodel.ImgWidth = 149; qbmodel.ImgHeight = 149; qbmodel.QBHeight = 149; qbmodel.QBWidth = 149; qbmodel.FontSize = 12; qbmodel.ENTag = tb_entag.Text; qbmodel.ModelName = tb_modelName.Text.Trim(); if (hidModel.Value == "0")//3*6 { qbmodel.Padding = "18px 25px 18px 20px"; qbmodel.QBHeight = 216; qbmodel.PrintW = 3; qbmodel.PrintH = 6; } else if (hidModel.Value == "1")//3*7 { qbmodel.Padding = "0px 25px 0px 20px"; qbmodel.QBHeight = 216; qbmodel.PrintW = 3; qbmodel.PrintH = 7; } #endregion BLL.QBModelBLL bll_qbmodel = new BLL.QBModelBLL(); if (Request.QueryString["id"] != null) { qbmodel.ID = long.Parse(Request.QueryString["id"]); } Model.QB_ModelEL qbTmplt = new Model.QB_ModelEL() { ENTag = tb_entag.Text.Trim() }; if (Request.QueryString["id"] != null) { qbTmplt.ID = long.Parse(Request.QueryString["id"].Trim()); qbTmplt.ExecuteEL(53); } else { qbTmplt.ExecuteEL(52); } if (qbTmplt.ID > 0 && qbTmplt.MainID > 0) { MessageBox.Show(this, "前缀已经使用请重新输入!"); return; } if (Request.QueryString["id"] != null) { #region 编辑 删除此原来模板的内容 添加新的内容 qbmodel.ExecNonQuery(2); List <string> qbmodeldetailstr = getQBModelDetail(); Model.QB_ModelDetailEL modeldetail = new Model.QB_ModelDetailEL(); modeldetail.QBID = qbmodel.ID; modeldetail.ExecNonQuery(31);//删除此原来模板的内容 modeldetail.MainID = 0; modeldetail.QBID = qbmodel.ID; foreach (string strdetail in qbmodeldetailstr)//循环添加新的内容 { modeldetail.QBDetail = strdetail; modeldetail.ExecNonQuery(1); } #endregion } else { //判断是否存在该名称的模板 if (bll_qbmodel.ExistsModel(qbmodel.ModelName, qbmodel.ID)) { BLL.Common.MessageBox.Show(this, "已存在相同名称的模板!"); return; } #region 新增 qbmodel.ExecuteEL(1);//插入记录 得到新插入实体 List <string> qbmodeldetailstr = getQBModelDetail(); Model.QB_ModelDetailEL modeldetail = new Model.QB_ModelDetailEL(); modeldetail.MainID = 0; modeldetail.QBID = qbmodel.ID; foreach (string strdetail in qbmodeldetailstr) { modeldetail.QBDetail = strdetail; modeldetail.ExecNonQuery(1); } #endregion } MessageBox.ShowAndRedirect(this, "保存成功!", "QBModelList.aspx"); }
/// <summary> /// 保存事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { string mainIdS = GetQueryString("mainId"); long mainId = 0; if (mainIdS != string.Empty) { mainId = long.Parse(mainIdS); } if (mainId > 0) { #region 赋值实体 Model.QB_ModelEL qbmodel = new Model.QB_ModelEL(); qbmodel.MainID = mainId; qbmodel.Valid = 1; qbmodel.ImgWidth = 149; qbmodel.ImgHeight = 149; qbmodel.QBHeight = 149; qbmodel.QBWidth = 149; qbmodel.FontSize = 12; qbmodel.ENTag = tb_entag.Text; qbmodel.ModelName = tb_modelName.Text.Trim(); if (hidModel.Value == "0")//3*6 { qbmodel.Padding = "18px 25px 18px 20px"; qbmodel.QBHeight = 216; qbmodel.PrintW = 3; qbmodel.PrintH = 6; } else if (hidModel.Value == "1")//3*7 { qbmodel.Padding = "0px 25px 0px 20px"; qbmodel.QBHeight = 216; qbmodel.PrintW = 3; qbmodel.PrintH = 7; } #endregion BLL.QBModelBLL bll_qbmodel = new BLL.QBModelBLL(); if (Request.QueryString["id"] != null) { qbmodel.ID = long.Parse(Request.QueryString["id"]); } if (Request.QueryString["id"] != null) { #region 编辑 删除此原来模板的内容 添加新的内容 //判断是否已经有此前缀,有的话则不继续执行 if (hf_entag.Value != tb_entag.Text) { if (IshaveENTag()) { return; } } qbmodel.ExecNonQuery(2); List <string> qbmodeldetailstr = getQBModelDetail(); Model.QB_ModelDetailEL modeldetail = new Model.QB_ModelDetailEL(); modeldetail.QBID = qbmodel.ID; modeldetail.ExecNonQuery(31);//删除此原来模板的内容 modeldetail.MainID = mainId; modeldetail.QBID = qbmodel.ID; foreach (string strdetail in qbmodeldetailstr)//循环添加新的内容 { modeldetail.QBDetail = strdetail; modeldetail.ExecNonQuery(1); } #endregion } else { //判断是否存在该名称的模板 if (bll_qbmodel.ExistsModel(qbmodel.ModelName, qbmodel.ID)) { BLL.Common.MessageBox.Show(this, "已存在相同名称的模板!"); return; } #region 新增 qbmodel.ExecuteEL(1);//插入记录 得到新插入实体 List <string> qbmodeldetailstr = getQBModelDetail(); Model.QB_ModelDetailEL modeldetail = new Model.QB_ModelDetailEL(); modeldetail.MainID = mainId; modeldetail.QBID = qbmodel.ID; foreach (string strdetail in qbmodeldetailstr) { modeldetail.QBDetail = strdetail; modeldetail.ExecNonQuery(1); } #endregion } MessageBox.ShowAndRedirect(this, "保存成功!", "QBModelList.aspx"); } else { MessageBox.Show(this, "没有传入相关参数!"); } }