예제 #1
0
        private void OnItemClick(object sender, System.EventArgs e)
        {
            //Menu services
            int             number    = 0;
            LTLConsignee2   consignee = null;
            dlgLTLConsignee dlg       = null;

            try {
                ToolStripItem menu = (ToolStripItem)sender;
                switch (menu.Name)
                {
                case "csNew":
                    consignee = new LTLConsignee2();
                    consignee.ClientNumber = this.cboClient.SelectedValue.ToString();
                    consignee.Number       = 0;
                    dlg      = new dlgLTLConsignee(consignee);
                    dlg.Font = this.Font;
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {
                        this.Cursor = Cursors.WaitCursor;
                        number      = FreightGateway.CreateLTLConsignee(consignee);
                        MessageBox.Show(this, "New consignee created.", App.Product, MessageBoxButtons.OK);
                        Refresh();
                    }
                    break;

                case "csOpen":
                    number    = int.Parse(this.grdConsignees.Selected.Rows[0].Cells["ConsigneeNumber"].Value.ToString());
                    consignee = FreightGateway.ReadLTLConsignee(number, this.cboClient.SelectedValue.ToString());
                    dlg       = new dlgLTLConsignee(consignee);
                    dlg.Font  = this.Font;
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {
                        this.Cursor = Cursors.WaitCursor;
                        FreightGateway.UpdateLTLConsignee(consignee);
                        MessageBox.Show(this, "Consignee updated.", App.Product, MessageBoxButtons.OK);
                        Refresh();
                    }
                    break;

                case "csRefresh":
                    this.Cursor = Cursors.WaitCursor;
                    Refresh();
                    break;
                }
            }
            catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
            finally { setUserServices(); this.Cursor = Cursors.Default; }
        }