using com.hnshituo.core.webapp.vo;
using Common;
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;
namespace CarMeterSystem
{
public partial class frmMatMsgInfo : Form
{
public frmMatMsgInfo()
{
InitializeComponent();
}
//是否选对了
public bool _isSuccess { get; set; }
string _matName = "", _chkMatName = "";
public frmMatMsgInfo(string matName)
{
InitializeComponent();
_matName = matName;
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
private void btnSave_Click(object sender, EventArgs e)
{
_isSuccess = (_matName == _chkMatName);
this.DialogResult = DialogResult.OK;
btnSave.Enabled = false;
btnCancel.Enabled = false;
}
///
/// 定时关闭(15000ms)
///
///
///
private void timer1_Tick(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
private void lbMat1_Click(object sender, EventArgs e)
{
_chkMatName = lbMat1.Text;
lbMat1.BackColor = Color.PaleTurquoise;
lbMat2.BackColor = Color.LightBlue;
}
private void lbMat2_Click(object sender, EventArgs e)
{
_chkMatName = lbMat2.Text;
lbMat2.BackColor = Color.PaleTurquoise;
lbMat1.BackColor = Color.LightBlue;
}
private void frmMatMsgInfo_Load(object sender, EventArgs e)
{
Random rd = new Random();
string strMat = "";
PbModelDbService> pbRelation = new PbModelDbService>();
string sql = $"select t.text, t.rn from (select matter_name text, rownum rn from meter_base_matter_info where IS_SECOND_RESOURCES = '1') t " +
$"where t.rn = (select trunc(dbms_random.value(1, (select count(1) + 1 from meter_base_matter_info where IS_SECOND_RESOURCES = '1'))) as rn from dual)";
RESTfulResult> rmRelation = pbRelation.executeSqlDataWf(sql);
if (rmRelation.Succeed && rmRelation.Data != null && rmRelation.Data.Count > 0)
{
strMat = rmRelation.Data[0].text;
}
else
{
strMat = _matName;
}
int i = rd.Next(1, 2);
if (i == 1)
{
lbMat1.Text = _matName;
lbMat2.Text = strMat;
}
if (i == 2)
{
lbMat2.Text = _matName;
lbMat1.Text = strMat;
}
}
}
}