Пример #1
0
        /// <summary>
        /// 保存按钮事件
        /// </summary>
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!FrmMainDAO.QueryUserButtonPower(this.Name, this.Text, sender, true))
                {
                    return;
                }

                if (TableStnModule.Rows.Count == 0 || bindingSource_StnModule.Current == null)
                {
                    return;
                }

                if (btnSave.Text != "保存")
                {
                    //DataRow headRow = ((DataRowView)bindingSource_StnModule.Current).Row;
                    //string autoQuotationNoStr = DataTypeConvert.GetString(headRow["AutoQuotationNo"]);
                    //if (quoDAO.CheckQuotationInfo_IsSalesOrder(null, autoQuotationNoStr))
                    //    return;

                    Set_ButtonEditGrid_State(false);
                    textFunctionDesc.Focus();
                }
                else
                {
                    bindingSource_StnModule.EndEdit();
                    DataRow headRow = ((DataRowView)bindingSource_StnModule.Current).Row;

                    if (textFunctionDesc.Text.Trim() == "")
                    {
                        MessageHandler.ShowMessageBox("功能简述不能为空,请重新操作。");
                        textFunctionDesc.Focus();
                        return;
                    }

                    if (headRow.RowState == DataRowState.Modified)
                    {
                        int count = new FrmStnSummaryDAO().QueryOtherStnUseModuleCount(DataTypeConvert.GetString(headRow["SMNo"]), 0);
                        if (count > 1)
                        {
                            if (MessageHandler.ShowMessageBox_YesNo(string.Format("功能模块[{0}]有{1}个工位信息使用,确认继续修改吗?", DataTypeConvert.GetString(headRow["SMNo"]), count)) != DialogResult.Yes)
                            {
                                return;
                            }
                        }
                    }
                    string tmpSMNoStr = "";
                    if (copyRow != null)
                    {
                        if (MessageHandler.ShowMessageBox_YesNo("确认是否复制供货明细信息?") == DialogResult.Yes)
                        {
                            tmpSMNoStr = DataTypeConvert.GetString(copyRow["SMNo"]);
                        }
                    }
                    int ret = smDAO.SaveStnModule(headRow, tmpSMNoStr, StnSummaryListModule_AutoId);
                    switch (ret)
                    {
                    case -1:

                        break;

                    case 1:
                        if (DataTypeConvert.GetString(textCommon.Tag) != "")
                        {
                            copyNewSMNoStr = DataTypeConvert.GetString(headRow["SMNo"]);
                            StnSummaryListModule_AutoId = 0;
                        }
                        copyRow        = null;
                        textCommon.Tag = "";
                        break;

                    case 0:
                        return;
                    }

                    //currentAutoQuotationNoStr = DataTypeConvert.GetString(headRow["AutoQuotationNo"]);
                    Set_ButtonEditGrid_State(true);

                    gridViewStnModule_FocusedRowChanged(null, null);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(this.Text + "--保存按钮事件错误。", ex);
            }
        }