using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Data;

namespace SiaSun.LMS.Implement
{
    /// <summary>
    /// 申请下架
    /// </summary>
    public class ApplyRollBack : ApplyBase
    {
        public bool ApplyHandle(Model.IO_CONTROL_APPLY mIO_CONTROL_APPLY, out string sResult)
        {
            bool  bResult = true;
                  sResult = string.Empty;
            int   START_CELL_ID = 0;
            int   end_cell_id = 0;

            try
            {
                mIO_CONTROL_APPLY.STOCK_BARCODE = string.Empty;
                string STOCK_BARCODE = mIO_CONTROL_APPLY.STOCK_BARCODE.ToUpper();

                bResult = this.Validate(mIO_CONTROL_APPLY, out START_CELL_ID,out sResult);               

                this._log.Fatal(string.Format("成功申请{0} {1} {2} {3}", mIO_CONTROL_APPLY.CONTROL_APPLY_ID, mIO_CONTROL_APPLY.STOCK_BARCODE,mIO_CONTROL_APPLY.CONTROL_ID,mIO_CONTROL_APPLY.DEVICE_CODE));

               //查申请站台ID
                string sql1 = string.Format("select * from wh_cell where cell_code='{0}'", mIO_CONTROL_APPLY.DEVICE_CODE);
                DataTable dt1 = this.GetList(sql1);

                //查14003申请个数
                string sql2 = string.Format("select * from io_control_apply where DEVICE_CODE='{0}'", mIO_CONTROL_APPLY.DEVICE_CODE);
                DataTable dt2 = this.GetList(sql2);

                this.WriteHisData(mIO_CONTROL_APPLY, mIO_CONTROL_APPLY.CONTROL_ERROR_TEXT);
                
     
            }

            catch (Exception ex)
            {
                bResult = false;

                sResult = ex.Message;

                this._log.Fatal(string.Format("调用方法{0}发生异常。", MethodBase.GetCurrentMethod().Name), ex);
            }

            //finally
            //{
            //    this.WriteHisData(mIO_CONTROL_APPLY, sResult);
            //}

            return bResult;
        }

    }
}