Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        //protected override void Render(System.Web.UI.HtmlTextWriter writer)
        //{
        //    Page.ClientScript.RegisterForEventValidation(this.ddlgroupcalcol.UniqueID, "4");
        //    base.Render(writer);
        //}

        //保存
        protected void lbtnSave_Click(object sender, EventArgs e)
        {
            string displaytype = ddlDisplayType.SelectedValue;

            if (!string.IsNullOrEmpty(hidTemplateID.Value))
            {
                bool iddel  = true;
                bool addrow = true;
                if (hidopertype.Value == "edit")//如果是更新,先删除之前的配置信息
                {
                    iddel = dc.DeleteTemInfoByTemplateID(hidTemplateID.Value);
                }
                //保存报表展现类型
                bool adddisplaytype = true;
                adddisplaytype = dc.UpdateDisplayTypeByTemplateID(Guid.Parse(hidTemplateID.Value), displaytype);
                #region 列配置与排序配置保存
                bool     addcolumn            = true;                                //标识列配置是否添加成功
                bool     addsort              = true;                                //标识排序配置是否添加成功
                bool     addgrid              = true;                                //标识田字型配置是否添加成功
                bool     addcal               = true;                                //计算列
                string   ColumnConfigContent  = hidColumnContent.Value.TrimEnd(';'); //列配置内容
                string   SortContent          = hidSortContent.Value.TrimEnd(';');   //排序配置内容
                string[] ColumnList           = ColumnConfigContent.Split(';');
                BS_TEMPLATE_COLUMNSBLL btcbll = new BS_TEMPLATE_COLUMNSBLL();
                double addm = 10;
                foreach (string cl in ColumnList)//添加列配置到数据库
                {
                    addm++;
                    string[]            ColumnInfoList = cl.Split('|');
                    BS_TEMPLATE_COLUMNS btc            = new BS_TEMPLATE_COLUMNS();
                    btc.TemplateID  = Guid.Parse(hidTemplateID.Value);
                    btc.ColumnName  = ColumnInfoList[0];
                    btc.Visiable    = bool.Parse(ColumnInfoList[1]);
                    btc.DisplayName = ColumnInfoList[2];
                    if (!string.IsNullOrEmpty(ColumnInfoList[3]))
                    {
                        btc.Sequence = decimal.Parse(ColumnInfoList[3]);
                    }
                    else
                    {
                        btc.Sequence = -1;
                    }
                    btc.MergeColumnName = ColumnInfoList[4];
                    btc.ColumnDataType  = ColumnInfoList[5];
                    btc.Created         = DateTime.Now.AddMilliseconds(addm);;
                    btc.Modified        = DateTime.Now;
                    btc.Author          = BaseWebPart.GetCurrentUserLoginId();
                    btc.Editor          = BaseWebPart.GetCurrentUserLoginId();
                    addcolumn           = btcbll.Add(btc);
                }
                //添加排序
                if (!string.IsNullOrEmpty(SortContent))
                {
                    BS_TEMPLATE_SORTBLL btsbll   = new BS_TEMPLATE_SORTBLL();
                    string[]            sortlist = SortContent.Split(';');
                    addm = 10;
                    foreach (string sort in sortlist)
                    {
                        addm++;
                        string[]         sortinfo = sort.Split('|');
                        BS_TEMPLATE_SORT model    = new BS_TEMPLATE_SORT();
                        model.TemplateID = Guid.Parse(hidTemplateID.Value);
                        model.SortColumn = sortinfo[0];
                        model.Type       = (sortinfo[1] == "升序" ? "asc" : "desc");
                        model.Sequence   = decimal.Parse(sortinfo[2]);
                        model.Created    = DateTime.Now.AddMilliseconds(addm);;
                        model.Modified   = DateTime.Now;
                        model.Author     = BaseWebPart.GetCurrentUserLoginId();
                        model.Editor     = BaseWebPart.GetCurrentUserLoginId();
                        addsort          = btsbll.Add(model);
                    }
                }
                #endregion
                if (displaytype == "GRID")//田字型
                {
                    string columnsize = txtColumnSize.Text.Trim();
                    addgrid = dc.UpdatePageSizeByTemplateID(Guid.Parse(hidTemplateID.Value), decimal.Parse(columnsize));
                }
                #region 列配置
                if (displaytype == "COLUMN" || displaytype == "ROW")//列配置
                {
                    var calcontent = hidCalContent.Value.TrimEnd(';');
                    if (!string.IsNullOrEmpty(calcontent))
                    {
                        string[]      CalList = calcontent.Split(';');
                        BS_COMPUTEBLL combll  = new BS_COMPUTEBLL();
                        addm = 10;
                        foreach (string cl in CalList)//添加计算列到数据库
                        {
                            addm++;
                            string[]   CalInfoList = cl.Split('|');
                            BS_COMPUTE btc         = new BS_COMPUTE();
                            btc.TemplateID = Guid.Parse(hidTemplateID.Value);
                            if (hiddbtype.Value.Trim() == "proc")
                            {
                                btc.ComputeColumn = CalInfoList[0];
                            }
                            else
                            {
                                btc.ComputeColumn = CalInfoList[0];
                            }
                            btc.DisplayName     = CalInfoList[1];
                            btc.MergeColumnName = CalInfoList[2];
                            if (!string.IsNullOrEmpty(CalInfoList[3]))
                            {
                                btc.Sequence = decimal.Parse(CalInfoList[3]);
                            }
                            else
                            {
                                btc.Sequence = -1;
                            }
                            btc.DecimalCount = Convert.ToInt32(CalInfoList[4]);
                            btc.Created      = DateTime.Now.AddMilliseconds(addm);;
                            btc.Modified     = DateTime.Now;
                            btc.Author       = BaseWebPart.GetCurrentUserLoginId();
                            btc.Editor       = BaseWebPart.GetCurrentUserLoginId();
                            addcal           = combll.Add(btc);
                        }
                    }
                }
                #endregion
                if (displaytype == "ROW")//行汇总
                {
                    string rowcontent = hidgroupbycontent.Value.Trim().TrimEnd('$');
                    if (!string.IsNullOrEmpty(rowcontent))
                    {
                        string[]      gblist = rowcontent.Split('$');
                        BS_GROUPBYBLL gbll   = new BS_GROUPBYBLL();
                        addm = 10;
                        foreach (string gbinfo in gblist)
                        {
                            addm++;
                            string[]   CalInfoList = gbinfo.Split('|');
                            BS_GROUPBY btc         = new BS_GROUPBY();
                            btc.TemplateID    = Guid.Parse(hidTemplateID.Value);
                            btc.Columns       = CalInfoList[0].TrimEnd(',');
                            btc.Location      = CalInfoList[2];
                            btc.ComputeColumn = CalInfoList[1];
                            btc.Sequence      = 0;
                            btc.SQL           = "";
                            btc.Created       = DateTime.Now.AddMilliseconds(addm);
                            btc.Modified      = DateTime.Now;
                            btc.Author        = BaseWebPart.GetCurrentUserLoginId();
                            btc.Editor        = BaseWebPart.GetCurrentUserLoginId();
                            addrow            = gbll.Add(btc);
                        }
                    }
                }
                if (addcolumn && addsort && addgrid && addcal && adddisplaytype && iddel && addrow)
                {
                    string TemplateID = hidTemplateID.Value;
                    string SourceID   = hidsourceid.Value;
                    if (!string.IsNullOrEmpty(TemplateID) && !string.IsNullOrEmpty(SourceID))
                    {
                        BusinessSearchComponent bsbll = new BusinessSearchComponent();
                        bsbll.RemoveTemplateByGuid(TemplateID);
                        string edit = string.Empty;
                        if (!string.IsNullOrEmpty(Page.Request.QueryString["type"]))
                        {
                            edit = "&type=edit";
                        }
                        Page.Response.Redirect("QueryConfig.aspx?templateID=" + TemplateID + "&sourceID=" + SourceID + edit);
                    }
                    //ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "subsuc", "layer.alert('展示配置成功!');", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "suberror", "layer.alert('未获取到模板编号!');", true);
            }
        }