Example #1
0
        private bool DoSave()
        {
            if (this.dataGridView_Main.RowCount < 2)
            {
                return(true);
            }
            bool        flag    = false;
            string      sSql    = "";
            string      sErr    = "";
            DataRowView current = (DataRowView)this.bindingSource_Main.Current;

            if (current.IsEdit || current.IsNew)
            {
                this.UIToDataRowView(current, this.panel_Edit);
                if (current[this.strKeyFld].ToString() == "")
                {
                    current[this.strKeyFld] = DBFuns.GetNewId(base.AppInformation.SvrSocket, this.strTbNameMain, this.strKeyFld, 3, "M", out sErr);
                    sSql = DBSQLCommandInfo.GetSQLByDataRow(current, this.strTbNameMain, this.strKeyFld, "cUsed", true);
                }
                else
                {
                    sSql = DBSQLCommandInfo.GetSQLByDataRow(current, this.strTbNameMain, this.strKeyFld, "cUsed", false);
                }
                if (current.IsEdit)
                {
                    current.EndEdit();
                }
                if (DBFuns.DoExecSql(base.AppInformation.SvrSocket, sSql, DBSQLCommandInfo.GetFieldsForDate(current), out sErr))
                {
                    this.OptMain = OperateType.optSave;
                    this.CtrlOptButtons(this.tlbMain, this.panel_Edit, this.OptMain, base.DBDataSet.Tables[this.strTbNameMain]);
                    this.CtrlControlReadOnly(this.panel_Edit, false);
                    MessageBox.Show("保存数据成功!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    this.OptMain = OperateType.optNone;
                    this.DoRefresh();
                }
                else
                {
                    MessageBox.Show("保存数据失败:" + sErr, "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                return(flag);
            }
            MessageBox.Show("对不起,当前没有处于编辑状态!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            return(flag);
        }