Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string strRating = "";
            Messages oErrMsg = Messages.Instance;
            FeedBack oFeedBack = new FeedBack();
            picbox.Visible = true;

            Application.DoEvents();

            if (cboRating.Text.Trim() == "--Select--")
            {
                strRating = "";
            }
            else
            {
                strRating = cboRating.Text.Trim();
            }

            try
            {

                oErrMsg = oFeedBack.UpdateFeedBack(JobID, strRating, txtComments.Text.Trim(), AccountRef, PartNumber);
                if (!oErrMsg.IsError)
                {
                    picbox.Visible = false;
                    comments _cmm = new comments();
                    _cmm.Comments = txtComments.Text;
                    _cmm.Rating = strRating;
                    _cmm.Row = this.Row;
                    _cmm.Col = this.Col;
                    OnValueChanged(_cmm);

                    DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    picbox.Visible = false;
                    MessageBox.Show(oErrMsg.Message);
                }
            }
            catch (Exception ex)
            {
                picbox.Visible = false;
                MessageBox.Show(ex.Message.ToString());
            }
        }
        private void Search()
        {
            Messages oErrMsg = Messages.Instance;
            FeedBack oFeedBack = new FeedBack();

            DataSet ds = null;

            if (this.InvokeRequired)
            {

                this.Invoke(new MethodInvoker(delegate
                {
                    this.Cursor = Cursors.WaitCursor;
                    btnSearch.Enabled = false;
                }));
            }
            else
            {
                this.Cursor = Cursors.WaitCursor;
                btnSearch.Enabled = false;
            }

            if (!Utils.PingTest())
            {
                if (this.InvokeRequired)
                {
                    this.Invoke(new MethodInvoker(delegate
                    {
                        this.Cursor = Cursors.Default;
                        MessageBox.Show("VPN disconnected. Please connect and try again.", "CSRAssistance");
                        return;
                    }));
                }
                else
                {
                    this.Cursor = Cursors.Default;
                    MessageBox.Show("VPN disconnected. Please connect and try again.", "CSRAssistance");
                    return;
                }

            }

            if (chkExcludeCallCust.InvokeRequired)
            {
                chkExcludeCallCust.Invoke(new MethodInvoker(delegate
                {
                    oErrMsg = oFeedBack.LoadData(dtfrom.Value.ToString("yyyyMMdd"),
                        dtto.Value.ToString("yyyyMMdd"),
                        (chkExcludeCallCust.Checked ? 1 : 0),
                        txtSearch.Text, 1,
                        Pager.PageSize,
                        false,
                        txtJobID.Text,
                        dtExFrom.Value.ToString("yyyyMMdd"),
                        dtExTo.Value.ToString("yyyyMMdd"),
                        (chkRepair.Checked ? 1 : 0),
                        RangeExclude);
                }));
            }
            else
            {
                oErrMsg = oFeedBack.LoadData(dtfrom.Value.ToString("yyyyMMdd"),
                dtto.Value.ToString("yyyyMMdd"),
                (chkExcludeCallCust.Checked ? 1 : 0),
                txtSearch.Text, 1,
                Pager.PageSize,
                false,
                txtJobID.Text,
                dtExFrom.Value.ToString("yyyyMMdd"),
                dtExTo.Value.ToString("yyyyMMdd"),
                (chkRepair.Checked ? 1 : 0),
                RangeExclude);

            }

            if (!oErrMsg.IsError)
            {
                ds = (DataSet) oErrMsg.Results;

                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0] != null)
                    {
                        dtExport = ds.Tables[0];
                    }
                }

                if (outlookGrid1.InvokeRequired)
                {
                    outlookGrid1.Invoke(new MethodInvoker(delegate
                    {
                        if (ds.Tables.Count > 0)
                        {
                            outlookGrid1.BindData(ds, "data");
                            View = "BoundInvoices";
                            DataGridViewCellEventArgs evt = new DataGridViewCellEventArgs(2, -1);
                            object sender = null;
                        }
                    }));
                }
                else
                {
                    if (ds.Tables.Count > 0)
                    {
                        outlookGrid1.BindData(ds, "data");
                        View = "BoundInvoices";
                        DataGridViewCellEventArgs evt = new DataGridViewCellEventArgs(2, -1);
                        object sender = null;
                    }
                }

                this.Invoke(new Action(() =>
                {
                    this.wfrm.Hide();
                    Pager.RecordCount = 0;
                    if (ds.Tables.Count > 0)
                        Pager.RecordCount = Convert.ToInt32(ds.Tables["counter"].Rows[0]["CNT"].ToString());

                    Pager.PageSize = 20;
                    Pager.MaximumNumberofLinks = (Pager.RecordCount > 0 ? 5 : 0);
                    lblCount.Text = Pager.RecordCount.ToString();

                    if (Pager.RecordCount > 0)
                        Pager.Visible = true;
                    else
                        Pager.Visible = false;
                }));

            }
            else
            {
                this.Invoke(new Action(() =>
                {
                    this.wfrm.Hide();
                    MessageBox.Show(oErrMsg.Message);
                }));

            }

            this.Invoke(new Action(() =>
            {
                this.btnSearch.Enabled = true;
                this.Cursor = Cursors.Default;
            }));
        }
        private void btnSearchRating_Click(object sender, EventArgs e)
        {
            Messages oErrMsg = Messages.Instance;
            FeedBack oFeedBack = new FeedBack();

            DataSet ds = null;
            this.Cursor = Cursors.WaitCursor;
            btnSearchRating.Enabled = false;

            if (!Utils.PingTest())
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show("VPN disconnected. Please connect and try again.", "CSRAssistance");
                return;
            }

            oErrMsg = oFeedBack.LoadRating(dtRateFrom.Value.ToString("yyyyMMdd"),
            dtRateTo.Value.ToString("yyyyMMdd"),
            (cboRating.Text == "--Select--" ? string.Empty : cboRating.Text),
            (chkBlankComment.Checked ? 1 : 0), 20,
            1);

            if (!oErrMsg.IsError)
            {
                ds = (DataSet)oErrMsg.Results;
                if (ds.Tables.Count > 0)
                {
                    dgList.DataSource = ds.Tables[0];
                }

                this.wfrm.Hide();
                bbaPager1.RecordCount = 0;
                if (ds.Tables.Count > 0)
                    bbaPager1.RecordCount = Convert.ToInt32(ds.Tables["counter"].Rows[0]["CNT"].ToString());

                bbaPager1.PageSize = 20;
                bbaPager1.MaximumNumberofLinks = (bbaPager1.RecordCount > 0 ? 5 : 0);
                lblCounter.Text = bbaPager1.RecordCount.ToString();

                if (bbaPager1.RecordCount > 0)
                {
                    bbaPager1.Visible = true;
                }
                else
                {
                    bbaPager1.Visible = false;
                }
                this.Cursor = Cursors.Default;
                btnSearchRating.Enabled = true;
            }
            else
            {
                this.wfrm.Hide();
                this.btnRatingSearch.Enabled = true;
                this.Cursor = Cursors.Default;
                MessageBox.Show(oErrMsg.Message);
            }
        }
        private void Pager_PageClicked(object sender, PagerControl.PageClickEventHandler e)
        {
            Messages oErrMsg = Messages.Instance;
            FeedBack oFeedBack = new FeedBack();
            DataSet ds = null;
            oErrMsg = oFeedBack.LoadData(dtfrom.Value.ToString("yyyyMMdd"),
            dtto.Value.ToString("yyyyMMdd"),
            (chkExcludeCallCust.Checked ? 1 : 0),
            txtSearch.Text, e.SelectedPage,
            Pager.PageSize,
            false,
            txtJobID.Text,
            dtExFrom.Value.ToString("yyyyMMdd"),
            dtExTo.Value.ToString("yyyyMMdd"),
            (chkRepair.Checked ? 1 : 0),
            (chkExcludeCallCust.Checked ? 1 : 0));

            if(!oErrMsg.IsError)
            {
                ds = (DataSet)oErrMsg.Results;
                if (ds.Tables.Count > 0)
                {
                    outlookGrid1.BindData(ds, "data");
                    View = "BoundInvoices";
                    DataGridViewCellEventArgs evt = new DataGridViewCellEventArgs(2, -1);
                }
            }
        }
        private void bbaPager1_PageClicked(object sender, PagerControl.PageClickEventHandler e)
        {
            Messages oErrMsg = Messages.Instance;
            FeedBack oFeedBack = new FeedBack();
            DataSet ds = null;

            oErrMsg = oFeedBack.LoadRating(dtRateFrom.Value.ToString("yyyyMMdd"),
            dtRateTo.Value.ToString("yyyyMMdd"),
            (cboRating.Text == "--Select--" ? string.Empty : cboRating.Text),
            (chkBlankComment.Checked ? 1 : 0), 20,
            e.SelectedPage);

            if (!oErrMsg.IsError)
            {
                ds = (DataSet)oErrMsg.Results;
                if (ds.Tables.Count > 0)
                {
                    dgList.DataSource = ds.Tables[0];
                }
            }
        }