/// <summary>
 /// 删除模板
 /// </summary>
 /// <param name="template">模板</param>
 public void RemoveTemplate(Template template)
 {
     if (template == null)
         throw new ArgumentNullException("Template is null");
     IUnitOfWork unitOfWork = _templateRepository.UnitOfWork;
     _templateRepository.Remove(template);
     unitOfWork.Commit();
 }
 /// <summary>
 /// 修改模板
 /// </summary>
 /// <param name="template">模板</param>
 public void ModifyTemplate(Template template)
 {
     if (template == null)
         throw new ArgumentNullException("Template is null");
     IUnitOfWork unitOfWork = _templateRepository.UnitOfWork;
     _templateRepository.Modify(template);
     //complete changes in this unit of work
     unitOfWork.CommitAndRefreshChanges();
 }
示例#3
0
 /// <summary>
 /// 保存
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     var result = ValPage();
     if(result)
     {
         var tableSouce = (DataTable)ViewState["CorrespondingTable"];
         if (tableSouce == null) return;
         var template = new Template();
         template.TID = Guid.NewGuid();
         template.TemplateCode = txtTemplateCode.Text;
         template.Name = txtName.Text;
         template.PrintDirection = Convert.ToInt32(ddlPrintDirection.SelectedValue);
         template.PagerWidth = Convert.ToInt32(txtPagerWidth.Text);
         template.PagerHeight = Convert.ToInt32(txtPagerHeight.Text);
         template.PaperType = ddlPaperType.SelectedValue;
         template.CreateDate = DateTime.Now;
         template.ModifyDate = DateTime.Now;
         template.Operator ="Admin";
         var nameArry = tableSouce.Select("SVALUE='" + ddlCorrespondingTable.SelectedValue + "'");
         if (nameArry!=null&&nameArry.Count()!=0)
         {
             template.CorrespondingTable = ddlCorrespondingTable.SelectedValue.ToLower();
             template.CorrespondingCN = Convert.ToString(nameArry[0].ItemArray[3]).ToLower();
             template.IdentifyKey = Convert.ToString(nameArry[0].ItemArray[4]).ToLower();
         }
         template.TemplateCode = txtTemplateCode.Text;
         try
         {
             _templateService.AddTemplate(template);
             ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('模板保存成功!')", true);
         }
         catch
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('模板保存失败!')", true);
         }
     }
 }
        /// <summary>
        /// 独立保存radio
        /// </summary>
        /// <param name="template"></param>
        private void SaveRadio(Template template,string sqlStr)
        {
            //处理radioBox
            Dictionary<string, Type> dt = ResolveRadioBoxType();
            if (dt.ContainsKey(ddlColume.SelectedValue))
            {
                var enumObj = HashtableForEnum(dt[ddlColume.SelectedValue]);
                if (enumObj != null)
                {
                    foreach (var key in enumObj.Keys)
                    {
                        Param param = new Param
                        {
                            PID = Guid.NewGuid(),
                            Tag = template.Params.Count + 1,
                            Key = Convert.ToString(key),
                            Value = sqlStr,
                            Top = 0,
                            Left = 0,
                            Width = 100,
                            Height = 20,
                            FontName = "WST_Swed",
                            FontSize = 9,
                            Alignment = 0,
                            Bold = 0,
                            Italic = 0,
                            Underline = 0,
                            ParamType = ddlParamType.SelectedValue,
                            DefaultValue = Convert.ToString(enumObj[key])
                        };
                        param.Template = template;
                        _paramService.AddParam(param);//保存
                    }
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('不能选择此字段,请重新选择!');", true);

                //置索引0
                BindColume(ddlTable.SelectedValue);
                BindKey(ddlColume.SelectedItem.Text); 
                //return;
            }
        }
 /// <summary>
 /// 新增模板
 /// </summary>
 /// <param name="template">模板</param>
 public void AddTemplate(Template template)
 {
     if (template == null)
         throw new ArgumentNullException("Template is null");
     IUnitOfWork unitOfWork = _templateRepository.UnitOfWork;
     _templateRepository.Add(template);
     //complete changes in this unit of work
     unitOfWork.Commit();
 }