using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace BLL
{
    public class ClsBaseSelect_InterFace
    {
        //结算方式
        /// 
        /// 结算方式
        /// 
        /// 
        public static void SetTextBySettleStyle(TextBox txt)
        {
            DAL.ClsIF_SettleStyle_View oSettleStyle = new DAL.ClsIF_SettleStyle_View();
            if (oSettleStyle.RefreshView())
            {
                txt.Text = oSettleStyle.oModel.HName;
                txt.Tag = oSettleStyle.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //采购方式
        /// 
        /// 采购方式
        /// 
        /// 
        public static void SetTextByPoStockStyle(TextBox txt)
        {
            DAL.ClsIF_PoStockStyle_View oPoStockStyle = new DAL.ClsIF_PoStockStyle_View();
            if (oPoStockStyle.RefreshView())
            {
                txt.Text = oPoStockStyle.oModel.HName;
                txt.Tag = oPoStockStyle.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //币别
        /// 
        /// 币别
        /// 
        /// 
        /// 
        public static void SetTextByCur(TextBox txt, TextBox txtHRate)
        {
            DAL.ClsIF_Currency_View oCur = new DAL.ClsIF_Currency_View();
            if (oCur.RefreshView())
            {
                if (oCur.GetInfoByID(oCur.oModel.HItemID))
                {
                    txt.Text = oCur.omodel.HName;
                    txt.Tag = oCur.omodel.HItemID.ToString();
                    txtHRate.Text = oCur.omodel.HExchangeRate.ToString();
                }
            }
            else
            {
                txt.Text = "";
                txtHRate.Text = "1";
            }
        }
        ////选择接口类工序-按任务单
        ///// 
        ///// 选择接口类工序-按任务单
        ///// 
        ///// 
        //public static void SetTextByProc_ICMO(TextBox txt, long HICMOInterID)
        //{
        //    //DAL.ClsIF_Process_View oProc = new DAL.ClsIF_Process_View();
        //    DAL.ClsK3_Process_View oProc = new DAL.ClsK3_Process_View();
        //    if (oProc.RefreshView(" and HItemID in (select HProcID  from K3_ICMOBillList_HProcID where hmainid=" + HICMOInterID + ")"))
        //    {
        //        txt.Text = oProc.oModel.HName;
        //        txt.Tag = oProc.oModel.HItemID.ToString();
        //    }
        //    else
        //    {
        //        txt.Text = "";
        //    }
        //}
        //选择接口类职员-按班组
        /// 
        /// 选择接口类职员-按班组
        /// 
        /// 
        public static void SetTextByEmp_Group(TextBox txt, long HGroupID)
        {
            DAL.ClsIF_Employee_View oEmp = new DAL.ClsIF_Employee_View();
            if (oEmp.RefreshView("and HGroupID=" + HGroupID))
            {
                txt.Text = oEmp.oModel.HName;
                txt.Tag = oEmp.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //接口类职员-网格-按班组
        /// 
        /// 接口类职员-网格-按班组
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public static void SetGridByEmp_Group(DataGridView grdMain, int i, int HEmpIDCol, int HEmpNumberCol, int HEmpNameCol, long HGroupID)
        {
            DAL.ClsIF_Employee_View oEmp = new DAL.ClsIF_Employee_View();
            if (oEmp.RefreshView("and HGroupID=" + HGroupID))
            {
                if (oEmp.GetInfoByID(oEmp.oModel.HItemID))
                {
                    grdMain.Rows[i].Cells[HEmpIDCol].Value = oEmp.omodel.HItemID.ToString();
                    grdMain.Rows[i].Cells[HEmpNumberCol].Value = oEmp.omodel.HNumber;
                    grdMain.Rows[i].Cells[HEmpNameCol].Value = oEmp.omodel.HName;
                }
                else
                {
                    grdMain.Rows[i].Cells[HEmpIDCol].Value = "0";
                    grdMain.Rows[i].Cells[HEmpNumberCol].Value = "";
                    grdMain.Rows[i].Cells[HEmpNameCol].Value = "";
                }
            }
            else
            {
                grdMain.Rows[i].Cells[HEmpIDCol].Value = "0";
                grdMain.Rows[i].Cells[HEmpNumberCol].Value = "";
                grdMain.Rows[i].Cells[HEmpNameCol].Value = "";
            }
        }
        //供应商
        /// 
        /// 供应商
        /// 
        /// 
        public static void SetTextBySupplier(TextBox txt)
        {
            DAL.ClsIF_Supplier_View oSupplier = new DAL.ClsIF_Supplier_View();
            if (oSupplier.RefreshView())
            {
                txt.Text = oSupplier.oModel.HName;
                txt.Tag = oSupplier.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //供应商   递入过滤条件
        /// 
        /// 供应商   递入过滤条件
        /// 
        /// 
        public static void SetTextBySupplier(TextBox txt, string sWhere)
        {
            DAL.ClsIF_Supplier_View oSupplier = new DAL.ClsIF_Supplier_View();
            if (oSupplier.RefreshView(sWhere))
            {
                txt.Text = oSupplier.oModel.HName;
                txt.Tag = oSupplier.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //选择接口类工序-按任务单
        /// 
        /// 选择接口类工序-按任务单
        /// 
        /// 
        public static void SetTextByProc_ICMO(TextBox txt, long HICMOInterID)
        {
            DAL.ClsIF_Process_View oProc = new DAL.ClsIF_Process_View();
            if (oProc.RefreshView(" and HItemID in (select HProcID  from K3_ICMOBillList_HProcID where hmainid=" + HICMOInterID + ")"))
            {
                txt.Text = oProc.oModel.HName;
                txt.Tag = oProc.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //选择接口类客户
        /// 
        /// 选择接口类客户
        /// 
        /// 
        public static void SetTextByCus(TextBox txt)
        {
            DAL.ClsIF_Customer_View oCus = new DAL.ClsIF_Customer_View();
            if (oCus.RefreshView())
            {
                txt.Text = oCus.oModel.HName;
                txt.Tag = oCus.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //选择接口类生产资源
        /// 
        /// 选择接口类生产资源
        /// 
        /// 
        public static void SetTextBySource(TextBox txt)
        {
            DAL.ClsIF_Source_View oSource = new DAL.ClsIF_Source_View();
            if (oSource.RefreshView())
            {
                txt.Text = oSource.oModel.HName;
                txt.Tag = oSource.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //接口类生产资源-网格
        /// 
        /// 接口类生产资源-网格
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public static void SetGridBySource(DataGridView grdMain, int i, int HSourceIDCol, int HSourceNumberCol, int HSourceNameCol)
        {
            DAL.ClsIF_Source_View oSource = new DAL.ClsIF_Source_View();
            if (oSource.RefreshView())
            {
                if (oSource.GetInfoByID(oSource.oModel.HItemID))
                {
                    grdMain.Rows[i].Cells[HSourceIDCol].Value = oSource.omodel.HItemID.ToString();
                    grdMain.Rows[i].Cells[HSourceNumberCol].Value = oSource.omodel.HNumber;
                    grdMain.Rows[i].Cells[HSourceNameCol].Value = oSource.omodel.HName;
                }
                else
                {
                    grdMain.Rows[i].Cells[HSourceIDCol].Value = "0";
                    grdMain.Rows[i].Cells[HSourceNumberCol].Value = "";
                    grdMain.Rows[i].Cells[HSourceNameCol].Value = "";
                }
            }
            else
            {
                grdMain.Rows[i].Cells[HSourceIDCol].Value = "0";
                grdMain.Rows[i].Cells[HSourceNumberCol].Value = "";
                grdMain.Rows[i].Cells[HSourceNameCol].Value = "";
            }
        }
        //选择接口类部门
        /// 
        /// 选择接口类部门
        /// 
        /// 
        public static void SetTextByDept(TextBox txt)
        {
            DAL.ClsIF_Department_View oDept = new DAL.ClsIF_Department_View();
            if (oDept.RefreshView())
            {
                txt.Text = oDept.oModel.HName;
                txt.Tag = oDept.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //选择接口类部门   递入过滤条件
        /// 
        /// 选择接口类部门   递入过滤条件
        /// 
        /// 
        public static void SetTextByDept(TextBox txt, string sWhere)
        {
            DAL.ClsIF_Department_View oDept = new DAL.ClsIF_Department_View();
            if (oDept.RefreshView(sWhere))
            {
                txt.Text = oDept.oModel.HName;
                txt.Tag = oDept.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //接口类部门-网格
        /// 
        /// 接口类部门-网格
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public static void SetGridByDept(DataGridView grdMain, int i, int HDeptIDCol, int HDeptNumberCol, int HDeptNameCol)
        {
            DAL.ClsIF_Department_View oDept = new DAL.ClsIF_Department_View();
            if (oDept.RefreshView())
            {
                if (oDept.GetInfoByID(oDept.oModel.HItemID))
                {
                    grdMain.Rows[i].Cells[HDeptIDCol].Value = oDept.omodel.HItemID.ToString();
                    grdMain.Rows[i].Cells[HDeptNumberCol].Value = oDept.omodel.HNumber;
                    grdMain.Rows[i].Cells[HDeptNameCol].Value = oDept.omodel.HName;
                }
                else
                {
                    grdMain.Rows[i].Cells[HDeptIDCol].Value = "0";
                    grdMain.Rows[i].Cells[HDeptNumberCol].Value = "";
                    grdMain.Rows[i].Cells[HDeptNameCol].Value = "";
                }
            }
            else
            {
                grdMain.Rows[i].Cells[HDeptIDCol].Value = "0";
                grdMain.Rows[i].Cells[HDeptNumberCol].Value = "";
                grdMain.Rows[i].Cells[HDeptNameCol].Value = "";
            }
        }
        //选择接口类职员
        /// 
        /// 选择接口类职员
        /// 
        /// 
        public static void SetTextByEmp(TextBox txt)
        {
            DAL.ClsIF_Employee_View oEmp = new DAL.ClsIF_Employee_View();
            if (oEmp.RefreshView())
            {
                txt.Text = oEmp.oModel.HName;
                txt.Tag = oEmp.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //接口类职员-网格
        /// 
        /// 接口类职员-网格
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public static void SetGridByEmp(DataGridView grdMain, int i, int HEmpIDCol, int HEmpNumberCol, int HEmpNameCol)
        {
            DAL.ClsIF_Employee_View oEmp = new DAL.ClsIF_Employee_View();
            if (oEmp.RefreshView())
            {
                if (oEmp.GetInfoByID(oEmp.oModel.HItemID))
                {
                    grdMain.Rows[i].Cells[HEmpIDCol].Value = oEmp.omodel.HItemID.ToString();
                    grdMain.Rows[i].Cells[HEmpNumberCol].Value = oEmp.omodel.HNumber;
                    grdMain.Rows[i].Cells[HEmpNameCol].Value = oEmp.omodel.HName;
                }
                else
                {
                    grdMain.Rows[i].Cells[HEmpIDCol].Value = "0";
                    grdMain.Rows[i].Cells[HEmpNumberCol].Value = "";
                    grdMain.Rows[i].Cells[HEmpNameCol].Value = "";
                }
            }
            else
            {
                grdMain.Rows[i].Cells[HEmpIDCol].Value = "0";
                grdMain.Rows[i].Cells[HEmpNumberCol].Value = "";
                grdMain.Rows[i].Cells[HEmpNameCol].Value = "";
            }
        }
        //选择接口类工序
        /// 
        /// 选择接口类工序
        /// 
        /// 
        public static void SetTextByProc(TextBox txt)
        {
            DAL.ClsIF_Process_View oProc = new DAL.ClsIF_Process_View();
            if (oProc.RefreshView())
            {
                txt.Text = oProc.oModel.HName;
                txt.Tag = oProc.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //选择接口类工序
        /// 
        /// 选择接口类工序
        /// 
        /// 
        public static void SetTextByProc(TextBox txt,TextBox txt2)
        {
            DAL.ClsIF_Process_View oProc = new DAL.ClsIF_Process_View();
            if (oProc.RefreshView())
            {
                txt.Text = oProc.oModel.HNumber;
                txt.Tag = oProc.oModel.HItemID.ToString();
                txt2.Text = oProc.oModel.HName;
            }
            else
            {
                txt.Text = "";
                txt2.Text = "";
            }
        }
        //接口类工序-网格
        /// 
        /// 接口类工序-网格
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public static void SetGridByProc(DataGridView grdMain, int i, int HProcIDCol, int HProcNumberCol, int HProcNameCol)
        {
            DAL.ClsIF_Process_View oProc = new DAL.ClsIF_Process_View();
            if (oProc.RefreshView())
            {
                if (oProc.GetInfoByID(oProc.oModel.HItemID))
                {
                    grdMain.Rows[i].Cells[HProcIDCol].Value = oProc.omodel.HItemID.ToString();
                    grdMain.Rows[i].Cells[HProcNumberCol].Value = oProc.omodel.HNumber;
                    grdMain.Rows[i].Cells[HProcNameCol].Value = oProc.omodel.HName;
                }
                else
                {
                    grdMain.Rows[i].Cells[HProcIDCol].Value = "0";
                    grdMain.Rows[i].Cells[HProcNumberCol].Value = "";
                    grdMain.Rows[i].Cells[HProcNameCol].Value = "";
                }
            }
            else
            {
                grdMain.Rows[i].Cells[HProcIDCol].Value = "0";
                grdMain.Rows[i].Cells[HProcNumberCol].Value = "";
                grdMain.Rows[i].Cells[HProcNameCol].Value = "";
            }
        }
        //接口类客户-网格
        /// 
        /// 接口类客户-网格
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public static void SetGridByCus(DataGridView grdMain, int i, int HCusIDCol, int HCusNumberCol, int HCusNameCol)
        {
            DAL.ClsIF_Customer_View oCus = new DAL.ClsIF_Customer_View();
            if (oCus.RefreshView())
            {
                if (oCus.GetInfoByID(oCus.oModel.HItemID))
                {
                    grdMain.Rows[i].Cells[HCusIDCol].Value = oCus.omodel.HItemID.ToString();
                    grdMain.Rows[i].Cells[HCusNumberCol].Value = oCus.omodel.HNumber;
                    grdMain.Rows[i].Cells[HCusNameCol].Value = oCus.omodel.HName;
                }
                else
                {
                    grdMain.Rows[i].Cells[HCusIDCol].Value = "0";
                    grdMain.Rows[i].Cells[HCusNumberCol].Value = "";
                    grdMain.Rows[i].Cells[HCusNameCol].Value = "";
                }
            }
            else
            {
                grdMain.Rows[i].Cells[HCusIDCol].Value = "0";
                grdMain.Rows[i].Cells[HCusNumberCol].Value = "";
                grdMain.Rows[i].Cells[HCusNameCol].Value = "";
            }
        }
        //选择接口类物料
        /// 
        /// 选择接口类物料
        /// 
        /// 
        public static void SetTextByMater(TextBox txt,bool backNumber)
        {
            DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View();
            if (oMater.RefreshView())
            {
                txt.Text = oMater.omodel.HNumber;
                txt.Tag = oMater.omodel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //选择接口类物料
        /// 
        /// 选择接口类物料
        /// 
        /// 
        public static void SetTextByMater(TextBox txt)
        {
            DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View();
            if (oMater.RefreshView())
            {
                txt.Text = oMater.omodel.HName;
                txt.Tag = oMater.omodel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //选择接口类物料
        /// 
        /// 选择接口类物料
        /// 
        /// 
        public static void SetTextByMater(TextBox txt, TextBox txt2, TextBox txt3)
        {
            DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View();
            if (oMater.RefreshView())
            {
                if (oMater.GetInfoByID(oMater.omodel.HItemID))
                {
                    txt.Text = oMater.omodel.HNumber;
                    txt.Tag = oMater.omodel.HItemID.ToString();
                    txt2.Text = oMater.omodel.HName;
                    txt3.Text = oMater.omodel.HModel;
                }
            }
            else
            {
                txt.Text = "";
                txt2.Text = "";
                txt3.Text = "";
            }
        }
        //选择接口类物料
        /// 
        /// 选择接口类物料
        /// 
        /// 代码文本框
        /// 名称文本框
        /// 规格文本框
        /// 单位文本框
        public static void SetTextByMater(TextBox txtNumber, TextBox txtName, TextBox txtModel, TextBox txtUnit)
        {
            DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View();
            DAL.ClsIF_Unit_View oUnit = new DAL.ClsIF_Unit_View();
            if (oMater.RefreshView())
            {
                if (oMater.GetInfoByID(oMater.omodel.HItemID))
                {
                    txtNumber.Text = oMater.omodel.HNumber;
                    txtNumber.Tag = oMater.omodel.HItemID.ToString();
                    txtName.Text = oMater.omodel.HName;
                    txtModel.Text = oMater.omodel.HModel;
                    if (oUnit.GetInfoByID(oMater.omodel.HUnitID))
                    {
                        txtUnit.Text = oUnit.omodel.HName;
                        txtUnit.Tag = oUnit.omodel.HItemID.ToString();
                    }
                    else
                    {
                        txtUnit.Text = "";
                        txtUnit.Tag = "0";
                    }
                }
                else
                {
                    txtNumber.Text = "";
                    txtNumber.Tag = "0";
                    txtName.Text = "";
                    txtModel.Text = "";
                    txtUnit.Text = "";
                    txtUnit.Tag = "0";
                }
            }
            else
            {
                txtNumber.Text = "";
                txtNumber.Tag = "0";
                txtName.Text = "";
                txtModel.Text = "";
                txtUnit.Text = "";
                txtUnit.Tag = "0";
            }
        }
        //接口类物料-网格
        /// 
        /// 接口类物料-网格
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public static void SetGridByMater(DataGridView grdMain, int i, int HMaterIDCol, int HMaterNumberCol, int HMaterNameCol, int HMaterModelCol, int HUnitIDCol, int HUnitNumberCol, int HUnitNameCol)
        {
            DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View();
            if (oMater.RefreshView())
            {
                if (oMater.GetInfoByID(oMater.omodel.HItemID))
                {
                    grdMain.Rows[i].Cells[HMaterIDCol].Value = oMater.omodel.HItemID.ToString();
                    grdMain.Rows[i].Cells[HMaterNumberCol].Value = oMater.omodel.HNumber;
                    grdMain.Rows[i].Cells[HMaterNameCol].Value = oMater.omodel.HName;
                    grdMain.Rows[i].Cells[HMaterModelCol].Value = oMater.omodel.HModel;
                    grdMain.Rows[i].Cells[HUnitIDCol].Value = oMater.omodel.HUnitID;
                    grdMain.Rows[i].Cells[HUnitNumberCol].Value = oMater.omodel.HUnitNumber;
                    grdMain.Rows[i].Cells[HUnitNameCol].Value = oMater.omodel.HUnitName;
                }
                else
                {
                    grdMain.Rows[i].Cells[HMaterIDCol].Value = "0";
                    grdMain.Rows[i].Cells[HMaterNumberCol].Value = "";
                    grdMain.Rows[i].Cells[HMaterNameCol].Value = "";
                    grdMain.Rows[i].Cells[HMaterModelCol].Value = "";
                    grdMain.Rows[i].Cells[HUnitIDCol].Value = "0";
                    grdMain.Rows[i].Cells[HUnitNumberCol].Value ="";
                    grdMain.Rows[i].Cells[HUnitNameCol].Value = "";
                }
            }
            else
            {
                grdMain.Rows[i].Cells[HMaterIDCol].Value = "0";
                grdMain.Rows[i].Cells[HMaterNumberCol].Value = "";
                grdMain.Rows[i].Cells[HMaterNameCol].Value = "";
                grdMain.Rows[i].Cells[HMaterModelCol].Value = "";
                grdMain.Rows[i].Cells[HUnitIDCol].Value = "0";
                grdMain.Rows[i].Cells[HUnitNumberCol].Value = "";
                grdMain.Rows[i].Cells[HUnitNameCol].Value = "";
            }
        }
        //接口类物料-网格
        /// 
        /// 接口类物料-网格
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public static void SetGridByMater(DataGridView grdMain, int i, int HMaterIDCol, int HMaterNumberCol, int HMaterNameCol, int HMaterModelCol)
        {
            DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View();
            if (oMater.RefreshView())
            {
                if (oMater.GetInfoByID(oMater.omodel.HItemID))
                {
                    grdMain.Rows[i].Cells[HMaterIDCol].Value = oMater.omodel.HItemID.ToString();
                    grdMain.Rows[i].Cells[HMaterNumberCol].Value = oMater.omodel.HNumber;
                    grdMain.Rows[i].Cells[HMaterNameCol].Value = oMater.omodel.HName;
                    grdMain.Rows[i].Cells[HMaterModelCol].Value = oMater.omodel.HModel;
                }
                else
                {
                    grdMain.Rows[i].Cells[HMaterIDCol].Value = "0";
                    grdMain.Rows[i].Cells[HMaterNumberCol].Value = "";
                    grdMain.Rows[i].Cells[HMaterNameCol].Value = "";
                    grdMain.Rows[i].Cells[HMaterModelCol].Value = "";
                }
            }
            else
            {
                grdMain.Rows[i].Cells[HMaterIDCol].Value = "0";
                grdMain.Rows[i].Cells[HMaterNumberCol].Value = "";
                grdMain.Rows[i].Cells[HMaterNameCol].Value = "";
                grdMain.Rows[i].Cells[HMaterModelCol].Value = "";
            }
        }
        //选择接口类班组
        /// 
        /// 选择接口类班组
        /// 
        /// 
        public static void SetTextByGroup(TextBox txt)
        {
            DAL.ClsIF_Group_View oGroup = new DAL.ClsIF_Group_View();
            if (oGroup.RefreshView())
            {
                txt.Text = oGroup.oModel.HName;
                txt.Tag = oGroup.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //接口类班组-网格
        /// 
        /// 接口类班组-网格
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public static void SetGridByGroup(DataGridView grdMain, int i, int HGroupIDCol, int HGroupNumberCol, int HGroupNameCol)
        {
            DAL.ClsIF_Group_View oGroup = new DAL.ClsIF_Group_View();
            if (oGroup.RefreshView())
            {
                if (oGroup.GetInfoByID(oGroup.oModel.HItemID))
                {
                    grdMain.Rows[i].Cells[HGroupIDCol].Value = oGroup.omodel.HItemID.ToString();
                    grdMain.Rows[i].Cells[HGroupNumberCol].Value = oGroup.omodel.HNumber;
                    grdMain.Rows[i].Cells[HGroupNameCol].Value = oGroup.omodel.HName;
                }
                else
                {
                    grdMain.Rows[i].Cells[HGroupIDCol].Value = "0";
                    grdMain.Rows[i].Cells[HGroupNumberCol].Value = "";
                    grdMain.Rows[i].Cells[HGroupNameCol].Value = "";
                }
            }
            else
            {
                grdMain.Rows[i].Cells[HGroupIDCol].Value = "0";
                grdMain.Rows[i].Cells[HGroupNumberCol].Value = "";
                grdMain.Rows[i].Cells[HGroupNameCol].Value = "";
            }
        }
        //选择接口类计量单位
        /// 
        /// 选择接口类计量单位
        /// 
        /// 
        public static void SetTextByUnit(TextBox txt)
        {
            DAL.ClsIF_Unit_View oUnit = new DAL.ClsIF_Unit_View();
            if (oUnit.RefreshView())
            {
                txt.Text = oUnit.oModel.HName;
                txt.Tag = oUnit.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //接口类计量单位-网格
        /// 
        /// 接口类计量单位-网格
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public static void SetGridByUnit(DataGridView grdMain, int i, int HUnitIDCol, int HUnitNumberCol, int HUnitNameCol)
        {
            DAL.ClsIF_Unit_View oUnit = new DAL.ClsIF_Unit_View();
            if (oUnit.RefreshView())
            {
                if (oUnit.GetInfoByID(oUnit.oModel.HItemID))
                {
                    grdMain.Rows[i].Cells[HUnitIDCol].Value = oUnit.omodel.HItemID.ToString();
                    grdMain.Rows[i].Cells[HUnitNumberCol].Value = oUnit.omodel.HNumber;
                    grdMain.Rows[i].Cells[HUnitNameCol].Value = oUnit.omodel.HName;
                }
                else
                {
                    grdMain.Rows[i].Cells[HUnitIDCol].Value = "0";
                    grdMain.Rows[i].Cells[HUnitNumberCol].Value = "";
                    grdMain.Rows[i].Cells[HUnitNameCol].Value = "";
                }
            }
            else
            {
                grdMain.Rows[i].Cells[HUnitIDCol].Value = "0";
                grdMain.Rows[i].Cells[HUnitNumberCol].Value = "";
                grdMain.Rows[i].Cells[HUnitNameCol].Value = "";
            }
        }
        //选择接口类仓库
        /// 
        /// 选择接口类仓库
        /// 
        /// 
        public static void SetTextByWarehouse(TextBox txt)
        {
            DAL.ClsIF_Warehouse_View oWh = new DAL.ClsIF_Warehouse_View();
            if (oWh.RefreshView())
            {
                txt.Text = oWh.oModel.HName;
                txt.Tag = oWh.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //选择接口类仓库   递入过滤条件
        /// 
        /// 选择接口类仓库   递入过滤条件
        /// 
        /// 
        public static void SetTextByWarehouse(TextBox txt, string sWhere)
        {
            DAL.ClsIF_Warehouse_View oWh = new DAL.ClsIF_Warehouse_View();
            if (oWh.RefreshView(sWhere))
            {
                txt.Text = oWh.oModel.HName;
                txt.Tag = oWh.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //接口类仓库-网格
        /// 
        /// 接口类仓库-网格
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public static void SetGridByWarehouse(DataGridView grdMain, int i, int HWhIDCol, int HWhNumberCol, int HWhNameCol)
        {
            DAL.ClsIF_Warehouse_View oWh = new DAL.ClsIF_Warehouse_View();
            if (oWh.RefreshView())
            {
                if (oWh.GetInfoByID(oWh.oModel.HItemID))
                {
                    grdMain.Rows[i].Cells[HWhIDCol].Value = oWh.omodel.HItemID.ToString();
                    grdMain.Rows[i].Cells[HWhNumberCol].Value = oWh.omodel.HNumber;
                    grdMain.Rows[i].Cells[HWhNameCol].Value = oWh.omodel.HName;
                }
                else
                {
                    grdMain.Rows[i].Cells[HWhIDCol].Value = "0";
                    grdMain.Rows[i].Cells[HWhNumberCol].Value = "";
                    grdMain.Rows[i].Cells[HWhNameCol].Value = "";
                }
            }
            else
            {
                grdMain.Rows[i].Cells[HWhIDCol].Value = "0";
                grdMain.Rows[i].Cells[HWhNumberCol].Value = "";
                grdMain.Rows[i].Cells[HWhNameCol].Value = "";
            }
        }
        //选择接口类区域
        /// 
        /// 选择接口类区域
        /// 
        /// 
        public static void SetTextByArea(TextBox txt)
        {
            DAL.ClsIF_Area_View oArea = new DAL.ClsIF_Area_View();
            if (oArea.RefreshView())
            {
                txt.Text = oArea.oModel.HName;
                txt.Tag = oArea.oModel.HItemID.ToString();
            }
            else
            {
                txt.Text = "";
            }
        }
        //仓位-网格 根据仓库
        /// 
        /// 仓位-网格 根据仓库
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public static void SetGridByStockPlaceByWh(DataGridView grdMain, int i, int HWhIDCol, int HStockPlaceIDCol, int HStockPlaceNumberCol, int HStockPlaceNameCol)
        {
            DAL.ClsIF_StockPlace_View oStockPlace = new DAL.ClsIF_StockPlace_View();
            if (oStockPlace.RefreshView())
            {
                if (oStockPlace.GetInfoByID(oStockPlace.oModel.HItemID))
                {
                    grdMain.Rows[i].Cells[HStockPlaceIDCol].Value = oStockPlace.omodel.HItemID.ToString();
                    grdMain.Rows[i].Cells[HStockPlaceNumberCol].Value = oStockPlace.omodel.HNumber;
                    grdMain.Rows[i].Cells[HStockPlaceNameCol].Value = oStockPlace.omodel.HName;
                }
                else
                {
                    grdMain.Rows[i].Cells[HStockPlaceIDCol].Value = "0";
                    grdMain.Rows[i].Cells[HStockPlaceNumberCol].Value = "";
                    grdMain.Rows[i].Cells[HStockPlaceNameCol].Value = "";
                }
            }
            else
            {
                grdMain.Rows[i].Cells[HStockPlaceIDCol].Value = "0";
                grdMain.Rows[i].Cells[HStockPlaceNumberCol].Value = "";
                grdMain.Rows[i].Cells[HStockPlaceNameCol].Value = "";
            }
        }
        //仓位-网格 根据仓库
        /// 
        /// 仓位-网格 根据仓库
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public static void SetGridByStockPlaceByWh(DataGridView grdMain, int i, int HWhIDCol, int HStockPlaceIDCol, int HStockPlaceNumberCol, int HStockPlaceNameCol, int HSPGroupIDCol, int HSPGroupNameCol, ref string sBackStr)
        {
            DAL.ClsIF_StockPlace_View oSP = new DAL.ClsIF_StockPlace_View();
            DAL.ClsIF_StockPlaceGroup_View oSPGroup = new DAL.ClsIF_StockPlaceGroup_View();
            if (DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HWhIDCol].Value) == 0)
            {
                sBackStr = "没有选择仓库!";
                return;
            }
            if (oSP.RefreshViewByWh(DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HWhIDCol].Value)))
            {
                if (oSP.GetInfoByID(oSP.oModel.HItemID))
                {
                    grdMain.Rows[i].Cells[HStockPlaceIDCol].Value = oSP.omodel.HItemID.ToString();
                    grdMain.Rows[i].Cells[HStockPlaceNumberCol].Value = oSP.omodel.HNumber;
                    grdMain.Rows[i].Cells[HStockPlaceNameCol].Value = oSP.omodel.HName;
                    if (oSPGroup.GetInfoByID(oSP.omodel.HSPGroupID))
                    {
                        grdMain.Rows[i].Cells[HSPGroupIDCol].Value = oSPGroup.omodel.HItemID;
                        grdMain.Rows[i].Cells[HSPGroupNameCol].Value = oSPGroup.omodel.HName;
                    }
                    else
                    {
                        grdMain.Rows[i].Cells[HSPGroupIDCol].Value = "0";
                        grdMain.Rows[i].Cells[HSPGroupNameCol].Value = "";
                    }
                }
                else
                {
                    grdMain.Rows[i].Cells[HStockPlaceIDCol].Value = "0";
                    grdMain.Rows[i].Cells[HStockPlaceNumberCol].Value = "";
                    grdMain.Rows[i].Cells[HStockPlaceNameCol].Value = "";
                    grdMain.Rows[i].Cells[HSPGroupIDCol].Value = "0";
                    grdMain.Rows[i].Cells[HSPGroupNameCol].Value = "";
                }
            }
            else
            {
                grdMain.Rows[i].Cells[HStockPlaceIDCol].Value = "0";
                grdMain.Rows[i].Cells[HStockPlaceNumberCol].Value = "";
                grdMain.Rows[i].Cells[HStockPlaceNameCol].Value = "";
                grdMain.Rows[i].Cells[HSPGroupIDCol].Value = "0";
                grdMain.Rows[i].Cells[HSPGroupNameCol].Value = "";
            }
        }
        //接口类区域-网格
        /// 
        /// 接口类区域-网格
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public static void SetGridByArea(DataGridView grdMain, int i, int HAreaIDCol, int HAreaNumberCol, int HAreaNameCol)
        {
            DAL.ClsIF_Area_View oArea = new DAL.ClsIF_Area_View();
            if (oArea.RefreshView())
            {
                if (oArea.GetInfoByID(oArea.oModel.HItemID))
                {
                    grdMain.Rows[i].Cells[HAreaIDCol].Value = oArea.omodel.HItemID.ToString();
                    grdMain.Rows[i].Cells[HAreaNumberCol].Value = oArea.omodel.HNumber;
                    grdMain.Rows[i].Cells[HAreaNameCol].Value = oArea.omodel.HName;
                }
                else
                {
                    grdMain.Rows[i].Cells[HAreaIDCol].Value = "0";
                    grdMain.Rows[i].Cells[HAreaNumberCol].Value = "";
                    grdMain.Rows[i].Cells[HAreaNameCol].Value = "";
                }
            }
            else
            {
                grdMain.Rows[i].Cells[HAreaIDCol].Value = "0";
                grdMain.Rows[i].Cells[HAreaNumberCol].Value = "";
                grdMain.Rows[i].Cells[HAreaNameCol].Value = "";
            }
        }
    }
}