Example #1
0
        public static string check_audit_save(string ordercode, string checktime, string checkname, string checkid, string checkremark
                                              , string auditflagtime, string auditflagname, string auditflagid, string auditcontent)
        {
            MethodSvc.MethodServiceClient msc = new MethodSvc.MethodServiceClient();

            System.Uri Uri      = new Uri("ftp://" + ConfigurationManager.AppSettings["FTPServer"] + ":" + ConfigurationManager.AppSettings["FTPPortNO"]);
            string     UserName = ConfigurationManager.AppSettings["FTPUserName"];
            string     Password = ConfigurationManager.AppSettings["FTPPassword"];
            FtpHelper  ftp      = new FtpHelper(Uri, UserName, Password);

            string        username = "******"; string userid = "763"; string realname = "昆山吉时报关有限公司";
            string        sql = ""; string resultmsg = "[]";
            string        feoremark = "";//记录是否需要调用费用接口
            List <string> delfile   = new List <string>();

            DBSession db = new DBSession();

            sql = @"select code,entrusttype,declstatus,inspstatus,ischeck,auditflag,checkpic      
                    from list_order lo where lo.code='" + ordercode + "'";
            DataTable dt_order = db.QuerySignle(sql);
            string    db_ischeck = dt_order.Rows[0]["ISCHECK"].ToString();
            string    db_auditflag = dt_order.Rows[0]["AUDITFLAG"].ToString();
            string    db_checkpic = dt_order.Rows[0]["CHECKPIC"].ToString();
            int       ischeck = 0; int auditflag = 0; int checkpic = db_checkpic == "1" ? 1 : 0;

            DataTable dt = db.QuerySignle("select * from list_attachment where ordercode='" + ordercode + "' and filetype='67'");

            foreach (DataRow dr in dt.Rows)
            {
                delfile.Add(dr["FILENAME"] + "");
            }

            db.Dispose();

            try
            {
                db = new DBSession();
                db.BeginTransaction();

                if (checktime != "")
                {
                    ischeck = 1;
                    if (db_ischeck != "1")
                    {
                        feoremark += "list_order.ischeck查验标志为1";

                        sql = @"insert into list_updatehistory(id,UPDATETIME,TYPE
                                            ,ORDERCODE,USERID,NEWFIELD,NAME,CODE,FIELD,FIELDNAME) 
                                    values(LIST_UPDATEHISTORY_ID.nextval,sysdate,'1'
                                            ,'" + ordercode + "','" + userid + "','1','" + realname + "','" + ordercode + "','ISCHECK','报关查验'"
                              + ")";
                        db.QuerySignle(sql);
                    }

                    sql = @"update list_order 
                            set ischeck=1,declcheckid='{1}',declcheckname='{2}',declchecktime=to_date('{3}','yyyy-MM-dd HH24:mi:ss'),checkremark='{4}'  
                            where code='{0}'";
                    sql = string.Format(sql, ordercode, checkid, checkname, checktime, checkremark);
                    db.QuerySignle(sql);
                }
                else
                {
                    checkpic = 0;
                    if (db_ischeck == "1")
                    {
                        feoremark += "list_order.ischeck查验标志为0";

                        sql = @"update list_order 
                            set ischeck=0,declcheckid=null,declcheckname=null,declchecktime=null,checkpic=0,checkremark='' 
                            where code='" + ordercode + "'";
                        db.QuerySignle(sql);

                        sql = @"insert into list_updatehistory(id,UPDATETIME,TYPE
                                            ,ORDERCODE,USERID,NEWFIELD,NAME,CODE,FIELD,FIELDNAME) 
                                    values(LIST_UPDATEHISTORY_ID.nextval,sysdate,'1'
                                            ,'" + ordercode + "','" + userid + "','0','" + realname + "','" + ordercode + "','ISCHECK','报关查验'"
                              + ")";
                        db.QuerySignle(sql);
                    }

                    sql = "delete LIST_ATTACHMENT where ordercode='" + ordercode + "' and filetype='67'";
                    db.QuerySignle(sql);
                }

                if (auditflagtime != "")
                {
                    auditflag = 1;
                    if (db_auditflag != "1")
                    {
                        feoremark += "list_order.auditflag稽核标志修改为1";

                        sql = @"insert into list_updatehistory(id,UPDATETIME,TYPE
                                            ,ORDERCODE,USERID,NEWFIELD,NAME,CODE,FIELD,FIELDNAME) 
                                    values(LIST_UPDATEHISTORY_ID.nextval,sysdate,'1'
                                            ,'" + ordercode + "','" + userid + "','1','" + realname + "','" + ordercode + "','AUDITFLAG','稽核标志'"
                              + ")";
                        db.QuerySignle(sql);
                    }

                    sql = @"update list_order 
                            set auditflag=1,auditflagid='{1}',auditflagname='{2}',auditflagtime=to_date('{3}','yyyy-MM-dd HH24:mi:ss'),auditcontent='{4}' 
                            where code='{0}'";
                    sql = string.Format(sql, ordercode, auditflagid, auditflagname, auditflagtime, auditcontent);
                    db.QuerySignle(sql);
                }
                else
                {
                    if (db_auditflag == "1")
                    {
                        feoremark += "list_order.auditflag稽核标志修改为0";

                        sql = @"update list_order 
                            set auditflag=0,auditflagid=null,auditflagname=null,auditflagtime=null,auditcontent=''  
                            where code='" + ordercode + "'";
                        db.QuerySignle(sql);

                        sql = @"insert into list_updatehistory(id,UPDATETIME,TYPE
                                            ,ORDERCODE,USERID,NEWFIELD,NAME,CODE,FIELD,FIELDNAME) 
                                    values(LIST_UPDATEHISTORY_ID.nextval,sysdate,'1'
                                            ,'" + ordercode + "','" + userid + "','0','" + realname + "','" + ordercode + "','AUDITFLAG','稽核标志'"
                              + ")";
                        db.QuerySignle(sql);
                    }
                }

                db.Commit();
                foreach (string item in delfile)//提交之后删除文件
                {
                    ftp.DeleteFile(item);
                }

                resultmsg = "[{\"ISCHECK\":" + ischeck + ",\"DECLCHECKTIME\":'" + checktime + "',\"CHECKPIC\":" + checkpic
                            + ",\"AUDITFLAG\":" + auditflag + ",\"AUDITFLAGTIME\":'" + auditflagtime + "'}]";
            }
            catch (Exception ex)
            {
                db.Rollback();
            }
            finally
            {
                db.Dispose();
            }


            //============================================================================================================费用接口
            if (feoremark != "")
            {
                //add 20180115 费用异常接口
                if (dt_order.Rows[0]["entrusttype"].ToString() == "03")
                {
                    if (Convert.ToInt32(dt_order.Rows[0]["declstatus"].ToString()) >= 160 && Convert.ToInt32(dt_order.Rows[0]["inspstatus"].ToString()) >= 120)
                    {
                        msc.FinanceExceptionOrder(ordercode, username, feoremark);
                    }
                }
                else
                {
                    if (Convert.ToInt32(dt_order.Rows[0]["declstatus"].ToString()) >= 160)
                    {
                        msc.FinanceExceptionOrder(ordercode, username, feoremark);
                    }
                }
            }
            //============================================================================================================
            return(resultmsg);
        }