144 lines
4.6 KiB
C#
144 lines
4.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Text.RegularExpressions;
|
|
using System.Collections;
|
|
using System.IO;
|
|
using System.Xml;
|
|
|
|
using Telerik.WinControls.UI;
|
|
using DAL;
|
|
|
|
namespace NSAnalysis
|
|
{
|
|
public partial class FRangeSetup : Telerik.WinControls.UI.ShapedForm
|
|
{
|
|
private TMeasureMSSQLDAL tmdal = new TMeasureMSSQLDAL();
|
|
public int idgvSelectRowNumber = 0;
|
|
|
|
#region 鼠标事件
|
|
|
|
private void btn_MouseHover(object sender, EventArgs e)
|
|
{
|
|
RadButton btn = sender as RadButton;
|
|
btn.BackColor = Color.FromArgb(0, 151, 186);
|
|
}
|
|
|
|
private void btn_MouseLeave(object sender, EventArgs e)
|
|
{
|
|
RadButton btn = sender as RadButton;
|
|
btn.BackColor = Color.FromArgb(19, 46, 53);
|
|
}
|
|
|
|
#endregion 鼠标事件
|
|
|
|
public FRangeSetup()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void FToleranceSetup_Load(object sender, EventArgs e)
|
|
{
|
|
dgvTolList.ColumnHeadersDefaultCellStyle.Font = new Font("Segoe UI", 10, FontStyle.Regular);
|
|
lpcAddTol.labPicture.Click += lpcAddTol_Click;
|
|
lpcAddTol.labText.Click += lpcAddTol_Click;
|
|
rtbnSearch_Click(null, null);
|
|
}
|
|
|
|
public void rtbnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
DataTable dt = tmdal.SelectAllRangeByCondition(rtbCarModel.Text.Trim(), rtbMesPointName.Text.Trim());
|
|
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
dgvTolList.DataSource = dt;
|
|
SetdgvRowBgColor(dgvTolList);
|
|
labSearchResult.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
dgvTolList.DataSource = dt;
|
|
labSearchResult.Visible = true;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置DataGridView各行变色
|
|
/// </summary>
|
|
/// <param name="dgv">DataGridView</param>
|
|
public void SetdgvRowBgColor(DataGridView dgv)
|
|
{
|
|
if (dgv.Rows.Count > 0)
|
|
{
|
|
foreach (DataGridViewRow item in dgv.Rows)
|
|
{
|
|
if (item.Index % 2 == 0)
|
|
{
|
|
item.DefaultCellStyle.BackColor = Color.FromArgb(19, 46, 53);
|
|
}
|
|
else
|
|
{
|
|
item.DefaultCellStyle.BackColor = Color.FromArgb(27, 60, 68);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void dgvTolList_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
|
|
{
|
|
e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);
|
|
}
|
|
|
|
private void lpcAddTol_Click(object sender, EventArgs e)
|
|
{
|
|
FAddRange fat = new FAddRange(this);
|
|
fat.ShowDialog(this);
|
|
}
|
|
|
|
private void dgvTolList_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
string buttonText = "";
|
|
if (e.RowIndex < 0 || e.ColumnIndex < 0)
|
|
{
|
|
return;
|
|
}
|
|
try
|
|
{
|
|
buttonText = dgvTolList.Columns[e.ColumnIndex].HeaderText;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
buttonText = " ";
|
|
}
|
|
if (buttonText == "删除")
|
|
{
|
|
if (DialogResult.Yes == MessageBox.Show("您确定要删除该条极差带信息吗,注意:删除后不可恢复!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
|
|
{
|
|
string iObjIDPk = dgvTolList.Rows[e.RowIndex].Cells["Id"].Value.ToString();
|
|
try
|
|
{
|
|
tmdal.DeleteOneRange(iObjIDPk);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("删除极差带信息失败,原因:" + ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
MessageBox.Show("删除极差带信息成功! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
rtbnSearch_Click(null, null);
|
|
}
|
|
}
|
|
|
|
if (buttonText == "修改" || buttonText == "Edit")
|
|
{
|
|
idgvSelectRowNumber = e.RowIndex;
|
|
FEditRange sfeditcnc = new FEditRange(this);
|
|
sfeditcnc.ShowDialog();
|
|
}
|
|
}
|
|
}
|
|
} |