Загрузка данных
private void AnyGridView_DoubleClick(object sender, EventArgs e = null)
{
try
{
var gv = (DevExpress.XtraGrid.Views.Grid.GridView)sender;
if (gv.GridControl?.Name == "gridMainSearch" || gv.GridControl?.Name == "gridDetailSearch")
return;
var row = gv.GetFocusedDataRow();
if (row == null) return;
string SafeStr(string name) => row.Field<string>(name) ?? "";
decimal SafeDec(string name) => row.Field<decimal?>(name) ?? 0;
long SafeLong(string name) => row.Field<long?>(name) ?? 0;
// без выбора определенных складов
if (string.IsNullOrEmpty(SklStor_Rcd))
{
// без чеков
if (gv.Name == gridView1.Name)
{
OstPoNom fOstPoNom = new OstPoNom(gridView1.GetFocusedDataRow().Field<string>("SklN_Nm")
, gridView1.GetFocusedDataRow().Field<decimal>("qt").ToString().TrimEnd('0').TrimEnd(',')
, gridView1.GetFocusedDataRow().Field<string>("EI_ShNm")
, gridView1.GetFocusedDataRow().Field<long>("SklN_Rcd")
, "");
fOstPoNom.Show();
}
// заказы
else if (gv.Name == gridView2.Name)
{
if (check_Zak_Storages.Checked) // со складами
{
OstPoSkl fOstPoSkl = new OstPoSkl(gridView2.GetFocusedDataRow().Field<string>("SklN_Nm")
, gridView2.GetFocusedDataRow().Field<string>("EI_ShNm")
, gridView2.GetFocusedDataRow().Field<long>("SklN_Rcd")
// SklStor_Rcd
, CacheData.GetSklStor_RcdByShAndNm(gridView2.GetFocusedDataRow().Field<string>("sklstor_Nm"), gridView2.GetFocusedDataRow().Field<string>("sklstor_Sh"))
// SklStor_Sh
, gridView2.GetFocusedDataRow().Field<string>("SklStor_Sh")
, gridView2.GetFocusedDataRow().Field<string>("prdpzk_nmr") ?? ""
, check_Zak_Storages.Checked);
fOstPoSkl.Show();
}
else // без складов
{
//debug tmp - delete after!
var _prdpzk_nmr = gridView2.GetFocusedDataRow().Field<string>("prdpzk_nmr") ?? "";
OstPoNom fOstPoNom = new OstPoNom(gridView2.GetFocusedDataRow().Field<string>("SklN_Nm")
, gridView2.GetFocusedDataRow().Field<decimal>("qt").ToString().TrimEnd('0').TrimEnd(',')
, gridView2.GetFocusedDataRow().Field<string>("EI_ShNm")
, gridView2.GetFocusedDataRow().Field<long>("SklN_Rcd")
, gridView2.GetFocusedDataRow().Field<string>("prdpzk_nmr") ?? ""
, check_Zak.Checked);
fOstPoNom.Show();
}
}
// пр.нак.
else if (gv.Name == gridView3.Name)
{
if (check_PrNacl_Storages.Checked || check_ZakPrNacl_Storages.Checked) // со складами
{
OstPoSkl fOstPoSkl = new OstPoSkl(gridView3.GetFocusedDataRow().Field<string>("SklN_Nm")
, gridView3.GetFocusedDataRow().Field<string>("EI_ShNm")
, gridView3.GetFocusedDataRow().Field<long>("SklN_Rcd")
// SklStor_Rcd
, CacheData.GetSklStor_RcdByShAndNm(gridView3.GetFocusedDataRow().Field<string>("sklstor_Nm"), gridView3.GetFocusedDataRow().Field<string>("sklstor_Sh"))
// SklStor_Sh
, gridView3.GetFocusedDataRow().Field<string>("SklStor_Sh")
, gridView3.GetFocusedDataRow().Field<string>("TOpa_AttrCd7") ?? "", check_Zak_Storages.Checked
, "", check_ZavNum_Storages.Checked
, false, gridView3.GetFocusedDataRow().Field<string>("TOpa_AttrName3") ?? "", check_PrNacl_Storages.Checked
, gridView3.GetFocusedDataRow().Field<string>("idZak") ?? "", check_ZakPrNacl_Storages.Checked);
fOstPoSkl.Show();
}
else // без складов
{
OstPoNom fOstPoNom = new OstPoNom(gridView3.GetFocusedDataRow().Field<string>("SklN_Nm")
, gridView3.GetFocusedDataRow().Field<decimal>("qt").ToString().TrimEnd('0').TrimEnd(',')
, gridView3.GetFocusedDataRow().Field<string>("EI_ShNm")
, gridView3.GetFocusedDataRow().Field<long>("SklN_Rcd")
, gridView3.GetFocusedDataRow().Field<string>("TOpa_AttrCd7") ?? "", check_Zak.Checked
, "", check_ZavNum.Checked
, gridView3.GetFocusedDataRow().Field<string>("TOpa_AttrName3") ?? "", check_PrNacl.Checked
, gridView3.GetFocusedDataRow().Field<string>("idZak") ?? "", check_ZakPrNacl.Checked
, gridView3.GetFocusedDataRow().Field<string>("sklnk_nmr") ?? "");
fOstPoNom.Show();
}
}
// заводские номера
else if (gv.Name == gridView4.Name)
{
if (check_ZavNum_Storages.Checked)
{
OstPoSkl fOstPoSkl = new OstPoSkl(gridView4.GetFocusedDataRow().Field<string>("SklN_Nm")
, gridView4.GetFocusedDataRow().Field<string>("EI_ShNm")
, gridView4.GetFocusedDataRow().Field<long>("SklN_Rcd")
// SklStor_Rcd
, CacheData.GetSklStor_RcdByShAndNm(gridView4.GetFocusedDataRow().Field<string>("sklstor_Nm"), gridView4.GetFocusedDataRow().Field<string>("sklstor_Sh"))
// SklStor_Sh
, gridView4.GetFocusedDataRow().Field<string>("SklStor_Sh")
, gridView4.GetFocusedDataRow().Field<string>("TOpa_AttrCd7") ?? ""
, check_Zak_Storages.Checked
, gridView4.GetFocusedDataRow().Field<string>("zavNmr")
, check_ZavNum_Storages.Checked
, false
, gridView4.GetFocusedDataRow().Field<string>("TOpa_AttrName3") ?? "", check_PrNacl_Storages.Checked
, gridView4.GetFocusedDataRow().Field<string>("idZak") ?? "", check_ZakPrNacl_Storages.Checked);
fOstPoSkl.Show();
}
else
{
OstPoNom fOstPoNom = new OstPoNom(gridView4.GetFocusedDataRow().Field<string>("SklN_Nm")
, gridView4.GetFocusedDataRow().Field<decimal>("qt").ToString().TrimEnd('0').TrimEnd(',')
, gridView4.GetFocusedDataRow().Field<string>("EI_ShNm")
, gridView4.GetFocusedDataRow().Field<long>("SklN_Rcd")
, gridView4.GetFocusedDataRow().Field<string>("TOpa_AttrCd7")
, check_Zak.Checked
, gridView4.GetFocusedDataRow().Field<string>("zavNmr")
, check_ZavNum.Checked
, gridView4.GetFocusedDataRow().Field<string>("TOpa_AttrName3") ?? "", check_PrNacl.Checked
, gridView4.GetFocusedDataRow().Field<string>("idZak") ?? "", check_ZakPrNacl.Checked
, gridView4.GetFocusedDataRow().Field<string>("sklnk_nmr") ?? "");
fOstPoNom.Show();
}
}
// склады
else if (gv.Name == gridView5.Name)
{
OstPoSkl fOstPoSkl = new OstPoSkl(
gridView5.GetFocusedDataRow().Field<string>("SklN_Nm")
, gridView5.GetFocusedDataRow().Field<string>("EI_ShNm")
, gridView5.GetFocusedDataRow().Field<long>("SklN_Rcd")
// SklStor_Rcd
, CacheData.GetSklStor_RcdByShAndNm(gridView5.GetFocusedDataRow().Field<string>("sklstor_Nm"), gridView5.GetFocusedDataRow().Field<string>("sklstor_Sh"))
// SklStor_Sh
, gridView5.GetFocusedDataRow().Field<string>("SklStor_Sh")
, "");
fOstPoSkl.Show();
}
// GridView не найден
else
{
throw new Exception("GridView.Name [" + gv.Name + "] not found");
}
}
// выбраны определенные склады
else
{
// без чеков
if (gv.Name == gridView1.Name)
{
OstPoNom fOstPoNom = new OstPoNom(
SklStor_Rcd
, gridView1.GetFocusedDataRow().Field<string>("SklN_Nm")
, gridView1.GetFocusedDataRow().Field<decimal>("qt").ToString().TrimEnd('0').TrimEnd(',')
, gridView1.GetFocusedDataRow().Field<string>("EI_ShNm")
, gridView1.GetFocusedDataRow().Field<long>("SklN_Rcd")
, "");
fOstPoNom.Show();
}
// заказы
else if (gv.Name == gridView2.Name)
{
if (check_Zak_Storages.Checked)
{
OstPoSkl fOstPoSkl = new OstPoSkl(gridView2.GetFocusedDataRow().Field<string>("SklN_Nm")
, gridView2.GetFocusedDataRow().Field<string>("EI_ShNm")
, gridView2.GetFocusedDataRow().Field<long>("SklN_Rcd")
// SklStor_Rcd
, CacheData.GetSklStor_RcdByShAndNm(gridView2.GetFocusedDataRow().Field<string>("sklstor_Nm"), gridView2.GetFocusedDataRow().Field<string>("sklstor_Sh"))
// SklStor_Sh
, gridView2.GetFocusedDataRow().Field<string>("SklStor_Sh")
, gridView2.GetFocusedDataRow().Field<string>("prdpzk_nmr") ?? ""
, check_Zak_Storages.Checked);
fOstPoSkl.Show();
}
else
{
OstPoNom fOstPoNom = new OstPoNom(
SklStor_Rcd
, gridView2.GetFocusedDataRow().Field<string>("SklN_Nm")
, gridView2.GetFocusedDataRow().Field<decimal>("qt").ToString().TrimEnd('0').TrimEnd(',')
, gridView2.GetFocusedDataRow().Field<string>("EI_ShNm")
, gridView2.GetFocusedDataRow().Field<long>("SklN_Rcd")
, gridView2.GetFocusedDataRow().Field<string>("prdpzk_nmr") ?? ""
, check_Zak.Checked);
fOstPoNom.Show();
}
}
// пр.нак.
else if (gv.Name == gridView3.Name)
{
if (check_PrNacl_Storages.Checked || check_ZakPrNacl_Storages.Checked)
{
OstPoSkl fOstPoSkl = new OstPoSkl(gridView3.GetFocusedDataRow().Field<string>("SklN_Nm")
, gridView3.GetFocusedDataRow().Field<string>("EI_ShNm")
, gridView3.GetFocusedDataRow().Field<long>("SklN_Rcd")
// SklStor_Rcd
, CacheData.GetSklStor_RcdByShAndNm(gridView3.GetFocusedDataRow().Field<string>("sklstor_Nm"), gridView3.GetFocusedDataRow().Field<string>("sklstor_Sh"))
// SklStor_Sh
, gridView3.GetFocusedDataRow().Field<string>("SklStor_Sh")
, gridView3.GetFocusedDataRow().Field<string>("TOpa_AttrCd7") ?? "", check_Zak_Storages.Checked
, "", check_ZavNum_Storages.Checked
, false, gridView3.GetFocusedDataRow().Field<string>("TOpa_AttrName3") ?? "", check_PrNacl_Storages.Checked
, gridView3.GetFocusedDataRow().Field<string>("idZak") ?? "", check_ZakPrNacl_Storages.Checked);
fOstPoSkl.Show();
}
else
{
OstPoNom fOstPoNom = new OstPoNom(SklStor_Rcd
, gridView3.GetFocusedDataRow().Field<string>("SklN_Nm")
, gridView3.GetFocusedDataRow().Field<decimal>("qt").ToString().TrimEnd('0').TrimEnd(',')
, gridView3.GetFocusedDataRow().Field<string>("EI_ShNm")
, gridView3.GetFocusedDataRow().Field<long>("SklN_Rcd")
, gridView3.GetFocusedDataRow().Field<string>("TOpa_AttrCd7") ?? "", check_Zak.Checked
, "", check_ZavNum.Checked
, gridView3.GetFocusedDataRow().Field<string>("TOpa_AttrName3") ?? "", check_PrNacl.Checked
, gridView3.GetFocusedDataRow().Field<string>("idZak") ?? "", check_ZakPrNacl.Checked
, gridView3.GetFocusedDataRow().Field<string>("sklnk_nmr") ?? "");
fOstPoNom.Show();
}
}
// заводские номера
else if (gv.Name == gridView4.Name)
{
if (check_ZavNum_Storages.Checked)
{
OstPoSkl fOstPoSkl = new OstPoSkl(gridView4.GetFocusedDataRow().Field<string>("SklN_Nm")
, gridView4.GetFocusedDataRow().Field<string>("EI_ShNm")
, gridView4.GetFocusedDataRow().Field<long>("SklN_Rcd")
// SklStor_Rcd
, CacheData.GetSklStor_RcdByShAndNm(gridView4.GetFocusedDataRow().Field<string>("sklstor_Nm"), gridView4.GetFocusedDataRow().Field<string>("sklstor_Sh"))
// SklStor_Sh
, gridView4.GetFocusedDataRow().Field<string>("SklStor_Sh")
, gridView4.GetFocusedDataRow().Field<string>("TOpa_AttrCd7") ?? ""
, check_Zak_Storages.Checked
, gridView4.GetFocusedDataRow().Field<string>("zavNmr")
, check_ZavNum_Storages.Checked
, false
, gridView4.GetFocusedDataRow().Field<string>("TOpa_AttrName3") ?? "", check_PrNacl_Storages.Checked
, gridView4.GetFocusedDataRow().Field<string>("idZak") ?? "", check_ZakPrNacl_Storages.Checked);
fOstPoSkl.Show();
}
else
{
OstPoNom fOstPoNom = new OstPoNom(
SklStor_Rcd
, gridView4.GetFocusedDataRow().Field<string>("SklN_Nm")
, gridView4.GetFocusedDataRow().Field<decimal>("qt").ToString().TrimEnd('0').TrimEnd(',')
, gridView4.GetFocusedDataRow().Field<string>("EI_ShNm")
, gridView4.GetFocusedDataRow().Field<long>("SklN_Rcd")
, gridView4.GetFocusedDataRow().Field<string>("TOpa_AttrCd7")
, check_Zak.Checked
, gridView4.GetFocusedDataRow().Field<string>("zavNmr")
, check_ZavNum.Checked
, gridView4.GetFocusedDataRow().Field<string>("TOpa_AttrName3") ?? "", check_PrNacl.Checked
, gridView4.GetFocusedDataRow().Field<string>("idZak") ?? "", check_ZakPrNacl.Checked
, gridView4.GetFocusedDataRow().Field<string>("sklnk_nmr") ?? "");
fOstPoNom.Show();
}
}
// склады
else if (gv.Name == gridView5.Name)
{
OstPoSkl fOstPoSkl = new OstPoSkl(
gridView5.GetFocusedDataRow().Field<string>("SklN_Nm")
, gridView5.GetFocusedDataRow().Field<string>("EI_ShNm")
, gridView5.GetFocusedDataRow().Field<long>("SklN_Rcd")
// SklStor_Rcd
, CacheData.GetSklStor_RcdByShAndNm(gridView5.GetFocusedDataRow().Field<string>("sklstor_Nm"), gridView5.GetFocusedDataRow().Field<string>("sklstor_Sh"))
// SklStor_Sh
, gridView5.GetFocusedDataRow().Field<string>("SklStor_Sh")
, "");
fOstPoSkl.Show();
}
// GridView не найден
else
{
throw new Exception("GridView.Name [" + gv.Name + "] not found");
}
}
}
catch (Exception exc)
{
XtraMessageBox.Show(exc.ToString(), "Ошибка выбора представления!", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Close();
}