Focus offers grid on MG select so qty can be typed immediately.
This commit is contained in:
parent
5c439fe780
commit
7f3bc2eb35
@ -741,6 +741,79 @@ namespace Электронная_Фармация.UserControls
|
|||||||
AppDebugLog.Error("PriceList", "Не удалось применить фильтр наименование+МГ", ex);
|
AppDebugLog.Error("PriceList", "Не удалось применить фильтр наименование+МГ", ex);
|
||||||
bsPriceList.RemoveFilter();
|
bsPriceList.RemoveFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FocusOffersGridForInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FocusOffersGridForInput()
|
||||||
|
{
|
||||||
|
if (!IsHandleCreated)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BeginInvoke(new Action(() =>
|
||||||
|
{
|
||||||
|
if (_browseMode != PriceBrowseMode.Offers || !dgvPriceList.Visible)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnsureOffersRowSelected();
|
||||||
|
dgvPriceList.Focus();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool EnsureOffersRowSelected()
|
||||||
|
{
|
||||||
|
if (_browseMode != PriceBrowseMode.Offers || dgvPriceList.Rows.Count == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dgvPriceList.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < dgvPriceList.Rows.Count; i++)
|
||||||
|
{
|
||||||
|
var row = dgvPriceList.Rows[i];
|
||||||
|
if (row.IsNewRow)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
_suppressPriceListSelectionEvents = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
row.Selected = true;
|
||||||
|
var columnIndex = GetPreferredOffersSelectionColumnIndex();
|
||||||
|
if (columnIndex >= 0 && columnIndex < row.Cells.Count)
|
||||||
|
{
|
||||||
|
dgvPriceList.CurrentCell = row.Cells[columnIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_suppressPriceListSelectionEvents = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowMePriceWithMarkupPercentForSelectedGood();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetPreferredOffersSelectionColumnIndex()
|
||||||
|
{
|
||||||
|
if (dgvPriceList.Columns.Contains("Наименование"))
|
||||||
|
{
|
||||||
|
return dgvPriceList.Columns["Наименование"].Index;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dgvPriceList.Columns.Count > 3 ? 3 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BindOffersTable()
|
private void BindOffersTable()
|
||||||
@ -1481,14 +1554,26 @@ and tempOrder.GoodName = PriceList.GoodName
|
|||||||
int RowIndex = -1;
|
int RowIndex = -1;
|
||||||
string idPriceListItem = string.Empty;
|
string idPriceListItem = string.Empty;
|
||||||
|
|
||||||
if (_browseMode == PriceBrowseMode.Offers && dgvPriceList.SelectedRows.Count > 0)
|
if (_browseMode == PriceBrowseMode.Offers)
|
||||||
{
|
{
|
||||||
RowIndex = dgvPriceList.SelectedRows[0].Index;
|
if (IsOrderQuantityStartKey(e.KeyChar))
|
||||||
if (RowIndex >= 0
|
|
||||||
&& RowIndex < dgvPriceList.Rows.Count
|
|
||||||
&& dgvPriceList.Rows[RowIndex].Cells.Count > 11)
|
|
||||||
{
|
{
|
||||||
idPriceListItem = dgvPriceList.Rows[RowIndex].Cells[11].Value?.ToString() ?? string.Empty;
|
EnsureOffersRowSelected();
|
||||||
|
if (!dgvPriceList.Focused)
|
||||||
|
{
|
||||||
|
dgvPriceList.Focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dgvPriceList.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
RowIndex = dgvPriceList.SelectedRows[0].Index;
|
||||||
|
if (RowIndex >= 0
|
||||||
|
&& RowIndex < dgvPriceList.Rows.Count
|
||||||
|
&& dgvPriceList.Rows[RowIndex].Cells.Count > 11)
|
||||||
|
{
|
||||||
|
idPriceListItem = dgvPriceList.Rows[RowIndex].Cells[11].Value?.ToString() ?? string.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2117,6 +2202,12 @@ and SumOrderedItems = '{SumOrder}'";
|
|||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsOrderQuantityStartKey(char keyChar)
|
||||||
|
{
|
||||||
|
return (keyChar >= (char)Keys.D1 && keyChar <= (char)Keys.D9)
|
||||||
|
|| (keyChar >= (char)Keys.NumPad1 && keyChar <= (char)Keys.NumPad9);
|
||||||
|
}
|
||||||
|
|
||||||
private void dgvPriceList_SelectionChanged(object sender, EventArgs e)
|
private void dgvPriceList_SelectionChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_suppressPriceListSelectionEvents)
|
if (_suppressPriceListSelectionEvents)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user