Exemplo n.º 1
0
        private void tbComment_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyData == Keys.Enter) && (tbComment.Focus()))
            {
                if (Line != null)
                {
                    var service = new SalesCommentLines_Service();
                    service.UseDefaultCredentials = true;

                    if (!tbComment.Text.Equals(""))
                    {
                        Line.Comment = tbComment.Text;
                        service.Update(ref Line);
                    }
                    else
                    {
                        if (MessageBox.Show("Vil du slette linjen?", "Slet bemærkningslinje", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                        {
                            service.Delete(Line.Key);
                        }
                    }
                    tbComment.Text = "";
                    Line           = null;
                }
                else
                {
                    var service = new BalanceWarehouse();
                    service.UseDefaultCredentials = true;

                    try
                    {
                        service.WSCreateSalesCommentLine((int)Document_Type.Order, orderno, tbComment.Text);
                        tbComment.Text = "";
                    }
                    catch (Exception ex)
                    {
                        MessageBoxExample.MyMessageBox.ShowBox(ex.Message);
                    }
                }
                GetComment();
            }

            if ((e.KeyData == Keys.Escape) && (tbComment.Focus()))
            {
                this.Close();
            }
        }