private void btTakeMoney_Click(object sender, EventArgs e) { int id_MoneyRecipient = selectedMoneyRecipient; globalForm.frmPassword frmPass = new globalForm.frmPassword(); frmPass.idUser = id_MoneyRecipient; if (DialogResult.OK == frmPass.ShowDialog()) { foreach (DataRow r in dtPayment.Select("isControl = 1")) { int id = (int)r["id"]; int id_ServiceRecords = (int)r["id_ServiceRecords"]; string nameType = (string)r["nameType"]; decimal Summa = (decimal)r["Summa"]; int Number = (int)(r["Number"] == DBNull.Value ? 0 : r["Number"]); string FIO = (string)r["FIO"]; try { int type = (int)r["type"]; bool bCashNonCash = (bool)r["bCashNonCash"]; //if (type == 2 || bCashNonCash) id_MoneyRecipient = UserSettings.User.Id; setLog(id_ServiceRecords, nameType, Summa, Number, FIO); Config.hCntMain.updatePayment(id, id_MoneyRecipient); Config.hCntMain.updateStatus(id_ServiceRecords, 14); //getData(); } catch { MessageBox.Show("null"); } } getData(); } }
private void dgvNote_CellContentClick(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; if (e.RowIndex != -1 && senderGrid.Columns[e.ColumnIndex].Name == cControl.Name) { bool _isControl = false; if (dtPayment.DefaultView[e.RowIndex]["isControl"] != DBNull.Value) { _isControl = bool.Parse(dtPayment.DefaultView[e.RowIndex]["isControl"].ToString()); } int MoneyRecipient = (int)dtPayment.DefaultView[e.RowIndex]["id_MoneyRecipient"]; if (dtPayment.Select("isControl = 1").Count() == 0) { selectedMoneyRecipient = MoneyRecipient; } else { if (MoneyRecipient != selectedMoneyRecipient) { dtPayment.DefaultView[e.RowIndex]["isControl"] = false; dtPayment.AcceptChanges(); senderGrid.Refresh(); return; } } dtPayment.DefaultView[e.RowIndex]["isControl"] = !_isControl; dtPayment.AcceptChanges(); senderGrid.Refresh(); if (dtPayment.Select("isControl = 1").Count() == 0) { selectedMoneyRecipient = -1; dtPayment.DefaultView.RowFilter = ""; } else if (dtPayment.Select("isControl = 1").Count() == 1 && selectedMoneyRecipient != -1) { dtPayment.DefaultView.RowFilter = "id_MoneyRecipient = " + selectedMoneyRecipient; } sumTovar(); } else if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { //TODO - Button Clicked - Execute Code Here int id = (int)dtPayment.DefaultView[dgvNote.CurrentRow.Index]["id"]; int id_ServiceRecords = (int)dtPayment.DefaultView[dgvNote.CurrentRow.Index]["id_ServiceRecords"]; string nameType = (string)dtPayment.DefaultView[dgvNote.CurrentRow.Index]["nameType"]; decimal Summa = (decimal)dtPayment.DefaultView[dgvNote.CurrentRow.Index]["Summa"]; int Number = (int)dtPayment.DefaultView[dgvNote.CurrentRow.Index]["Number"]; string FIO = (string)dtPayment.DefaultView[dgvNote.CurrentRow.Index]["FIO"]; try { int id_MoneyRecipient = (int)dtPayment.DefaultView[dgvNote.CurrentRow.Index]["id_MoneyRecipient"]; int type = (int)dtPayment.DefaultView[dgvNote.CurrentRow.Index]["type"]; bool bCashNonCash = (bool)dtPayment.DefaultView[dgvNote.CurrentRow.Index]["bCashNonCash"]; //if (type == 2 || bCashNonCash) id_MoneyRecipient = UserSettings.User.Id; globalForm.frmPassword frmPass = new globalForm.frmPassword(); frmPass.idUser = id_MoneyRecipient; if (DialogResult.OK == frmPass.ShowDialog()) { setLog(id_ServiceRecords, nameType, Summa, Number, FIO); Config.hCntMain.updatePayment(id, id_MoneyRecipient); Config.hCntMain.updateStatus(id_ServiceRecords, 14); getData(); } } catch { MessageBox.Show("null"); } } }