Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                return;
            }

            SPUser user = SPContext.Current.Web.CurrentUser;

            if (user != null)
            {
                Company company = com.GetCompanyInfo(BaseWebPart.GetCurrentUserLoginId());
                userName.Value   = BaseWebPart.GetCurrentUserLoginId(1);
                txtcompany.Value = company.Costomer;
                linkMan.Value    = SPContext.Current.Web.CurrentUser.Name;
                phone.Value      = company.phone;
            }
            QGCostcoSoapClient client    = new QGCostcoSoapClient();
            string             preDate   = DateTime.Now.ToString("yyyyMMddHHmmss");//Text1.Value;
            string             errorMsg  = "";
            string             errorCode = "";
            string             result    = "";

            try
            {
                result = client.getBookTime(preDate, out errorMsg, out errorCode);
                BaseComponent.Info("WebService Paras getBookTime:preDate " + preDate + ";errorMsg " + errorMsg + ";errorCode " + errorCode);
                if (errorCode == "0")
                {
                    var appointment = com.GetAppointment(result);
                    beginTime.Value = DateTime.ParseExact(appointment.STARTTIME, "yyyyMMddHHmmss", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd HH:mm");
                    endTime.Value   = DateTime.ParseExact(appointment.ENDTIME, "yyyyMMddHHmmss", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd HH:mm");
                    DateTime time = DateTime.ParseExact(appointment.INSPECTIONDATE, "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
                    inspectionTime.Value = time.ToString("yyyy-MM-dd");

                    string[] weekdays = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
                    string   week     = weekdays[Convert.ToInt32(time.DayOfWeek)];

                    inspectionDay.Value = week;

                    if (DateTime.Now < DateTime.ParseExact(appointment.STARTTIME, "yyyyMMddHHmmss", CultureInfo.InvariantCulture) || DateTime.Now > DateTime.ParseExact(appointment.ENDTIME, "yyyyMMddHHmmss", CultureInfo.InvariantCulture))
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "connsuc", "layer.alert('现在不是预约时间!');", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "connsuc", "layer.alert('今天不允许预约!');", true);
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "connsuc", "layer.alert('加载预约时间失败啦!');", true);

                BaseComponent.Error(ex.ToString());
            }
        }
Пример #2
0
        //保存
        protected void lbtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(hidTemplateID.Value))
                {
                    bool adduserquery    = false;
                    bool adddefaultquery = false;
                    //bool iddel = true;
                    if (hidopertype.Value == "edit")//如果是更新,先删除之前的配置信息
                    {
                        bll.DeleteTemInfoByTemplateID(hidTemplateID.Value);
                    }
                    string DefaultQueryContent = hidDefaultContent.Value.TrimEnd(';');//用户默认筛选条件内容
                    if (!string.IsNullOrEmpty(DefaultQueryContent))
                    {
                        string MainLogic = "";
                        if (radand.Checked)
                        {
                            MainLogic = "and";
                        }
                        if (rador.Checked)
                        {
                            MainLogic = "or";
                        }
                        BS_DEFAULT_QUERYBLL qcqbll = new BS_DEFAULT_QUERYBLL();
                        string[]            uqlist = DefaultQueryContent.Split(';');
                        double addm = 10;
                        foreach (string uqinfo in uqlist)
                        {
                            addm++;
                            string[]         uqinfolist = uqinfo.Split('|');
                            BS_DEFAULT_QUERY model      = new BS_DEFAULT_QUERY();
                            model.TemplateID   = Guid.Parse(hidTemplateID.Value);
                            model.ColumnName   = uqinfolist[0];
                            model.MainLogic    = MainLogic;
                            model.Compare      = uqinfolist[1];
                            model.CompareValue = uqinfolist[2];
                            model.Desction     = uqinfolist[3];
                            model.ModuleID     = Convert.ToInt32(uqinfolist[4]);
                            model.SubLogic     = uqinfolist[5];

                            model.Created   = DateTime.Now.AddMilliseconds(addm);
                            model.Modified  = DateTime.Now;
                            model.Author    = BaseWebPart.GetCurrentUserLoginId();
                            model.Editor    = BaseWebPart.GetCurrentUserLoginId();
                            adddefaultquery = qcqbll.Add(model);
                        }
                    }
                    string UserQueryContent = hidUserQueryContent.Value.TrimEnd('$');//用户筛选配置内容
                    if (!string.IsNullOrEmpty(UserQueryContent))
                    {
                        BS_CUSTOM_QUERYBLL qcqbll = new BS_CUSTOM_QUERYBLL();
                        string[]           uqlist = UserQueryContent.Split('$');
                        double             addm   = 10;
                        foreach (string uqinfo in uqlist)
                        {
                            addm++;
                            string[]        uqinfolist = uqinfo.Split('|');
                            BS_CUSTOM_QUERY model      = new BS_CUSTOM_QUERY();
                            model.TemplateID  = Guid.Parse(hidTemplateID.Value);
                            model.ColumnName  = uqinfolist[0];
                            model.DisplayName = uqinfolist[1];
                            model.ControlType = uqinfolist[2];
                            model.Compare     = uqinfolist[3];
                            model.Sequence    = -1;
                            if (!string.IsNullOrEmpty(uqinfolist[4]))
                            {
                                model.Sequence = decimal.Parse(uqinfolist[4]);
                            }
                            model.DefaultValue = uqinfolist[6];
                            model.Reminder     = uqinfolist[5];
                            model.Created      = DateTime.Now.AddMilliseconds(addm);
                            model.Modified     = DateTime.Now;
                            model.Author       = BaseWebPart.GetCurrentUserLoginId();
                            model.Editor       = BaseWebPart.GetCurrentUserLoginId();
                            adduserquery       = qcqbll.Add(model);
                        }
                    }
                    string edit = string.Empty;
                    if (!string.IsNullOrEmpty(Page.Request.QueryString["type"]))
                    {
                        edit = "&type=edit";
                    }
                    BusinessSearchComponent bsbll = new BusinessSearchComponent();
                    bsbll.RemoveTemplateByGuid(hidTemplateID.Value);
                    string sourceid = hidsourceid.Value.Trim();
                    if (adduserquery || adddefaultquery)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "subsuc", "layer.alert('用户筛选条件配置成功!');", true);
                        Page.Response.Redirect("CommunicationConfig.aspx?templateID=" + hidTemplateID.Value + "&sourceID=" + sourceid + edit);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "subsucerror", "layer.alert('用户筛选条件配置失败!');", true);
                    }
                    if (string.IsNullOrEmpty(DefaultQueryContent) && string.IsNullOrEmpty(UserQueryContent))
                    {
                        Page.Response.Redirect("CommunicationConfig.aspx?templateID=" + hidTemplateID.Value + "&sourceID=" + sourceid + edit);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "suberror", "layer.alert('未获取到模板编号!');", true);
                }
            }
            catch (Exception ee)
            {
                BaseComponent.Error(ee.Message);
            }
        }
