using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Core.Mes.ClientFrameWork;
using Core.Mes.IBaseInterface;
using System.Data;
using System.Runtime.InteropServices;
using Core.XgMes.Client.JGKC.TurnoffSendManager;
namespace Core.XgMes.Client.JGKC.MaterialManager
{
    public partial class FrmMaterialDaioageNew : Mes.ClientFrameWork.FrmBase
    {

        public string strwzdm = "";
        public string strwzmc = "";
        public string strgg = "";
        public string strcz = "";
        public string strjldw = "";
        public string strdz = "";
        public string strckcode = "";
        public string strckmc = "";
        public string strcklb = "";
        public string strlbmc = "";
        public string strlbdm = "";
        public FrmMaterialDaioageNew()
        {
            InitializeComponent();
        }
        public void Init()
        {
            string err = "";
            string sql = "SELECT BB.MATERIAL_CODE,BB.MATERIAL_NAME,BB.SPEC,BB.MATERIAL,BB.SUBSTANCE,BB.UNITS,CC.DEPOTID,CC.DEPOTNAME,AA.STOCK_CODE,BB.MATERIAL_LB,BB.MATERIAL_LB_NAME FROM MATERIAL_CODE_MANAGE1 BB,KCJ_STORESMAGNAGER1 AA,KCJ_DEPOTMAGAGER1 CC  WHERE BB.MATERIAL_CODE=AA.MATERIALCODE(+) AND AA.STOCK_CODE=CC.DEPOT_LB(+)  "
                        + " ORDER BY TO_NUMBER(BB.SORT_CODE)  ASC ";
            DataSet ds = (DataSet)ClientCommon._RemotingHelp.ExecuteMethod("BJZWStuff", "Core.XgMes.Server.JGKC.SteelPlateManager.Common", "GetDataSet", new object[] { sql }, out err);
            if (err == "")
            {
                ultraGrid1.DataSource = ds;
            }
        }

        private void btnQR_Click(object sender, EventArgs e)
        {
         
           Infragistics.Win.UltraWinGrid.UltraGridRow row = ultraGrid1.ActiveRow;
           if (row.Selected) return;
          strwzdm = row.Cells["MATERIAL_CODE"].Value.ToString();
          strwzmc = row.Cells["MATERIAL_NAME"].Value.ToString();
          strgg = row.Cells["SPEC"].Value.ToString();
          strcz = row.Cells["MATERIAL"].Value.ToString();
          strjldw = row.Cells["UNITS"].Value.ToString();
          strdz = row.Cells["SUBSTANCE"].Value.ToString();
          strckcode = row.Cells["DEPOTID"].Value.ToString();
          strckmc = row.Cells["DEPOTNAME"].Value.ToString();
          strcklb = row.Cells["STOCK_CODE"].Value.ToString();
          strlbmc = row.Cells["MATERIAL_LB_NAME"].Value.ToString();
          strlbdm = row.Cells["MATERIAL_LB"].Value.ToString();
           this.Close();
        }

        private void FrmMaterialDaioage_Load(object sender, EventArgs e)
        {
            Init();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string strWhere = "";
            string sql = "";
            string err = "";
            if (Chk_WZDM.Checked && txt_wzdm.Text.Trim().Length > 0)
            {
                strWhere += " AND BB.MATERIAL_CODE LIKE '%" + txt_wzdm.Text.Trim().ToString() + "%' ";
            }
            if (chk_wz.Checked && txt_wz.Text.Trim().Length > 0)
            {
                strWhere += " AND BB.MATERIAL_NAME LIKE '%" + txt_wz.Text.Trim().ToString() + "%' ";
            }
            sql = "SELECT BB.MATERIAL_CODE,BB.MATERIAL_NAME,BB.SPEC,BB.MATERIAL,BB.SUBSTANCE,BB.UNITS,CC.DEPOTID,CC.DEPOTNAME,AA.STOCK_CODE,BB.MATERIAL_LB,BB.MATERIAL_LB_NAME FROM MATERIAL_CODE_MANAGE1 BB,KCJ_STORESMAGNAGER1 AA,KCJ_DEPOTMAGAGER1 CC  WHERE BB.MATERIAL_CODE=AA.MATERIALCODE(+) AND AA.STOCK_CODE=CC.DEPOT_LB(+)  " + strWhere
                        + " ORDER BY TO_NUMBER(BB.SORT_CODE)  ASC ";
            DataSet ds = (DataSet)ClientCommon._RemotingHelp.ExecuteMethod("BJZWStuff", "Core.XgMes.Server.JGKC.SteelPlateManager.Common", "GetDataSet", new object[] { sql }, out err);
            if (err == "")
            {
                ultraGrid1.DataSource = ds;
            }
        }

        private void Chk_WZDM_CheckedChanged(object sender, EventArgs e)
        {
            txt_wzdm.Enabled = Chk_WZDM.Checked;
        }

        private void chk_wz_CheckedChanged(object sender, EventArgs e)
        {
            txt_wz.Enabled = chk_wz.Checked;
        }
    }
}