Example #1
0
 public EasyUiGrid<Template> GetTemplate(Template filter,int pageSize,int pageIndex,ref int recordCount)
 {
     List<Template> Templates = _TemplateRepository.GetTemplate(filter,pageSize,pageIndex,ref recordCount);
     EasyUiGrid<Template> list = new EasyUiGrid<Template>();
     list.total = Templates.Count;
     list.rows = Templates;
     return list;
 }
Example #2
0
 public int Add_Template(Template model)
 {
     string cmdText = @"
     DECLARE @NEWID INT
     INSERT INTO [Template] (TypeId,TemplateName,filename,Templatecontent,Isdelete,Addtime)
                        values (@TypeId,@TemplateName,@filename,@Templatecontent,@Isdelete,GETDATE())
     SET @NEWID=@@IDENTITY
     SELECT @NEWID";
     SqlParameter[] parameters =
     {
         SqlParamHelper.MakeInParam("@TypeId",SqlDbType.Int,4,model.TypeId),
         SqlParamHelper.MakeInParam("@TemplateName",SqlDbType.VarChar,50,model.TemplateName),
         SqlParamHelper.MakeInParam("@filename",SqlDbType.VarChar,255,model.filename),
         SqlParamHelper.MakeInParam("@Templatecontent",SqlDbType.VarChar,100,model.Templatecontent),
         SqlParamHelper.MakeInParam("@Isdelete",SqlDbType.Int,4,model.Isdelete)
     };
     return SqlHelper.ExecuteNonQuery(WriteConnectionString,CommandType.Text,cmdText,parameters);
 }
 private void Add()
 {
     int Id = GetRequestString("Id").ToInt32();
     int TypeId = GetRequestString("TypeId").ToInt32();
     string TemplateName = GetRequestString("TemplateName");
     string filename = GetRequestString("filename");
     int Isdelete = GetRequestString("Isdelete").ToInt32();
     string Templatecontent = GetRequestString("Templatecontent");
     Template temp;
     if(!GetRequestString("Id").IsNullOrEmpty()){
         temp = _TemplateService.Get_Template(Id);
         if(temp != null){
             temp.TypeId = TypeId;
             temp.TemplateName = TemplateName;
             temp.filename = filename;
             temp.Isdelete = Isdelete;
             temp.Templatecontent = Templatecontent;
             temp.Addtime = DateTime.Now;
             _TemplateService.UpdateTemplate(temp);
         }
         else{
             Response.Write("false");
         }
     }
     else{
         temp = new Template();
         temp.TypeId = TypeId;
         temp.TemplateName = TemplateName;
         temp.filename = filename;
         temp.Isdelete = Isdelete;
         temp.Templatecontent = Templatecontent;
         temp.Addtime = DateTime.Now;
         _TemplateService.Add_Template(temp);
     }
     Response.Write("true");
 }
Example #4
0
 public void Add(Template pTemplate)
 {
     _arrayInternal.Add(pTemplate);
 }
Example #5
0
 public int UpdateTemplate(Template model)
 {
     return _TemplateRepository.UpdateTemplate(model);
 }
Example #6
0
 public int Add_Template(Template model)
 {
     return _TemplateRepository.Add_Template(model);
 }
Example #7
0
 public List<Template> GetTemplate(Template filter,int pageSize,int pageIndex,ref int recordCount)
 {
     SqlParameter[] parameters =
     {
         SqlParamHelper.MakeParam("@RecordNum",SqlDbType.Int,4,ParameterDirection.InputOutput,recordCount),
         SqlParamHelper.MakeInParam("@SelectList",SqlDbType.VarChar,2000,Template_INFO_FIELDS),
         SqlParamHelper.MakeInParam("@TableSource",SqlDbType.VarChar,100,"[View_TemplateDictionary]"),
         SqlParamHelper.MakeInParam("@SearchCondition",SqlDbType.VarChar,2000,GetSearchCondition(filter)),
         SqlParamHelper.MakeInParam("@OrderExpression",SqlDbType.VarChar,1000,"Addtime"),
         SqlParamHelper.MakeInParam("@PageSize",SqlDbType.Int,4,pageSize),
         SqlParamHelper.MakeInParam("@PageIndex",SqlDbType.Int,4,pageIndex)
     };
     List<Template> list = new List<Template>();
     using (IDataReader dr = SqlHelper.ExecuteReader(ReadConnectionString,CommandType.StoredProcedure,"PR_GetDataByPageIndex",parameters)){
         while(dr.Read()){
             list.Add(BindTemplate(dr));
         }
     }
     try{
         recordCount = Convert.ToInt32(parameters[0].Value);
     }
     catch{
         recordCount = 0;
     }
     return list;
 }
Example #8
0
 private string GetSearchCondition(Template filter)
 {
     StringBuilder condition = new StringBuilder("1=1");
     if(!filter.TemplateName.IsNullOrEmpty()){
         condition.Append(string.Format(" and TemplateName like '%{0}%'",filter.TemplateName.Trim().ToSafeSql()));
     }
     return condition.ToString();
 }
Example #9
0
 public int UpdateTemplate(Template model)
 {
     string cmdText = @"UPDATE [Template] SET [TypeId]=@TypeId,[TemplateName]=@TemplateName,[filename]=@filename,[Isdelete]=@Isdelete,[Templatecontent]=@Templatecontent,Addtime=GETDATE() WHERE id=@id";
     SqlParameter[] parameters =
     {
         SqlParamHelper.MakeInParam("@id",SqlDbType.Int,4,model.id),
         SqlParamHelper.MakeInParam("@TypeId",SqlDbType.Int,4,model.TypeId),
         SqlParamHelper.MakeInParam("@TemplateName",SqlDbType.VarChar,50,model.TemplateName),
         SqlParamHelper.MakeInParam("@filename",SqlDbType.VarChar,255,model.filename),
         SqlParamHelper.MakeInParam("@Isdelete",SqlDbType.Int,4,model.Isdelete),
         SqlParamHelper.MakeInParam("@Templatecontent",SqlDbType.VarChar,100,model.Templatecontent)
     };
     return SqlHelper.ExecuteNonQuery(WriteConnectionString,CommandType.Text,cmdText,parameters);
 }
Example #10
0
 private void Seach()
 {
     try{
         int recordCount = 0;
         Template filter = new Template();
         filter.TemplateName = GetRequestString("name");
         EasyUiGrid<Template> loginlogs = _TemplateService.GetTemplate(filter,PageSize,PageIndex,ref recordCount);
         Json(loginlogs);
     }
     catch{
         Json(new EasyUiGrid<Template>());
     }
 }