コード例 #1
0
ファイル: SEC_TASK_GROUP.cs プロジェクト: 100009/hberp
        private void toolDel_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (DBGrid.CurrentRow.IsNewRow)
                {
                    DBGrid.CurrentRow.ErrorText = "";
                    DBGrid.CancelEdit();
                    return;
                }

                DialogResult result = MessageBox.Show("Do you really want to delete it?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                if (result == DialogResult.Yes)
                {
                    DeleteCurrentRow();
                    DBGrid.Rows.RemoveAt(DBGrid.CurrentRow.Index);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #2
0
        private void DBGrid_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
        {
            if (!rowChanged)
            {
                return;
            }

            DataGridViewRow row = DBGrid.Rows[e.RowIndex];

            try
            {
                this.Cursor = Cursors.WaitCursor;
                string valResult = ValidateRowEntry(e);
                if (valResult.Length > 0)
                {
                    row.ErrorText = valResult;
                    e.Cancel      = true;
                    if (row.IsNewRow)
                    {
                        row.ErrorText = "";
                        DBGrid.CancelEdit();
                    }
                    return;
                }

                string           parmid    = row.Cells[0].Value.ToString().ToUpper();
                string           parmname  = row.Cells[1].Value.ToString();
                string           parmvalue = row.Cells[2].Value.ToString();
                string           remark    = row.Cells[3].Value.ToString();
                modSysParameters mod       = new modSysParameters(parmid, parmname, parmvalue, remark, Util.UserId, DateTime.Now.ToString());
                bool             ret       = _dal.Update(parmid, mod, out Util.emsg);
                if (!ret)
                {
                    MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Failure"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    row.Cells[0].Value = row.Cells[0].Value.ToString().ToUpper();
                    row.Cells[4].Value = Util.UserId;
                    row.Cells[5].Value = DateTime.Now.ToString();
                    StatusLabel4.Text  = "Update succeed!";
                }

                rowChanged = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #3
0
        private void DBGrid_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
        {
            if (!rowChanged)
            {
                return;
            }

            DataGridViewRow row = DBGrid.Rows[e.RowIndex];

            try
            {
                this.Cursor = Cursors.WaitCursor;
                string valResult = ValidateRowEntry(e);
                if (valResult.Length > 0)
                {
                    row.ErrorText = valResult;
                    e.Cancel      = true;
                    if (row.IsNewRow)
                    {
                        row.ErrorText = "";
                        DBGrid.CancelEdit();
                    }
                    return;
                }
                //action_code,action_name,scores
                string  actioncode       = row.Cells[0].Value.ToString().ToUpper();
                string  actionname       = row.Cells[1].Value.ToString();
                decimal scores           = Convert.ToDecimal(row.Cells[2].Value);
                modCustomerScoreRule mod = new modCustomerScoreRule(actioncode, actionname, scores, 0, Util.UserId, DateTime.Now);
                bool ret = _dal.Update(actioncode, mod, out Util.emsg);
                if (!ret)
                {
                    MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Failure"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    row.Cells[0].Value = row.Cells[0].Value.ToString().ToUpper();
                    row.Cells[3].Value = Util.UserId;
                    row.Cells[4].Value = DateTime.Now.ToString();
                    StatusLabel4.Text  = "Update succeed!";
                }

                rowChanged = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #4
0
ファイル: SEC_TASK_GROUP.cs プロジェクト: 100009/hberp
        private void DBGrid_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
        {
            if (!rowChanged)
            {
                return;
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;
                DataGridViewRow row = DBGrid.Rows[e.RowIndex];

                string valResult = ValidateRowEntry(e);
                if (valResult.Length > 0)
                {
                    row.ErrorText = valResult;
                    e.Cancel      = true;
                    if (row.IsNewRow)
                    {
                        row.ErrorText = "";
                        DBGrid.CancelEdit();
                    }
                    return;
                }

                string       groupid   = row.Cells[0].Value.ToString().ToUpper();
                string       groupdesc = row.Cells[1].Value.ToString();
                int          status    = row.Cells[2].Value == null ? 0 : Convert.ToInt32(row.Cells[2].Value.ToString());
                int?         seq       = Convert.ToInt32(row.Cells[3].Value.ToString());
                modTaskGroup mod       = new modTaskGroup(groupid, groupdesc, status, seq, Util.UserId, DateTime.Now);
                if (Convert.ToDateTime(row.Cells[5].Value).Year == 1)
                {
                    bool ret = _dal.Insert(mod, out Util.emsg);
                    if (!ret)
                    {
                        MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Failure"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        row.Cells[0].Value = row.Cells[0].Value.ToString().ToUpper();
                        row.Cells[5].Value = DateTime.Now.ToString();
                        row.Tag            = "1";
                        StatusLabel4.Text  = "Add succeed!";
                    }
                }
                else
                {
                    bool ret = _dal.Update(groupid, mod, out Util.emsg);
                    if (!ret)
                    {
                        MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Failure"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        row.Cells[0].Value = row.Cells[0].Value.ToString().ToUpper();
                        row.Cells[5].Value = DateTime.Now.ToString();
                        StatusLabel4.Text  = "Update succeed!";
                    }
                }
                rowChanged = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }