/// <summary> /// 检查明细是否输入本次核销 /// </summary> /// <param name="dgv"></param> /// <param name="colName"></param> /// <returns></returns> bool CheckDetail(DataGridViewEx dgv, string colName, string colWaitMoneyName) { if (!dgv.Visible) { return true; } if (dgv.Rows.Count == 0) { MessageBoxEx.Show("请导入往来单据!"); dgv.Focus(); return false; } bool check = true; foreach (DataGridViewRow dgvr in dgv.Rows) { if (dgvr.IsNewRow) { continue; } string waitMoney = CommonCtrl.IsNullToString(dgvr.Cells[colWaitMoneyName].Value);//待结算 if (waitMoney.Length == 0) { return true; } string nameNum = CommonCtrl.IsNullToString(dgvr.Cells[colName].Value); if (nameNum.Length == 0) { MessageBoxEx.Show("请输入本次核销!"); dgv.CurrentCell = dgvr.Cells[colName]; check = false; break; } if (decimal.Parse(waitMoney) < decimal.Parse(nameNum)) { MessageBoxEx.Show("本次核销不能大于未结算金额!"); dgv.CurrentCell = dgvr.Cells[colName]; check = false; break; } } return check; }
public void SelectCell(int col, int row) { _gridView.Focus(); _gridView.ClearSelection(); _gridView.CurrentCell = _gridView[col, row]; }
/// <summary> /// 检查明细是否输入本次核销 /// </summary> /// <param name="dgv">DataGridView</param> /// <param name="colName">本次核销列名</param> /// <param name="colWaitMoneyName">待核销列名</param> /// <param name="orderID">单据ID列名</param> /// <param name="orderName">单据名称列名</param> /// <param name="verification_money">冲销金额</param> /// <returns></returns> bool CheckDetail(DataGridViewEx dgv, string colName, string colWaitMoneyName, string orderID, string orderName, ref decimal verification_money) { if (!dgv.Visible) { return true; } if (dgv.Rows.Count == 0) { MessageBoxEx.Show("请导入往来单据!"); dgv.Focus(); return false; } bool check = true; foreach (DataGridViewRow dgvr in dgv.Rows) { if (dgvr.IsNewRow) { continue; } string waitMoney = CommonCtrl.IsNullToString(dgvr.Cells[colWaitMoneyName].Value);//待结算 DataSources.EnumAccountVerification orderType = (DataSources.EnumAccountVerification)Convert.ToInt32(cboOrderType.SelectedValue); if (waitMoney.Length == 0) { //预付转预付,预收转预收不必有待结算,其它必须有待结算 if (orderType != DataSources.EnumAccountVerification.YuFuToYuFu && orderType != DataSources.EnumAccountVerification.YuShouToYuShou) { return true; } } string nameNum = CommonCtrl.IsNullToString(dgvr.Cells[colName].Value); if (nameNum.Length == 0) { MessageBoxEx.Show("请输入本次核销!"); dgv.CurrentCell = dgvr.Cells[colName]; check = false; break; } //预付转预付,预收转预收不必比较待结算,其它待结算=本次核销 if (orderType != DataSources.EnumAccountVerification.YuFuToYuFu && orderType != DataSources.EnumAccountVerification.YuShouToYuShou) { string documentID = CommonCtrl.IsNullToString(dgvr.Cells[orderID].Value);//单据ID string documentType = CommonCtrl.IsNullToString(dgvr.Cells[orderName].Value);//单据名称 if (!Financial.CheckDocument(documentID, documentType, decimal.Parse(nameNum))) { MessageBoxEx.Show("本次核销不能大于未结算金额!"); dgv.CurrentCell = dgvr.Cells[colName]; check = false; break; } } //只合计第一个 if (colName == colVerificationMoney.Name) { verification_money += Convert.ToDecimal(dgvr.Cells[colName].Value); } } return check; }