/// <summary> /// 新增按钮事件 /// </summary> private void btnNew_Click(object sender, EventArgs e) { try { DataRow baseRow = TableQuotationBaseInfo.NewRow(); TableQuotationBaseInfo.Rows.Add(baseRow); bindingSource_BaseInfo.MoveLast(); ColumnView headView = (ColumnView)gridControlQuotation.FocusedView; gridViewQuotation.FocusedRowHandle = headView.FocusedRowHandle; TableCORInfo.Rows.Clear(); PageCORInfo.PageVisible = false; xtraTabBottom.SelectedTabPageIndex = 0; TableQuotationPriceInfo.Clear(); //gridViewQuotationPriceInfo.AddNewRow(); DataRow priceRow = TableQuotationPriceInfo.NewRow(); TableQuotationPriceInfo.Rows.Add(priceRow); FocusedListView(false, "CurrencyCate", gridViewQuotationPriceInfo.GetFocusedDataSourceRowIndex()); gridViewQuotationPriceInfo.RefreshData(); Set_ButtonEditGrid_State(false); textRFQNO.Focus(); } catch (Exception ex) { ExceptionHandler.HandleException(this.Text + "--新增按钮事件错误。", ex); } }
/// <summary> /// 新增按钮事件 /// </summary> private void btnNew_Click(object sender, EventArgs e) { try { if (!FrmMainDAO.QueryUserButtonPower(this.Name, this.Text, sender, true)) { return; } TableQuotationBaseInfo.Rows.Clear(); DataRow baseRow = TableQuotationBaseInfo.NewRow(); TableQuotationBaseInfo.Rows.Add(baseRow); bindingSource_BaseInfo.MoveLast(); TableQuotationPriceInfo.Clear(); //gridViewQuotationPriceInfo.AddNewRow(); DataRow priceRow = TableQuotationPriceInfo.NewRow(); TableQuotationPriceInfo.Rows.Add(priceRow); FocusedListView(false, "CurrencyCate", gridViewQuotationPriceInfo.GetFocusedDataSourceRowIndex()); gridViewQuotationPriceInfo.RefreshData(); Set_ButtonEditGrid_State(false); textRFQNO.Focus(); } catch (Exception ex) { ExceptionHandler.HandleException(this.Text + "--新增按钮事件错误。", ex); } }
/// <summary> /// 保存按钮事件 /// </summary> private void btnSave_Click(object sender, EventArgs e) { try { if (TableQuotationBaseInfo.Rows.Count == 0 || bindingSource_BaseInfo.Current == null) { return; } if (!CheckState(false, true)) { return; } if (btnSave.Text != "保存") { DataRow headRow = ((DataRowView)bindingSource_BaseInfo.Current).Row; string autoQuotationNoStr = DataTypeConvert.GetString(headRow["AutoQuotationNo"]); if (quoDAO.CheckQuotationInfo_IsSalesOrder(null, autoQuotationNoStr)) { return; } Set_ButtonEditGrid_State(false); textRFQNO.Focus(); } else { bindingSource_BaseInfo.EndEdit(); DataRow headRow = ((DataRowView)bindingSource_BaseInfo.Current).Row; if (textRFQNO.Text.Trim() == "") { MessageHandler.ShowMessageBox("手工单号不能为空,请重新操作。"); textRFQNO.Focus(); return; } if (textProjectName.Text.Trim() == "") { MessageHandler.ShowMessageBox("项目名称不能为空,请重新操作。"); textProjectName.Focus(); return; } if (searchBussinessBaseNo.Text.Trim() == "") { MessageHandler.ShowMessageBox("客户不能为空,请重新操作。"); searchBussinessBaseNo.Focus(); return; } if (textRequester.Text.Trim() == "") { MessageHandler.ShowMessageBox("客户需求人不能为空,请重新操作。"); textRequester.Focus(); return; } for (int i = gridViewQuotationPriceInfo.DataRowCount - 1; i >= 0; i--) { DataRow listRow = gridViewQuotationPriceInfo.GetDataRow(i); if (DataTypeConvert.GetString(listRow["CurrencyCate"]) == "") { gridViewQuotationPriceInfo.DeleteRow(i); continue; } if (DataTypeConvert.GetString(listRow["Amount"]) == "" || DataTypeConvert.GetDecimal(listRow["Amount"]) == 0) { MessageHandler.ShowMessageBox("金额不能为空,请填写后再进行保存。"); FocusedListView(true, "Amount", i); return; } if (DataTypeConvert.GetString(listRow["Tax"]) == "") { MessageHandler.ShowMessageBox("税率不能为空,请填写后再进行保存。"); FocusedListView(true, "Tax", i); return; } if (DataTypeConvert.GetString(listRow["Versions"]) == "") { MessageHandler.ShowMessageBox("版本不能为空,请填写后再进行保存。"); FocusedListView(true, "Versions", i); return; } if (DataTypeConvert.GetString(listRow["Offerer"]) == "") { MessageHandler.ShowMessageBox("报价人不能为空,请填写后再进行保存。"); FocusedListView(true, "Offerer", i); return; } if (DataTypeConvert.GetString(listRow["QuotationDate"]) == "") { MessageHandler.ShowMessageBox("报价日期不能为空,请填写后再进行保存。"); FocusedListView(true, "QuotationDate", i); return; } string versionsStr = DataTypeConvert.GetString(listRow["Versions"]); if (TableQuotationPriceInfo.Select(string.Format("Versions = '{0}'", versionsStr)).Length > 1) { MessageHandler.ShowMessageBox("版本号有重复,请重新填写后再进行保存。"); FocusedListView(true, "Versions", i); return; } } int ret = quoDAO.SaveQuotationInfo(headRow, TableQuotationPriceInfo); switch (ret) { case -1: break; case 1: break; case 0: return; } //currentAutoQuotationNoStr = DataTypeConvert.GetString(headRow["AutoQuotationNo"]); Set_ButtonEditGrid_State(true); gridViewQuotation_FocusedRowChanged(null, null); } } catch (Exception ex) { ExceptionHandler.HandleException(this.Text + "--保存按钮事件错误。", ex); } }