Grid的check

private bool CheckInputOfEdit1()
{
// 開始ログを出力する
GetLogger().LogMethodBegin("OS0304.CheckInputOfEdit");

//背景色設定
this.inputColorCheck();

foreach (DataGridViewRow row in this.dgvD_Haisya.Rows)
{

// 受入日

if (null == row.Cells["dgvc_UKEDATE"].Value
|| ValidationUtil.IsEmpty(row.Cells["dgvc_UKEDATE"].Value.ToString()))
{
this.dgvD_Haisya.SelectionChanged -= new System.EventHandler(this.dgvD_Haisya_SelectionChanged);
row.Selected = true;
this.dgvD_Haisya.SelectionChanged += new System.EventHandler(this.dgvD_Haisya_SelectionChanged);

FormControlUtil.SetControlBackColor(this.dtpS_UKE_DATE, false);
ShowMsgById(MessageIdDef.COM_00010, "受入日");
this.ActiveControl = this.dtpS_UKE_DATE;

// 終了ログを出力する
GetLogger().LogMethodEnd("OS0304.ValidateGridView");
return false;
}

//事業所コード

if (null == row.Cells["dgvc_JIGYOUSYOCD"].Value
|| ValidationUtil.IsEmpty(row.Cells["dgvc_JIGYOUSYOCD"].Value.ToString()))
{
row.Selected = true;
FormControlUtil.SetControlBackColor(this.cmbS_JIGYOUSYO_CD, false);
ShowMsgById(MessageIdDef.COM_00010, "事業所");
this.ActiveControl = this.cmbS_JIGYOUSYO_CD;

//終了ログを出力する
GetLogger().LogMethodEnd("OS0304.ValidateGridView");
return false;
}

//取引先(バイオマス業者)

if (null == row.Cells["dgvC_TORIHIKISAKIRK"].Value
|| ValidationUtil.IsEmpty(row.Cells["dgvC_TORIHIKISAKIRK"].Value.ToString()))
{
row.Selected = true;
FormControlUtil.SetControlBackColor(this.cmbE_TORIHIKISAKI_BIO_CD, false);
ShowMsgById(MessageIdDef.COM_00010, "取引先(バイオマス業者)");
this.ActiveControl = this.cmbE_TORIHIKISAKI_BIO_CD;

//終了ログを出力する
GetLogger().LogMethodEnd("OS0304.ValidateGridView");
return false;
}

//時間帯

if (null == row.Cells["dgvC_JIKANTAI"].Value
|| ValidationUtil.IsEmpty(row.Cells["dgvC_JIKANTAI"].Value.ToString()))
{
row.Selected = true;
FormControlUtil.SetControlBackColor(this.decE_JIKAN_TAI, false);
ShowMsgById(MessageIdDef.COM_00010, "時間帯");
this.ActiveControl = this.decE_JIKAN_TAI;

//終了ログを出力する
GetLogger().LogMethodEnd("OS0304.ValidateGridView");
return false;
}

// 時間帯半角数字チェック

if (null != row.Cells["dgvC_JIKANTAI"].Value
&& !ValidationUtil.IsEmpty(row.Cells["dgvC_JIKANTAI"].Value.ToString())
&& !ValidationUtil.IsNumbericFormat(row.Cells["dgvC_JIKANTAI"].Value.ToString(), 2, 1))
{
row.Selected = true;
FormControlUtil.SetControlBackColor(this.decE_JIKAN_TAI, false);
ShowMsgById(MessageIdDef.COM_00030, "時間帯", "半角数字");
this.ActiveControl = this.decE_JIKAN_TAI;

//終了ログを出力する
GetLogger().LogMethodEnd("OS0304.ValidateGridView");
return false;
}

// 時間帯 範囲チェック

if (null != row.Cells["dgvC_JIKANTAI"].Value
&& !ValidationUtil.IsEmpty(this.decE_JIKAN_TAI.Text)
&& (Convert.ToDecimal(this.decE_JIKAN_TAI.Text) < 0
|| Convert.ToDecimal(this.decE_JIKAN_TAI.Text) > 23))
{
row.Selected = true;
FormControlUtil.SetControlBackColor(this.decE_JIKAN_TAI, false);
ShowMsgById(MessageIdDef.COM_00050, "時間帯", "0", "23");
this.ActiveControl = this.decE_JIKAN_TAI;

// 終了ログを出力する
GetLogger().LogMethodEnd("OS0304.ValidateGridView");
return false;
}

// 数量
if (null == row.Cells["dgvC_SURYO"].Value
|| ValidationUtil.IsEmpty(row.Cells["dgvC_SURYO"].Value.ToString()))
{
row.Selected = true;
FormControlUtil.SetControlBackColor(this.decE_SURYO, false);
ShowMsgById(MessageIdDef.COM_00010, "数量");
this.ActiveControl = this.decE_SURYO;

// 終了ログを出力する
GetLogger().LogMethodEnd("OS0304.ValidateGridView");
return false;
}

//数量(t) 半角数字チェック

if (null != row.Cells["dgvC_SURYO"].Value
&& !ValidationUtil.IsEmpty(row.Cells["dgvC_SURYO"].Value.ToString())
&& !ValidationUtil.IsNumbericFormat(row.Cells["dgvC_SURYO"].Value.ToString(), 3, 3))
{
row.Selected = true;
FormControlUtil.SetControlBackColor(this.decE_SURYO, false);
ShowMsgById(MessageIdDef.COM_00030, "数量(t", "半角数字");
this.ActiveControl = this.decE_SURYO;

// 終了ログを出力する
GetLogger().LogMethodEnd("OS0304.ValidateGridView");
return false;
}


//数量(t) 0以上チェック

if (null != row.Cells["dgvC_SURYO"].Value
&& !ValidationUtil.IsEmpty(row.Cells["dgvC_SURYO"].Value.ToString())
&& Convert.ToDecimal(row.Cells["dgvC_SURYO"].Value) <= 0)
{
row.Selected = true;
FormControlUtil.SetControlBackColor(this.decE_SURYO, false);
ShowMsgById(MessageIdDef.COM_00030, "数量(t)", "0以上");
this.ActiveControl = this.decE_SURYO;

// 終了ログを出力する
GetLogger().LogMethodEnd("OS0304.ValidateGridView");
return false;
}
}

//終了ログを出力する
GetLogger().LogMethodEnd("OS0304.CheckInputOfEdit");

return true ;
}

原文地址:https://www.cnblogs.com/yutt/p/7210836.html