• Ext MVC 增删改 【公司用】


    在上一篇博客的基础上继续写

     1 //1) Controller 
     2     public string Add()//add添加方法
     3         {
     4             Models.CCC item = JsonTool.JsonToObject<Models.CCC>(this.RequestParam());
     5             string Message = "";
     6             if (CCCBLL.Create.Add(item, out Message))
     7             {
     8                 return "{"success":true}";
     9             }
    10             else
    11             {
    12                 return "{"success":false,"error":"添加失败:" + Message.Replace(""", "") + ""}";
    13             }
    14         }
    15 
    16 //2) CCCDAL
    17     public bool Add(Models.CCC item, out BaseClass.Message.MSG Message)
    18         {
    19             string sql = "insert into CCC (Name,Number,Country,Configure,Price,Time,Note) values
    20 
    21 (@Name,@Number,@Country,@Configure,@Price,@Time,@Note)";
    22 
    23             DBParameter[] param ={
    24                                      DBParameter.Create("Name",DbType.String,item.Name),
    25                                      DBParameter.Create("Number",DbType.String,item.Number),
    26                                      DBParameter.Create("Country",DbType.String,item.Country),
    27                                      DBParameter.Create("Configure",DbType.String,item.Configure),
    28                                      DBParameter.Create("Price",DbType.String,item.Price),
    29                                      DBParameter.Create("Time",DbType.String,item.Time),
    30                                      DBParameter.Create("Note",DbType.String,item.Note)
    31                                 };
    32             bool result = sop.ReturnExecuteCount(sql, false, param) > 0 ? true : false;
    33             Message = sop.Parent.Parent.msg;
    34             return result;
    35         }
    36 //3) CCCBLL
    37       public bool Add(Models.CCC item, out string Message)
    38         {
    39             bool result = DAL.Add(item, out OpMessage);
    40             Message = OpMessage.MessageError;
    41             //日志
    42             AddSysLog(OpMessage, "车车车添加", "飞车");
    43             return result;
    44         }

     1 //1) Controller 
     2     public string Delete()//删除方法
     3         {
     4             Models.CCC item = JsonTool.JsonToObject<Models.CCC>(this.RequestParam());
     5             string Message = "";
     6             if (CCCBLL.Create.Delete(out Message, item.Ids.ToString()))
     7             {
     8                 return "{"success":true}";
     9             }
    10             else
    11             {
    12                 return "{"success":false,"error:":"删除失败:" + Message.Replace(""", "") + ""}";
    13             }
    14         }
    15 
    16 //2) CCCDAL
    17     public bool Delete(out BaseClass.Message.MSG Message, params object[] PrimaryKey)
    18         {
    19             List<IDbCommand> mycmds = new List<IDbCommand>();
    20             string sql = "";
    21             foreach (object o in PrimaryKey)
    22             {
    23                 sql = "delete CCC where Ids = @Ids";
    24                 mycmds.Add(sop.ReturnCommand(sql, false, DBParameter.Create("Ids", DbType.Int32, o)));
    25             }
    26             bool result = sop.RunTrans(mycmds);
    27 
    28             Message = sop.Parent.Parent.msg;
    29             return result;
    30         }
    31 //3) CCCBLL
    32       public bool Delete(out string Message, string Ids)
    33         {
    34             bool result = false;
    35             //是否删除
    36             bool temp = false;
    37             if (temp)
    38             {
    39                 Message = "订单{0}正在使用中,无法删除";
    40             }
    41             else
    42             {
    43                 Ids = Ids.Replace(" ", "");
    44                 result = DAL.Delete(out OpMessage, Ids.Split(','));
    45                 Message = OpMessage.MessageError;
    46             }
    47             //日志
    48             AddSysLog(OpMessage, "车车车删除", "飞车");
    49             return result;
    50         }

     1 //1) Controller 
     2     public string Edit()//修改方法
     3         {
     4             Models.CCC item = JsonTool.JsonToObject<Models.CCC>(this.RequestParam());
     5             string Message = "";
     6 
     7             if (CCCBLL.Create.Edit(item, out Message))
     8             {
     9                 return "{"success":true}";
    10             }
    11             else
    12             {
    13                 return "{"success":false,"error":"编辑失败:" + Message.Replace(""", "") + ""}";
    14             }
    15         }
    16 
    17 //2) CCCDAL
    18      public bool Edit(Models.CCC item, out BaseClass.Message.MSG Message)
    19         {
    20             string sql = " update  CCC set 
    21 
    22 Name=@Name,Number=@Number,Country=@Country,Configure=@Configure,Price=@Price,Time=@Time,Note=@Note where Ids=@Ids";
    23             DBParameter[] param ={
    24                                 DBParameter.Create("Ids",DbType.Int32,item.Ids),
    25                                 DBParameter.Create("Name",DbType.String,item.Name),
    26                                 DBParameter.Create("Number",DbType.String,item.Number),
    27                                 DBParameter.Create("Country",DbType.String,item.Country),
    28                                 DBParameter.Create("Configure",DbType.String,item.Configure),
    29                                 DBParameter.Create("Price",DbType.String,item.Price),
    30                                 DBParameter.Create("Time",DbType.String,item.Time),
    31                                 DBParameter.Create("Note",DbType.String,item.Note)
    32                                 };
    33             bool result = sop.ReturnExecuteCount(sql, false, param) > 0 ? true : false;
    34             Message = sop.Parent.Parent.msg;
    35             return result;
    36         }
    37 //3) CCCBLL
    38       public bool Edit(Models.CCC item, out string Message)
    39         {
    40             bool result = DAL.Edit(item, out OpMessage);
    41             Message = OpMessage.MessageError;
    42             //日志
    43             AddSysLog(OpMessage, "车车车编辑", "飞车");
    44             return result;
    45         }
  • 相关阅读:
    关于word开发中字体大小
    WPF学习笔记
    C#各种配置文件使用,操作方法总结
    web.config和app.config使用
    微软 WordXML格式初步分析
    面向对象—C#高级编程(第10版)学习笔记8
    C#编程的推荐规则和约定—C#高级编程(第10版)学习笔记7
    C#基础—C#高级编程(第10版)学习笔记6
    .Net 应用程序体系结构—C#高级编程(第10版)学习笔记5
    通俗易懂说编程:.Net Core是什么、有何用?
  • 原文地址:https://www.cnblogs.com/baimangguo/p/7976344.html
Copyright © 2020-2023  润新知