protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (!string.IsNullOrEmpty(Page.Request.QueryString["sourceID"])) { hidsourceid.Value = Page.Request.QueryString["sourceID"]; } if (!string.IsNullOrEmpty(Page.Request.QueryString["templateID"])) { hidTemplateID.Value = Page.Request.QueryString["templateID"]; } if (!string.IsNullOrEmpty(hidsourceid.Value) && !string.IsNullOrEmpty(hidTemplateID.Value)) { string sourceid = hidsourceid.Value.Trim(); BS_DATASOURCEBLL bll = new BS_DATASOURCEBLL(); CMICT.CSP.Model.BS_DATASOURCE model = bll.GetModel(Guid.Parse(sourceid)); if (model != null) { dc = new DisplayConfigComponent(model.SourceIP, model.UserName, model.Password, model.DBName); } BindColumnList(); BindControltype(); BindComparetype(); BindInfoIfEdit(hidTemplateID.Value); } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (!string.IsNullOrEmpty(Page.Request.QueryString["sourceID"])) { hidsourceid.Value = Page.Request.QueryString["sourceID"]; string sourceid = hidsourceid.Value.Trim(); BS_DATASOURCEBLL bll = new BS_DATASOURCEBLL(); CMICT.CSP.Model.BS_DATASOURCE model = bll.GetModel(Guid.Parse(sourceid)); if (model != null) { dcserver = new DisplayConfigComponent(model.SourceIP, model.UserName, model.Password, model.DBName); if (model.ObjectType.ToLower() == "proc") { hiddbtype.Value = "proc"; } } } try { if (!string.IsNullOrEmpty(Page.Request.QueryString["templateID"])) { hidTemplateID.Value = Page.Request.QueryString["templateID"]; BindDisplayType(); BindColumnIfEdit(hidTemplateID.Value); BindColumnList(); BindCalColumnList(); BindDecimal();//绑定小数位数 } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "alertnomodel", "layer.alert('未获取到模板信息,请联系管理员!',8);", true); } }catch (Exception ex) { BaseComponent.Error("DisplayConfig-pageload:" + ex.Message); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "alertnomodelerror", "layer.alert('数据源连接失败,请联系管理员!',8);", true); } } }
protected void lbtnSave_Click(object sender, EventArgs e) { string edit = string.Empty; if (!string.IsNullOrEmpty(Page.Request.QueryString["type"])) { edit = "&type=edit"; } try { string TemplateID = Page.Request.QueryString["templateID"]; string SourceID = ddlSourceName.SelectedValue; if (hidsourceid.Value.Trim() != SourceID.Trim())//修改数据源后删除显示与查询配置信息 { if (!string.IsNullOrEmpty(TemplateID)) { if (dbll.OperConfigDataSource(TemplateID, SourceID)) { if (!string.IsNullOrEmpty(hidsourceid.Value.Trim())) { //更新后查询原数据源是否还有被其它模板引用,没有则更新状态为草稿 ConnectionConfigComponent ccc = new ConnectionConfigComponent(); DataTable dstable = ccc.GetTemplateIDBySourceID(Guid.Parse(hidsourceid.Value.Trim())); if (dstable == null || dstable.Rows.Count == 0) { dbll.UpdateSourceStatusBySourceID(hidsourceid.Value.Trim()); } } DisplayConfigComponent dcbll = new DisplayConfigComponent(); dcbll.DeleteTemInfoByTemplateID(TemplateID); dcbll.UpdateStatusByTemplateID(TemplateID, "DRAFT"); QueryConfigComponent qcbll = new QueryConfigComponent(); qcbll.DeleteTemInfoByTemplateID(TemplateID); CommunicationConfigComponent cccbll = new CommunicationConfigComponent(); //取出所有与此模板有通信关联的源模板信息 DataTable SourceTemList = cccbll.GetCommunicationBySourceTemplateID(TemplateID); //删除通信配置 cccbll.DeleteCommunicationByTemplateID(TemplateID); //刷新模板缓存 BusinessSearchComponent bsbll = new BusinessSearchComponent(); //bsbll.RefreshTemplateByGuid(TemplateID); bsbll.RemoveTemplateByGuid(TemplateID); if (SourceTemList != null && SourceTemList.Rows.Count > 0) { foreach (DataRow dr in SourceTemList.Rows) { if (!string.IsNullOrEmpty(Convert.ToString(dr["TargetTemplateID"]))) { bsbll.RemoveTemplateByGuid(Convert.ToString(dr["TargetTemplateID"])); } } } Page.Response.Redirect("DisplayConfig.aspx?templateID=" + TemplateID + "&sourceID=" + SourceID + edit + ""); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "sourceerror", "layer.alert('数据源配置失败!',8);", true); } } } else { Page.Response.Redirect("DisplayConfig.aspx?templateID=" + TemplateID + "&sourceID=" + SourceID + edit + ""); } } catch (Exception ex) { BaseComponent.Error("DataSourceConfig-lbtnSave_Click:" + ex.Message); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "sourceerrorex", "layer.alert('数据源配置失败!',8);", true); } }
protected void lbtnSave_Click(object sender, EventArgs e) { try { string tipcontent = string.Empty; if (!TestConn(out tipcontent))//如果连接失败 { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "saveconntest", "layer.alert('连接测试失败" + tipcontent + "!',8);executeconnectsur();", true); return; } string SourceName = this.txtSourceName.Value.Trim(); string SourceDesc = this.txtSourceDesc.Value.Trim(); string SourceIP = this.txtSourceIP.Value.Trim(); string UserName = this.txtUserName.Value.Trim(); string Password = this.txtPwd.Text.Trim(); string DBName = this.txtDBName.Text.Trim(); string ObjectType = this.txtObjectType.Text.Trim(); string ObjectName = this.txtObjectName.Text.Trim(); string SourceStatus = "FREE"; DateTime Created = DateTime.Now; DateTime Modified = DateTime.Now; string Author = GetCurrentUserLoginId(); string Editor = GetCurrentUserLoginId(); CMICT.CSP.BLL.BS_DATASOURCEBLL bll = new CMICT.CSP.BLL.BS_DATASOURCEBLL(); string rsourceid = string.Empty; if (hidOperType.Value == "edit") { rsourceid = Page.Request.QueryString["sourceID"]; } if (bll.GetExists(SourceName, rsourceid)) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "sourcenameexist", "layer.alert('已经存在此数据源名称:" + SourceName + "!请重新填写!',8);executeconnectsur();", true); return; } CMICT.CSP.Model.BS_DATASOURCE model = new CMICT.CSP.Model.BS_DATASOURCE(); model.SourceName = SourceName; model.SourceDesc = SourceDesc; model.SourceIP = SourceIP; model.UserName = UserName; model.Password = Password; model.DBName = DBName; model.ObjectType = ObjectType; model.ObjectName = ObjectName; model.SourceStatus = SourceStatus; model.Created = Created; model.Modified = Modified; model.Author = Author; model.Editor = Editor; model.BigCategory = txtCATEGORY.Text; model.SmallCategory = txtsmallcategory.Text; model.SourceCNName = ""; if (hidOperType.Value == "add") { if (bll.Add(model)) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "connsuca", "layer.alert('数据源新增成功!',9);", true); Page.Response.Redirect("DataSourceManage.aspx"); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "connerrora", "layer.alert('数据源新增失败!',8);", true); } } else//修改 { Guid SourceID = Guid.Parse(Page.Request.QueryString["sourceID"]); CMICT.CSP.Model.BS_DATASOURCE oldmodel = bll.GetModel(SourceID); model.SourceID = SourceID; model.Author = hidauthor.Value; model.Created = DateTime.Parse(hidcreated.Value); model.SourceStatus = hidSourceStatus.Value.Trim(); if (bll.Update(model)) { //更新数据源后清空相应模板的配置信息 if (model.DBName != oldmodel.DBName || model.SourceIP != oldmodel.SourceIP || model.UserName != oldmodel.UserName || model.Password != oldmodel.Password || model.ObjectType != oldmodel.ObjectType || model.ObjectName != oldmodel.ObjectName) { ConnectionConfigComponent ccc = new ConnectionConfigComponent(); DataTable dstable = ccc.GetTemplateIDBySourceID(SourceID); if (dstable != null && dstable.Rows.Count > 0) { DisplayConfigComponent dcbll = new DisplayConfigComponent(); QueryConfigComponent qcbll = new QueryConfigComponent(); BusinessSearchComponent bsbll = new BusinessSearchComponent(); //删除通信配置 CommunicationConfigComponent cccbll = new CommunicationConfigComponent(); foreach (DataRow dr in dstable.Rows) { dcbll.UpdateStatusByTemplateID(dr["TemplateID"].ToString(), "DRAFT"); dcbll.DeleteTemInfoByTemplateID(dr["TemplateID"].ToString()); qcbll.DeleteTemInfoByTemplateID(dr["TemplateID"].ToString()); //取出所有与此模板有通信关联的源模板信息 DataTable SourceTemList = cccbll.GetCommunicationBySourceTemplateID(dr["TemplateID"].ToString()); cccbll.DeleteCommunicationByTemplateID(dr["TemplateID"].ToString()); bsbll.RefreshTemplateByGuid(dr["TemplateID"].ToString()); if (SourceTemList != null && SourceTemList.Rows.Count > 0) { foreach (DataRow drr in SourceTemList.Rows) { if (!string.IsNullOrEmpty(Convert.ToString(drr["TargetTemplateID"]))) { bsbll.RefreshTemplateByGuid(Convert.ToString(drr["TargetTemplateID"])); } } } } } } ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "connsucad", "layer.alert('数据源修改成功!');", true); Page.Response.Redirect("DataSourceManage.aspx"); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "connerrorae", "layer.alert('数据源修改失败!');", true); } } } catch (Exception ee) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "saveerror", "layer.alert('" + ee.Message + "');", true); } }
//复制 protected void btncopy_Click(object sender, EventArgs e) { try { string TemplateID = hidtemplateid.Value.Trim(); string CopyNewName = hidCopyName.Value.Trim(); if (!string.IsNullOrEmpty(TemplateID) && !string.IsNullOrEmpty(CopyNewName)) { Guid temid = Guid.Parse(TemplateID); //复制templatemain表 BS_TEMPLATE_MAINBLL tmain = new BS_TEMPLATE_MAINBLL(); BS_TEMPLATE_MAIN tmodel = tmain.GetModel(temid); tmodel.TemplateName = CopyNewName; tmodel.Created = DateTime.Now; tmodel.Modified = DateTime.Now; tmodel.Author = BaseWebPart.GetCurrentUserLoginId(); tmodel.Editor = BaseWebPart.GetCurrentUserLoginId(); tmodel.TemplateStatus = "FREE"; string newtemplateid = tmain.Add(tmodel); if (!string.IsNullOrEmpty(newtemplateid)) { DisplayConfigComponent dcc = new DisplayConfigComponent(); #region 制表 Guid newtemplateguid = Guid.Parse(newtemplateid); //复制bscompare表 DataTable dt = dcc.GetCalListByTemplateID(temid); if (dt != null && dt.Rows.Count > 0) { BS_COMPUTEBLL cmain = new BS_COMPUTEBLL(); foreach (DataRow dr in dt.Rows) { BS_COMPUTE cmodel = cmain.GetModel(Guid.Parse(dr["id"].ToString())); if (cmodel != null) { cmodel.TemplateID = newtemplateguid; cmodel.Created = DateTime.Now; cmodel.Modified = DateTime.Now; cmodel.Author = BaseWebPart.GetCurrentUserLoginId(); cmodel.Editor = BaseWebPart.GetCurrentUserLoginId(); cmain.Add(cmodel); } } } //复制BS_CUSTOM_QUERY表 dt = tmbll.GetBS_CUSTOM_QUERYIDByTemplateID(temid); if (dt != null && dt.Rows.Count > 0) { BS_CUSTOM_QUERYBLL cbll = new BS_CUSTOM_QUERYBLL(); foreach (DataRow dr in dt.Rows) { BS_CUSTOM_QUERY cqmodel = cbll.GetModel(Guid.Parse(dr["id"].ToString())); if (cqmodel != null) { cqmodel.TemplateID = newtemplateguid; cqmodel.Created = DateTime.Now; cqmodel.Modified = DateTime.Now; cqmodel.Author = BaseWebPart.GetCurrentUserLoginId(); cqmodel.Editor = BaseWebPart.GetCurrentUserLoginId(); cbll.Add(cqmodel); } } } //复制BS_CUSTOM_QUERY表 dt = tmbll.GetBS_DEFAULT_QUERYIDByTemplateID(temid); if (dt != null && dt.Rows.Count > 0) { BS_DEFAULT_QUERYBLL dbll = new BS_DEFAULT_QUERYBLL(); foreach (DataRow dr in dt.Rows) { BS_DEFAULT_QUERY dmodel = dbll.GetModel(Guid.Parse(dr["id"].ToString())); if (dmodel != null) { dmodel.TemplateID = newtemplateguid; dmodel.Created = DateTime.Now; dmodel.Modified = DateTime.Now; dmodel.Author = BaseWebPart.GetCurrentUserLoginId(); dmodel.Editor = BaseWebPart.GetCurrentUserLoginId(); dbll.Add(dmodel); } } } //复制BS_GROUPBY表 dt = tmbll.GetBS_GROUPBYIDByTemplateID(temid); if (dt != null && dt.Rows.Count > 0) { BS_GROUPBYBLL gbll = new BS_GROUPBYBLL(); foreach (DataRow dr in dt.Rows) { BS_GROUPBY gmodel = gbll.GetModel(Guid.Parse(dr["id"].ToString())); if (gmodel != null) { gmodel.TemplateID = newtemplateguid; gmodel.Created = DateTime.Now; gmodel.Modified = DateTime.Now; gmodel.Author = BaseWebPart.GetCurrentUserLoginId(); gmodel.Editor = BaseWebPart.GetCurrentUserLoginId(); gbll.Add(gmodel); } } } //复制BS_TEMPLATE_COLUMNS表 dt = tmbll.GetBS_TEMPLATE_COLUMNSIDByTemplateID(temid); if (dt != null && dt.Rows.Count > 0) { BS_TEMPLATE_COLUMNSBLL tbll = new BS_TEMPLATE_COLUMNSBLL(); foreach (DataRow dr in dt.Rows) { BS_TEMPLATE_COLUMNS tcmodel = tbll.GetModel(Guid.Parse(dr["id"].ToString())); if (tcmodel != null) { tcmodel.TemplateID = newtemplateguid; tcmodel.Created = DateTime.Now; tcmodel.Modified = DateTime.Now; tcmodel.Author = BaseWebPart.GetCurrentUserLoginId(); tcmodel.Editor = BaseWebPart.GetCurrentUserLoginId(); tbll.Add(tcmodel); } } } //复制BS_TEMPLATE_SORT表 dt = tmbll.GetBS_TEMPLATE_SORTIDByTemplateID(temid); if (dt != null && dt.Rows.Count > 0) { BS_TEMPLATE_SORTBLL sbll = new BS_TEMPLATE_SORTBLL(); foreach (DataRow dr in dt.Rows) { BS_TEMPLATE_SORT smodel = sbll.GetModel(Guid.Parse(dr["id"].ToString())); if (smodel != null) { smodel.TemplateID = newtemplateguid; smodel.Created = DateTime.Now; smodel.Modified = DateTime.Now; smodel.Author = BaseWebPart.GetCurrentUserLoginId(); smodel.Editor = BaseWebPart.GetCurrentUserLoginId(); sbll.Add(smodel); } } } //复制BS_COMMUNICATION_MAIN表 dt = tmbll.GetBS_COMMUNICATION_MAINIDByTemplateID(temid); if (dt != null && dt.Rows.Count > 0) { BS_COMMUNICATION_MAINBLL sbll = new BS_COMMUNICATION_MAINBLL(); BS_COMMUNICATION_DETAILBLL detailbll = new BS_COMMUNICATION_DETAILBLL(); foreach (DataRow dr in dt.Rows) { Guid commid = Guid.NewGuid(); BS_COMMUNICATION_MAIN smodel = sbll.GetModel(Guid.Parse(dr["CommunicationID"].ToString())); if (smodel != null) { smodel.CommunicationID = commid; smodel.TargetTemplateID = newtemplateguid; smodel.Created = DateTime.Now; smodel.Modified = DateTime.Now; smodel.Author = BaseWebPart.GetCurrentUserLoginId(); smodel.Editor = BaseWebPart.GetCurrentUserLoginId(); sbll.Add(smodel); } DataTable dtdetail = tmbll.GetBS_COMMUNICATION_DETAILByID(Guid.Parse(dr["CommunicationID"].ToString())); if (dtdetail != null && dtdetail.Rows.Count > 0) { foreach (DataRow drd in dtdetail.Rows) { BS_COMMUNICATION_DETAIL sdmodel = detailbll.GetModel(Guid.Parse(drd["id"].ToString())); if (smodel != null) { sdmodel.ID = Guid.NewGuid(); sdmodel.CommunicationID = commid; sdmodel.Created = DateTime.Now; sdmodel.Modified = DateTime.Now; sdmodel.Author = BaseWebPart.GetCurrentUserLoginId(); sdmodel.Editor = BaseWebPart.GetCurrentUserLoginId(); detailbll.Add(sdmodel); } } } } } #endregion ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "sucadd", "layer.alert('模板复制成功!',9);", true); BindTemplateList(); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "erroradd", "layer.alert('模板复制失败!',8);", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "errora", "layer.alert('未获取到模板源信息,无法复制!',8);", true); } } catch (Exception ee) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "erroradd", "layer.alert('模板复制失败!',8);", true); BaseComponent.Error(ee.Message); } }