using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlTypes;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PTMedicalInsurance.Common;
using PTMedicalInsurance.Helper;
using Newtonsoft.Json.Linq;
using PTMedicalInsurance.Forms;
using PTMedicalInsurance.Variables;
namespace PTMedicalInsurance.Forms
{
public partial class ChooseCard : Form
{
public string cardType;
public string businessType;
public string ID,PatName;
public int sL_CardType;
public string psnCertType;
public bool bYDSBK;
//设置业务实例
InvokeHelper invoker = new InvokeHelper();
public ChooseCard()
{
InitializeComponent();
this.StartPosition = FormStartPosition.CenterParent;
initCombox();
}
private DataTable GetDBLKComboxTable(string sqlStr)
{
InvokeHelper invoker = new InvokeHelper();
dynamic joInparm = new JObject();
dynamic joTmp = new JObject();
joTmp.sqlStr = sqlStr;
JArray jaParams = new JArray();
jaParams.Add(joTmp);
joInparm.Add("params", JArray.FromObject(jaParams));
joInparm.code = "09010014";
string inParam = joInparm.ToString();
JObject joRtn = invoker.invokeInsuService(inParam, "获取下拉框消息");
//dynamic jsonRtn = JsonConvert.DeserializeObject(strRtn);
DataTable dt = (DataTable)joRtn["result"].ToObject(typeof(DataTable));
//dt.Columns[0].ColumnName = "编码";
//dt.Columns[1].ColumnName = "名称";
//dt.Columns[2].ColumnName = "拼音查找码";
return dt;
}
private void SetDBLKCombox(ref PTControl.DBLookupCombox dblcbx, string sqlStr)
{
dblcbx.sDisplayField = "Code,Name,SearchCode";
dblcbx.sDisplayMember = "名称";
dblcbx.sKeyWords = "Code,SearchCode";
DataTable dt = GetDBLKComboxTable(sqlStr);
dblcbx.DataSource = dt;
if (dt?.Rows.Count > 0)
{
// default to select first one;
}
dblcbx.RowFilterVisible = true;
dblcbx.TextBox.Width = 400;
dblcbx.DataGridView.Width = 400;
dblcbx.DataGridView.Columns[0].Name = "编码";
dblcbx.DataGridView.Columns[1].Name = "名称";
dblcbx.DataGridView.Columns[2].Name = "查找码";
dblcbx.DataGridView.Columns[0].Width = 100;
dblcbx.DataGridView.Columns[1].Width = 200;
}
private void initCombox()
{
string sqlCondition = " and A.Interface_Dr = '" + Global.inf.InsuCurrencyCataLogue.ToString() + "'";
string sqlStr = "";
sqlStr = " SELECT B.Code,B.Descripts AS Name FROM HB_Dictionary A JOIN HB_DictionaryDataDetail B ON A.ID = B.HBDictionary_Dr "
+ " WHERE A.InsuCode = 'psn_cert_type'" + sqlCondition;
SetDBLKCombox(ref dblkcbxPsnCertType, sqlStr);
}
private void btOk_Click(object sender, EventArgs e)
{
cardType = "0" + (rbgCardType.SelectedIndex +1).ToString();
businessType = "01"+cbBusinessType.Text.Substring(0,3);
bYDSBK = chk_WSSBK.Checked;
// 身份证
if (rbgCardType.SelectedIndex == 1)
{
ID = tbID.Text;
PatName = tbName.Text;
}
//社保卡
if (rbgCardType.SelectedIndex == 2)
{
if (cbCardType.Text == "")
{
MessageBox.Show("读社保卡时需要选择卡类型!");
return;
}
sL_CardType = int.Parse(cbCardType.Text.Trim().Substring(0, 1)); //卡类型
}
//非中国大陆公民身份证人员
if (rbgCardType.SelectedIndex == 3)
{
if (tbID.Text == "")
{
MessageBox.Show("非大陆居民,外籍号码必填!例:香港的外籍号码:HKG000000888");
return;
}
}
DialogResult = DialogResult.OK;
}
private void ChooseCard_Load(object sender, EventArgs e)
{
rbgCardType.SelectedIndex = 2; //身份证
cbBusinessType.SelectedIndex = 0; //社保卡
}
private void rbgCardType_ValueChanged(object sender, int index, string text)
{
if (rbgCardType.SelectedIndex == 0)
{
// 电子凭证
cbBusinessType.Enabled = true;
lblNo.Text = "电子凭证号";
tbID.Text = "";
tbID.Focus();
}
else
{
lblNo.Text = "身份证号";
cbBusinessType.Enabled = false;
tbID.Text = Global.pat.presetIDNO;
}
if (rbgCardType.SelectedIndex == 2)
{
cbCardType.SelectedIndex = 0;
cbCardLevel.SelectedIndex = 2;
cbCardType.Enabled = true;
tbPassword.Enabled = true;
//tbPassword.Text = "";
}
else
{
cbCardType.Enabled = false;
tbPassword.Enabled = false;
}
if (rbgCardType.SelectedIndex == 1)
{
cbCBD.Text = "深圳市";
Global.pat.card.SearchAdmCode = "440300";
}
else
{
cbCBD.Text = "";
Global.pat.card.SearchAdmCode = "";
}
if (rbgCardType.SelectedIndex == 3)
{
lblNo.Text = "外籍号码";
}
}
private void btCancle_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
///
/// 修改密码
///
///
///
private void uiButton1_Click(object sender, EventArgs e)
{
string errorMsg="";
JObject joData = new JObject();
joData.Add("", "");
JObject joInput = new JObject();
joInput.Add("data", joData);
InvokeHelper invoker = new InvokeHelper();
JObject joRtn =invoker.invokeCenterService(TradeEnum.ModifyPassword, joInput);
if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
{
MessageBox.Show("修改卡密码失败:" + errorMsg);
}
else
{
MessageBox.Show("修改卡密码成功!");
}
}
private void SearchAdmdvs()
{
JObject joAdmdvsInfo = new JObject();
SearchAdmdvs Adm = new SearchAdmdvs();
try
{
Global.pat.card.SearchAdmKey = cbCBD.Text;
Adm.StartPosition = FormStartPosition.CenterParent;
if (Adm.ShowDialog() == DialogResult.OK)
{
cbCBD.Text = Global.pat.card.SearchAdmName;
if (!string.IsNullOrEmpty(Global.pat.card.SearchAdmCode))
{
//自动选择异地
if (Utils.isOtherCity(Global.pat.card.SearchAdmCode))
{
//rbgOtherProv.SelectedIndex = 1;
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("异常:" + ex.Message);
return;
}
}
private void dblkcbxPsnCertType_AfterSelector(object sender, PTControl.AfterSelectorEventArgs e)
{
DataGridViewRow row = e.Value as DataGridViewRow;
DataRowView dataRow = row.DataBoundItem as DataRowView;
psnCertType = dataRow["Code"].ToString().Trim();
//insuTypeName = dataRow["Name"].ToString().Trim();
}
private void cbCBD_DoEnter(object sender, EventArgs e)
{
//初始化
Global.pat.card.SearchAdmCode = "";
SearchAdmdvs();
}
}
}