Пример #1
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="tablename">表名,例如:sys_employee</param>
        /// <param name="strJson">["10","11"]或{"key1":"201201010001","key2":"201201010001"}或者{"where_1":"input_dt>='20120101'"}</param>
        /// <param name="msg"></param>
        public static void Delete(string tablename, string strJson, ref string msg)
        {
            try
            {
                string database = str_dbDefault;
                if (database == "") database = "db_drsyn";
                tablename = database + "." + tablename;

                ws.data.jsonDal.OperateDataJsonHelper opdata = new ws.data.jsonDal.OperateDataJsonHelper();
                opdata.Gen_Delete(tablename, strJson, ref msg);
                string pstda = opdata.GenOperateJson();
                string rtn = SendHttpRequest.SendRequestByJson(pstda);
                if (rtn.Substring(0, 6) == "<error")
                {
                    msg = rtn;
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
        }
Пример #2
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="tablename">表名,例如:sys_employee</param>
 /// <param name="strJson">{a:'aaa',b:'bb'}或[{a:'aaa',b:'bb'},{a:'aaa1',b:'bb2'}]</param>
 /// <msg></msg>
 /// <returns>添加成功的id,例如:100或1,2,3</returns>
 public static string Insert(string tablename,string strJson,ref string msg)
 {
     try
     {
         string database = str_dbDefault;
         if (database == "") database = "db_drsyn";
         tablename = database + "." + tablename;
         ws.data.jsonDal.OperateDataJsonHelper opdata = new ws.data.jsonDal.OperateDataJsonHelper();
         opdata.Gen_Insert(tablename, strJson, ref msg);
         string pstda = opdata.GenOperateJson();
         string rtn = SendHttpRequest.SendRequestByJson(pstda);
         if (rtn.Substring(0, 6) == "<error")
         {
             msg = rtn;
             return "";
         }                
         return rtn.Replace("<succ msg='", "").Replace("'/>", "");
     }
     catch (Exception ex)
     {
         msg = ex.Message;
         return "";
     }
 }