Пример #3
0
        protected void btninterfload_Click(object sender, EventArgs e)
        {
            try
            {
                System.ServiceModel.WSHttpBinding binding = new System.ServiceModel.WSHttpBinding(System.ServiceModel.SecurityMode.None);
                binding.MaxReceivedMessageSize = int.MaxValue;
                string comtype = ddlcompanyname.SelectedValue;
                string bustype = ddlbusinesstype.SelectedValue;
                if (!string.IsNullOrEmpty(comtype) && !string.IsNullOrEmpty(bustype) && comtype.Contains(";"))
                {
                    string[] comlist         = comtype.Split(';');
                    string   currentUserName = BaseWebPart.GetCurrentUserLoginId();
                    string   dtcolstr        = "目标客户公司代码,目标客户公司名称,目标客户说明,语义内容,业务代码,业务代码说明,业务翻译说明,目标客户代码,目标客户代码英文描述,目标客户代码中文描述,我方代码,我方代码英文描述,我方代码中文描述,生效时间,失效时间";
                    CBOSServices.CodSwicthTableServiceClient client = new CBOSServices.CodSwicthTableServiceClient();
                    CBOSServices.CodSwicthTable[]            result = client.getCodSwitchMessage2(comlist[1], bustype);
                    if (result != null && result.Length > 0)
                    {
                        codeMap.DelCodeMapByComIDAndBusID(comlist[1].Trim(), bustype.Trim());//插入前先删除
                        foreach (CBOSServices.CodSwicthTable re in result)
                        {
                            if (string.IsNullOrEmpty(re.CODE_CBOS))
                            {
                                continue;
                            }
                            DataTable dt         = new DataTable();
                            string[]  dtitlelist = dtcolstr.Split(',');
                            foreach (string str in dtitlelist)
                            {
                                dt.Columns.Add(str);
                            }
                            DataRow dr = dt.NewRow();
                            dr[0]  = comlist[1];
                            dr[1]  = comlist[0];
                            dr[2]  = "";
                            dr[3]  = "";
                            dr[4]  = re.SWITCH_TAB_NAME;
                            dr[5]  = "";
                            dr[6]  = "";
                            dr[7]  = re.CODE_CBOS;
                            dr[8]  = re.CODE_NAME_E_CBOS;
                            dr[9]  = re.CODE_NAME_C_CBOS;
                            dr[10] = re.CODE_SWITCH;
                            dr[11] = re.CODE_NAME_E_SWITCH;
                            dr[12] = re.CODE_NAME_C_SWITCH;
                            dr[13] = "";
                            dr[14] = "";
                            dt.Rows.Add(dr);
                            codeMap.InsertTableFromDataTable(dt, currentUserName);
                        }
                    }
                    BindCodeMap();
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "interfaceloadsuc", "InterfaceUploadSuccess();", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "interfaceloaderror", "layer.alert('公司名称与业务代码不能为空!',8);", true);
                }
            }
            catch (Exception ex)
            {
                BaseComponent.Error("代码映射接口导入: " + ex.Message + "--------" + ex.StackTrace);

                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "interfaceload", "layer.alert('接口导入出现异常,请联系管理员!',8);", true);
            }
            //finally
            //{
            //    //ddlcompanyname.SelectedValue = "all";
            //    //ddlbusinesstype.SelectedValue = "all";
            //}
        }
Пример #4
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);
            }
        }
Пример #5
0
        //复制
        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);
            }
        }