public string DeleteOrder()
        {
            try
            {
                JArray        orderData = (JArray)JsonConvert.DeserializeObject(Request["formdata"]);
                List <string> listSqls  = new List <string>();
                string        strSql    = string.Empty;

                string code = string.Empty;
                if (orderData.Count > 0)
                {
                    foreach (JObject obj in orderData)
                    {
                        code += "'" + obj.Value <string>("CODE") + "',";

                        strSql = "delete from RESIDENT_ORDER where code='" + obj.Value <string>("CODE") + "'";
                        listSqls.Add(strSql);
                        strSql = @"delete from RESIDENT_DECLARATION d 
where d.ordercode='" + obj.Value <string>("CODE") + "'";
                        listSqls.Add(strSql);
                    }
                    code = code.Substring(0, code.Length - 1);
                    lock (objDelete)
                    {
                        strSql = "select code from RESIDENT_ORDER where code in (" + code + ") and status<>10";
                        DataTable dt = DBMgr.GetDataTable(strSql);
                        if (dt.Rows.Count > 0)
                        {
                            return("{success:false,msg:'保存失败:有单子状态大于已委托,不可删除'}");
                        }
                        DBMgr.ExecuteNonQueryBatch(listSqls);
                        return("{success:true}");
                    }
                }
                else
                {
                    return("{success:false,msg:'保存失败:未找到要删除的数据'}");
                }
            }
            catch (Exception ex)
            {
                return("{success:false,msg:'保存失败:" + ex.Message + "'}");
            }
        }
        public string batchMaintance(string codes, string id)
        {
            try
            {
                string status   = "";
                string time     = "";
                string userid   = "";
                string username = "";
                switch (id)
                {
                case "maintance_ACCEPTTIME":    //受理时间
                    status   = "15";
                    userid   = "ACCEPTUSERID";
                    username = "******";
                    time     = "ACCEPTTIME";
                    break;

                case "maintance_MOENDTIME":    //制单完成时间
                    status   = "30";
                    userid   = "MOENDID";
                    username = "******";
                    time     = "MOENDTIME";
                    break;

                case "maintance_COENDTIME":    //审核完成时间
                    status   = "50";
                    userid   = "COENDID";
                    username = "******";
                    time     = "COENDTIME";
                    break;

                case "maintance_RECOENDTIME":    //复审完成时间
                    status   = "55";
                    userid   = "RECOENDID";
                    username = "******";
                    time     = "RECOENDTIME";
                    break;

                case "maintance_REPSTARTTIME":    //申报时间
                    status   = "100";
                    userid   = "REPSTARTID";
                    username = "******";
                    time     = "REPSTARTTIME";
                    break;

                case "maintance_REPENDTIME":    //申报完成时间
                    status   = "120";
                    userid   = "REPENDID";
                    username = "******";
                    time     = "REPENDTIME";
                    break;

                case "maintance_PASSTIME":    //通关放行时间
                    status   = "160";
                    userid   = "PASSID";
                    username = "******";
                    time     = "PASSTIME";
                    break;
                }

                List <string> listSqls   = getMainSqls(codes, status, time, userid, username);
                int           successQty = 0;
                lock (objMaintance)
                {
                    successQty = DBMgr.ExecuteNonQueryBatch(listSqls);
                }

                return("{success:true,successQty:" + successQty + "}");
            }
            catch (Exception ex)
            {
                return("{success:false,msg:'保存失败:" + ex.Message + "'}");
            }
        }
        public string Create_Save()
        {
            try
            {
                JObject jsonOrderdata     = (JObject)JsonConvert.DeserializeObject(Request["formOrderdata"]);
                JObject jsonOrderTimedata = (JObject)JsonConvert.DeserializeObject(Request["formOrderTimedata"]);
                JArray  jarryDeclData     = (JArray)JsonConvert.DeserializeObject(Request["formDeclData"]);
                JObject json_user         = Extension.Get_UserInfo(HttpContext.User.Identity.Name);

                string code = jsonOrderdata.Value <string>("CODE");//

                //检查是否有重复的 合同号和企业编号
                if (checkContact_CusNO_BusiUnit_isRepeat
                        (code, jsonOrderdata.Value <string>("CONTRACTNO").Trim(), jsonOrderdata.Value <string>("CUSNO").Trim(),
                        jsonOrderdata.Value <string>("BUSIUNITCODE")))
                {
                    return("{success:false,msg:'保存失败:企业编号或者合同号重复,不可保存'}");
                }

                string flag = string.Empty;

                string DECLCODEQTY     = string.Empty;
                string DECLARATIONCODE = string.Empty;
                int    sheetnum        = 0;//SHEETNUM
                for (int i = 0; i < jarryDeclData.Count; i++)
                {
                    if (jarryDeclData[i]["SHEETNUM"].ToStringSafe() != string.Empty)
                    {
                        sheetnum += Convert.ToInt32(jarryDeclData[i]["SHEETNUM"].ToStringSafe());
                    }
                }

                if (jarryDeclData.Count > 0)
                {
                    DECLCODEQTY = jarryDeclData.Count.ToString();
                    if (jarryDeclData.Count == 1)
                    {
                        DECLARATIONCODE = jarryDeclData[0].Value <string>("DECLARATIONCODE");
                    }
                    else
                    {
                        DECLARATIONCODE = jarryDeclData[0].Value <string>("DECLARATIONCODE") + "...";;
                    }
                }
                string status = string.Empty;

                List <string> listSqls = new List <string>();
                string        strSql   = string.Empty;
                if (code == string.Empty)
                {
                    code = Extension.getOrderCode();
                    flag = "add";
                }
                else
                {
                    flag = "modify";

                    strSql = "delete from RESIDENT_ORDER where code='" + code + "'";
                    listSqls.Add(strSql);
                    strSql = "delete from RESIDENT_DECLARATION where ORDERCODE='" + code + "'";
                    listSqls.Add(strSql);
                }
                //保存业务信息
                string BUSIUNITNAME = jsonOrderdata.Value <string>("BUSIUNITNAME");
                string MANIFEST     = jsonOrderdata.Value <string>("MANIFEST");
                string INSPFLAG     = jsonOrderdata.Value <string>("INSPFLAG");
                string CHECKFLAG    = jsonOrderdata.Value <string>("CHECKFLAG");
                string CHECKREMARK  = jsonOrderdata.Value <string>("CHECKREMARK");
                if (MANIFEST == "on" || MANIFEST == "true" || MANIFEST == "1")
                {
                    MANIFEST = "1";
                }
                else
                {
                    MANIFEST = "0";
                }

                if (INSPFLAG == "on" || INSPFLAG == "true" || INSPFLAG == "1")
                {
                    INSPFLAG = "1";
                }
                else
                {
                    INSPFLAG = "0";
                }
                if (CHECKFLAG == "on" || CHECKFLAG == "true" || CHECKFLAG == "1")
                {
                    CHECKFLAG = "1";
                }
                else
                {
                    CHECKFLAG = "0";
                }
                if (CHECKREMARK == null)
                {
                    CHECKREMARK = string.Empty;
                }

                if (BUSIUNITNAME.Contains("("))
                {
                    BUSIUNITNAME = BUSIUNITNAME.Split('(')[0];
                }
                strSql = @"insert into RESIDENT_ORDER (code,cusno,busitype,tradeway,portcode,busiunitcode,busiunitname,goodsnum,goodgw,contractno,
TOTALNO,DIVIDENO,MANIFEST,INSPFLAG,REMARK,RECEIVERUNITCODE,RECEIVERUNITNAME,CREATETIME,DECLCODEQTY,DECLARATIONCODE,SHIPPINGAGENT, INSPREMARK, COMMODITYNUM,UNITYCODE,CHECKFLAG,CHECKREMARK,SHEETNUM) 
            values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}',sysdate,'{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}')";
                strSql = string.Format(strSql, code, jsonOrderdata.Value <string>("CUSNO").Trim(), jsonOrderdata.Value <string>("BUSITYPE"), jsonOrderdata.Value <string>("TRADEWAY2")
                                       , jsonOrderdata.Value <string>("PORTCODE"), jsonOrderdata.Value <string>("BUSIUNITCODE"), BUSIUNITNAME
                                       , jsonOrderdata.Value <string>("GOODSNUM2"), jsonOrderdata.Value <string>("GOODGW2")
                                       , jsonOrderdata.Value <string>("CONTRACTNO").Trim(), jsonOrderdata.Value <string>("TOTALNO").Trim(), jsonOrderdata.Value <string>("DIVIDENO").Trim()
                                       , MANIFEST, INSPFLAG, jsonOrderdata.Value <string>("REMARK2").Trim()
                                       , json_user.Value <string>("CUSTOMERCODE"), json_user.Value <string>("CUSTOMERNAME"), DECLCODEQTY, DECLARATIONCODE
                                       , jsonOrderdata.Value <string>("SHIPPINGAGENT").Trim(), jsonOrderdata.Value <string>("INSPREMARK").Trim(), jsonOrderdata.Value <string>("COMMODITYNUM")
                                       , jsonOrderdata.Value <string>("UNITYCODE").Trim(), CHECKFLAG, CHECKREMARK.Trim(), sheetnum);
                listSqls.Add(strSql);

                //  strSql="update RESIDENT_ORDER set ";
                strSql = string.Empty;
                string sysdate = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                status = "10";                                                                                                        //已委托
                if (jsonOrderTimedata.Value <string>("SUBMITTIME") != "null" && jsonOrderTimedata.Value <string>("SUBMITTIME") != "") //
                {
                    strSql += " SUBMITTIME=to_date('" + jsonOrderTimedata.Value <string>("SUBMITTIME") + "','yyyy/mm/dd hh24:mi:ss'),SUBMITUSERID='" + jsonOrderTimedata.Value <string>("SUBMITUSERID") + "',SUBMITUSERNAME='******', ";
                }
                else
                {
                    strSql += " SUBMITTIME=to_date('" + sysdate + "','yyyy/mm/dd hh24:mi:ss'),SUBMITUSERID='" + json_user.Value <string>("ID") + "',SUBMITUSERNAME='******', ";
                }
                if (jsonOrderTimedata.Value <string>("ACCEPTTIME") != "null" && jsonOrderTimedata.Value <string>("ACCEPTTIME") != "")
                {
                    status  = "15";//已受理
                    strSql += " ACCEPTTIME=to_date('" + jsonOrderTimedata.Value <string>("ACCEPTTIME") + "','yyyy/mm/dd hh24:mi:ss'),ACCEPTUSERID='" + jsonOrderTimedata.Value <string>("ACCEPTUSERID") + "',ACCEPTUSERNAME='******', ";
                }
                if (jsonOrderTimedata.Value <string>("MOENDTIME") != "null" && jsonOrderTimedata.Value <string>("MOENDTIME") != "")
                {
                    status  = "30";//制单完成
                    strSql += " MOENDTIME=to_date('" + jsonOrderTimedata.Value <string>("MOENDTIME") + "','yyyy/mm/dd hh24:mi:ss'),MOENDID='" + jsonOrderTimedata.Value <string>("MOENDID") + "',MOENDNAME='" + jsonOrderTimedata.Value <string>("MOENDNAME") + "', ";
                }
                if (jsonOrderTimedata.Value <string>("COENDTIME") != "null" && jsonOrderTimedata.Value <string>("COENDTIME") != "")
                {
                    status  = "50";//审核完成
                    strSql += " COENDTIME=to_date('" + jsonOrderTimedata.Value <string>("COENDTIME") + "','yyyy/mm/dd hh24:mi:ss'),COENDID='" + jsonOrderTimedata.Value <string>("COENDID") + "',COENDNAME='" + jsonOrderTimedata.Value <string>("COENDNAME") + "', ";
                }
                if (jsonOrderTimedata.Value <string>("RECOENDTIME") != "null" && jsonOrderTimedata.Value <string>("RECOENDTIME") != "")
                {
                    status  = "55";//复审完成
                    strSql += " RECOENDTIME=to_date('" + jsonOrderTimedata.Value <string>("RECOENDTIME") + "','yyyy/mm/dd hh24:mi:ss'),RECOENDID='" + jsonOrderTimedata.Value <string>("RECOENDID") + "',RECOENDNAME='" + jsonOrderTimedata.Value <string>("RECOENDNAME") + "', ";
                }
                if (jsonOrderTimedata.Value <string>("REPSTARTTIME") != "null" && jsonOrderTimedata.Value <string>("REPSTARTTIME") != "")
                {
                    status  = "100";//已申报
                    strSql += " REPSTARTTIME=to_date('" + jsonOrderTimedata.Value <string>("REPSTARTTIME") + "','yyyy/mm/dd hh24:mi:ss'),REPSTARTID='" + jsonOrderTimedata.Value <string>("REPSTARTID") + "',REPSTARTNAME='" + jsonOrderTimedata.Value <string>("REPSTARTNAME") + "', ";
                }
                if (jsonOrderTimedata.Value <string>("REPENDTIME") != "null" && jsonOrderTimedata.Value <string>("REPENDTIME") != "")
                {
                    status  = "120";//申报完成
                    strSql += " REPENDTIME=to_date('" + jsonOrderTimedata.Value <string>("REPENDTIME") + "','yyyy/mm/dd hh24:mi:ss'),REPENDID='" + jsonOrderTimedata.Value <string>("REPENDID") + "',REPENDNAME='" + jsonOrderTimedata.Value <string>("REPENDNAME") + "', ";
                }
                if (jsonOrderTimedata.Value <string>("ARRANGETIME") != "null" && jsonOrderTimedata.Value <string>("ARRANGETIME") != "")
                {
                    //status = "120";//申报完成
                    strSql += " ARRANGETIME=to_date('" + jsonOrderTimedata.Value <string>("ARRANGETIME") + "','yyyy/mm/dd hh24:mi:ss'),ARRANGEID='" + jsonOrderTimedata.Value <string>("ARRANGEID") + "',ARRANGENAME='" + jsonOrderTimedata.Value <string>("ARRANGENAME") + "', ";
                }
                if (jsonOrderTimedata.Value <string>("PASSTIME") != "null" && jsonOrderTimedata.Value <string>("PASSTIME") != "")
                {
                    status  = "160";//通关放行
                    strSql += " PASSTIME=to_date('" + jsonOrderTimedata.Value <string>("PASSTIME") + "','yyyy/mm/dd hh24:mi:ss'),PASSID='" + jsonOrderTimedata.Value <string>("PASSID") + "',PASSNAME='" + jsonOrderTimedata.Value <string>("PASSNAME") + "', ";
                }
                if (strSql != string.Empty)
                {
                    //strSql = strSql.Trim();
                    //strSql = strSql.Substring(0, strSql.Length - 1);
                    strSql = "update RESIDENT_ORDER set " + strSql + " status=" + status + " where code='" + code + "'";
                    listSqls.Add(strSql);
                }

                //保存表体
                int count = 1;
                foreach (JObject obj in jarryDeclData)
                {
                    strSql = @"insert into RESIDENT_DECLARATION (ordercode,declarationcode,tradeway,sheetnum,modifyflag,goodsnum,goodgw,customsstatus,createtime,tradewayNAME,no) 
values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',sysdate,'{8}','{9}')";
                    strSql = string.Format(strSql, code, obj.Value <string>("DECLARATIONCODE"), obj.Value <string>("TRADEWAY"), obj.Value <string>("SHEETNUM")
                                           , obj.Value <string>("MODIFYFLAG"), obj.Value <string>("GOODSNUM"), obj.Value <string>("GOODGW"), obj.Value <string>("CUSTOMSSTATUS")
                                           , obj.Value <string>("TRADEWAYNAME"), count);
                    listSqls.Add(strSql);
                    count++;
                }
                DBMgr.ExecuteNonQueryBatch(listSqls);
                //保存成功后在重新拉一下数据
                return(loadrecord(code));
            }
            catch (Exception ex)
            {
                return("{success:false,msg:'保存失败:" + ex.Message + "'}");
            }
        }