using Newtonsoft.Json.Linq;
using PTMedicalInsurance.Business;
using PTMedicalInsurance.Helper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AnHuiMI.Common;
using PTMedicalInsurance.Variables;
using PTMedicalInsurance.FormSetter;

namespace AnHuiMI.Forms
{
    public partial class AssistSelect : Form
    {
        public AssistSelect()
        {
            InitializeComponent();
        }
        HisMainBusiness hBus = new HisMainBusiness();
        private InvokeHelper invoker = new InvokeHelper();
        private void AssistSelect_Load(object sender, EventArgs e)
        {
            uiDatetimePicker1.Text = DateTime.Now.ToString("yyyy-MM-01 00:00:00");
            uiDatetimePicker2.Value = DateTime.Now.AddDays(1 - DateTime.Now.Day).AddMonths(1).AddDays(-1);
        }
        private void uiButton1_Click(object sender, EventArgs e)
        {
            string outParam;
            //打开读卡窗口，操作员选择读卡类型后进行读卡器读卡，再进行1101获取参保信息
            if (hBus.readCard(out outParam) != 0)
            {
                MessageBox.Show(JsonHelper.setExceptionJson(-100, "读卡失败！",  outParam).ToString());
            }
            else
            {
                //展示患者信息界面
                if (hBus.showPatInfo(outParam, out outParam) != 0)
                {
                    MessageBox.Show(JsonHelper.setIrisReturnValue(0, "展示患者信息失败", JObject.Parse(outParam)).ToString());
                }
                else
                {
                    
                }
            }
            uiTextBox1.Text = Global.pat.psn_no;
        }

        private void uiMbyyButton1_Click(object sender, EventArgs e)
        {
            GridViewSetter grdSetter = new GridViewSetter();
            grdSetter.SetMbMedicationHistory(uiDataGridView1);
            JObject jo5205= new JObject();
            jo5205.Add("psn_no", uiTextBox1.Text);//必填
            jo5205.Add("begntime", uiDatetimePicker1.Text);//yyyy-MM-dd HH:mm:ss必填
            jo5205.Add("endtime", uiDatetimePicker2.Text);//yyyy-MM-dd HH:mm:ss
            JObject data5205= new JObject();
            data5205.Add("data", jo5205);
            JObject out5205= invoker.invokeCenterService("5205", JObject.Parse(JsonHelper.setCenterInpar("5205", data5205)));
            DataTable dt = (DataTable)out5205["output"]["feedetail"].ToObject(typeof(DataTable));
            uiDataGridView1.DataSource = dt;
        }

        private void uiPanel1_Click(object sender, EventArgs e)
        {

        }

      
    }
}
 