using com.hnshituo.core.webapp.vo;
using Common;
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace MeterModuleLibrary
{
    /// <summary>
    /// 调整班次回调
    /// </summary>
    /// <param name="productDate">产品日期</param>
    /// <param name="meterClass">班次</param>
    /// <param name="meterGroup">班组</param>
    public delegate void CallBack(DateTime productDate, string meterClass, string meterGroup);

    public partial class frmHotDeliveryUpdateClass : Form
    {
        public event CallBack callBack;

        private ComBaseInfoService comBaseInfoService = new ComBaseInfoService(); //基础数服务
        public string productDateShow = "", meterClassShow = "", meterGroupShow = "";

        public frmHotDeliveryUpdateClass()
        {
            InitializeComponent();
        }

        private void frmHotDeliveryUpdateClass_Load(object sender, EventArgs e)
        {
            tbProductDate.Text = productDateShow;
            tbClass.Text = meterClassShow;
            tbGroup.Text = meterGroupShow;

            //热送磅班组信息载入cmbMeterGroupUp
            RESTfulResult<List<ComBaseInfo>> rrComMeterGroop = comBaseInfoService.doQueryBaseList(new ComBaseInfo { validFlag = "1", pBaseCode = "001044" });
            if (rrComMeterGroop.Succeed && rrComMeterGroop.Data != null && rrComMeterGroop.Data.Count > 0)
            {
                ClsControlPack.SetUltraComboDataSource(cmbMeterGroup, rrComMeterGroop.Data.ListToDataTable<ComBaseInfo>(), "baseCode", "baseName");
            }
            else
            {
                MessageBox.Show("热送磅班组信息载入失败!");
                return;
            }

            //热送磅班次信息载入cmbMeterClassUp
            RESTfulResult<List<ComBaseInfo>> rrComMeterClass = comBaseInfoService.doQueryBaseList(new ComBaseInfo { validFlag = "1", pBaseCode = "001043" });
            if (rrComMeterClass.Succeed && rrComMeterClass.Data != null && rrComMeterClass.Data.Count > 0)
            {
                ClsControlPack.SetUltraComboDataSource(cmbMeterClass, rrComMeterClass.Data.ListToDataTable<ComBaseInfo>(), "baseCode", "baseName");
            }
            else
            {
                MessageBox.Show("热送磅班次信息载入失败!");
                return;
            }
        }

        /// <summary>
        /// 取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Cancle_Click(object sender, EventArgs e)
        {
            Close();
        }

        /// <summary>
        /// 确认
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btOK_Click(object sender, EventArgs e)
        {
            callBack(dtProductDate.Value, cmbMeterClass.Text, cmbMeterGroup.Text);
            Close();
        }
    }
}