示例#1
0
 private bool DeleteComment(SupportNoteComment comment, DataGridView datagrid)
 {
     CRUDResult delete = ApiActions.DELETE(PreferenceForm.API_MAIN_URL() + "supportnotecomment/delete&id=" + comment.id.ToString());
     ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(delete.data);
     if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
     {
         return true;
     }
     else
     {
         if (MessageAlert.Show("เกิดข้อผิดพลาด", "Error", MessageAlertButtons.RETRY_CANCEL, MessageAlertIcons.ERROR) == DialogResult.Retry)
         {
             this.DeleteComment(comment, datagrid);
         }
         return false;
     }
 }
示例#2
0
        private void ShowInlineForm(COMMENT_TYPE comment_type, FORM_MODE mode)
        {
            this.curr_comment_type = comment_type;

            DataGridView dgv = null;
            switch (comment_type)
            {
                case COMMENT_TYPE.COMMENT:
                    dgv = this.dgvComment;
                    this.inline_comment_desc = new CustomTextBox()
                    {
                        Read_Only = false
                    };
                    dgv.Parent.Controls.Add(this.inline_comment_desc);
                    break;
                case COMMENT_TYPE.COMPLAIN:
                    dgv = this.dgvComplain;
                    this.inline_comment_desc = new CustomTextBox()
                    {
                        Read_Only = false
                    };
                    dgv.Parent.Controls.Add(this.inline_comment_desc);
                    break;
                case COMMENT_TYPE.NONE:
                    break;
                default:
                    break;
            }

            if (dgv != null && mode == FORM_MODE.ADD)
            {
                dgv.Rows[dgv.Rows.Add()].Cells[0].Selected = true;
                this.prepared_comment = new SupportNoteComment();
                this.prepared_comment.id = -1;
                this.prepared_comment.type = (int)comment_type;
                this.prepared_comment.note_id = this.note_id;
                this.prepared_comment.rec_by = this.parent_wind.main_form.G.loged_in_user_name;
                this.FormAdd();
            }

            if (dgv != null && mode == FORM_MODE.EDIT && dgv.Rows[dgv.CurrentCell.RowIndex].Tag is SupportNoteComment)
            {
                this.prepared_comment = (SupportNoteComment)dgv.Rows[dgv.CurrentCell.RowIndex].Tag;
                this.prepared_comment.rec_by = this.parent_wind.main_form.G.loged_in_user_name;

                this.inline_comment_desc.Texts = this.prepared_comment.description;
                this.FormEdit();
            }

            this.SetInlineFormPosition(dgv);
            dgv.Enabled = false;
            dgv.SendToBack();
            this.inline_comment_desc.BringToFront();
            this.inline_comment_desc.Focus();
            this.inline_comment_desc.SelectionStart = 0;
            this.inline_comment_desc.SelectionLength = 0;

            dgv.Tag = HelperClass.DGV_TAG.READ;
            dgv.Refresh();
        }
示例#3
0
        private void ClearInlineForm(DataGridView dgv)
        {
            this.prepared_comment = null;
            if (this.inline_comment_desc != null)
            {
                this.inline_comment_desc.Dispose();
                this.inline_comment_desc = null;
            }
            dgv.Enabled = true;

            if (dgv.Rows.Cast<DataGridViewRow>().Where(r => !(r.Tag is SupportNoteComment)).Count<DataGridViewRow>() > 0)
                dgv.Rows.Remove(dgv.Rows.Cast<DataGridViewRow>().Where(r => !(r.Tag is SupportNoteComment)).First<DataGridViewRow>());
        }