using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
namespace DAL
{
    public class ClsGy_BarCodeBill_View:DBUtility.ClsGy_Base_View
    {
        
        //
        public Model.ClsGy_BarCodeBill_WMS_Model omodel = new Model.ClsGy_BarCodeBill_WMS_Model();
        public Model.ClsGy_BarCodeBill_WMS_Model_View omodel_View = new Model.ClsGy_BarCodeBill_WMS_Model_View();
        public  SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); 
        public ClsGy_BarCodeBill_View()
        {
            base.MvarReportTitle = "条码档案设置";
            base.MvarItemKey = "Gy_BarCodeBill";
            base.SQLName = "Select HItemID,HNumber 条码档案代码,HName 条码档案 from Gy_BarCodeBill where HStopflag=0 Order by HItemID ";
        }
        //
        public void Dispose()
        {
            GC.SuppressFinalize(this);
        }
        //
         
        //返回项目信息
        public override bool GetInfoByID(Int64 sItemID)
        {
            DataSet DS ;
            try
            {
                DS = oCn.RunProcReturn("Select * from " + MvarItemKey + " Where HItemID='" + sItemID + "'", MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count  == 0)
                    return false;
                else
                {
                    return GetInfo(DS);
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
        //根据代码返回项目信息
        public override bool GetInfoByNumber(string sNumber)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from " + MvarItemKey + " Where HBarCode='" + sNumber + "'", MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return false;
                else
                {
                    return GetInfo(DS);
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        } 
        //返回项目信息
        public override bool GetInfo(DataSet Ds)
        {
            try
            {
                omodel = new Model.ClsGy_BarCodeBill_WMS_Model();
                omodel.HItemID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HItemID"]);
                omodel.HBarCode = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBarCode"]);
                omodel.HBarCodeType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBarCodeType"]);
                omodel.HBatchNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBatchNo"]);
                omodel.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]);
                omodel.HUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HUnitID"]);
                omodel.HQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HQty"]);
                omodel.HSupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSupID"]);
                omodel.HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HGroupID"]);
                omodel.HRemark = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"]);
                omodel.HSourceBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceBillNo"]);
                //
                omodel.HSourceBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceBillType"]);
                omodel.HSourceInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceInterID"]);
                omodel.HSourceEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceEntryID"]);
                omodel.HMTONo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMTONo"]);
                return true;
 
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
        //根据代码返回项目信息
        public bool GetInfoByNumber_View(string sNumber)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from h_v_Gy_BarCodeBill Where HBarCode='" + sNumber + "'", "h_v_Gy_BarCodeBill", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return false;
                else
                {
                    return GetInfo_View(DS);
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
        /// 
        /// 根据代码返回项目信息 ForReport
        /// 
        /// 
        /// 
        public bool GetInfoForReportByNumber_View(string sNumber)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from h_v_Gy_BarCodeBillForReport Where HBarCode='" + sNumber + "'", "h_v_Gy_BarCodeBillForReport", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return false;
                else
                {
                    return GetInfo_View(DS);
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
        //返回项目信息
        public bool GetInfo_View(DataSet Ds)
        {
            try
            {
                omodel_View = new Model.ClsGy_BarCodeBill_WMS_Model_View();
                omodel_View.HItemID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HItemID"]);
                omodel_View.HBarCode = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBarCode"]);
                omodel_View.HBarCodeType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBarCodeType"]);
                omodel_View.HBatchNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBatchNo"]);
                omodel_View.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]);
                omodel_View.HMaterNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMaterNumber"]);
                omodel_View.HMaterName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMaterName"]);
                omodel_View.HMaterModel = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMaterModel"]);
                omodel_View.HUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HUnitID"]);
                omodel_View.HUnitName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HUnitName"]);
                omodel_View.HQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HQty"]);
                omodel_View.HinitQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HinitQty"]);
                omodel_View.HSupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSupID"]);
                omodel_View.HSupName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSupName"]);
                omodel_View.HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HGroupID"]);
                omodel_View.HGroupName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HGroupName"]);
                omodel_View.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"]);
                omodel_View.HDeptName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HDeptName"]);
                omodel_View.HRemark = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"]);
                omodel_View.HSourceBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceBillNo"]);
                omodel_View.HBarCodeStatus = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBarCodeStatus"]);
                //
                omodel_View.HSourceBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceBillType"]);
                omodel_View.HSourceInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceInterID"]);
                omodel_View.HSourceEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceEntryID"]);
                //
                omodel_View.HWHID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HWhID"]);
                omodel_View.HWHName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HWhName"]);
                omodel_View.HDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HDate"]);
                omodel_View.HInstructID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInstructID"]);
                omodel_View.HInstructNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInstructNo"]);
                omodel_View.HSeOrderBillID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSeOrderBillID"]);
                omodel_View.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSeOrderBillNo"]);
                //omodel_View.HCheckerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckerID"]);
                omodel_View.HAuxPropID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HAuxPropID"]);
                omodel_View.HAuxPropName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HAuxPropName"]);
                omodel_View.HMTONo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMTONo"]);
                omodel_View.HSTOCKORGID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSTOCKORGID"]);
                omodel_View.HOWNERID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HOWNERID"]);
                return true;
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
    }
}