Example #1
0
        private void NewEditExit_NewClick(object sender, EventArgs e)
        {
            try
            {
                switch (NewEditExit.BtnNewText)
                {
                case "&New":
                    this.EnableDisableControls(true);
                    this.VisibleControls(false);
                    this.BindComboBox(false);
                    this.InitializeControls();
                    this.txtTripCode.Focus();
                    break;

                case "&Save":
                    if (this.CheckRequiredFields())
                    {
                        TripController       tripController       = new TripController();
                        TripInfo             tripInfo             = new TripInfo();
                        TripDetailCollection tripDetailCollection = new TripDetailCollection();

                        GetHeaderInfo(tripInfo);
                        tripDetailCollection = GetItemCollection();

                        tripController.Insert(tripInfo, tripDetailCollection);

                        string log = "Form-TripPlan;Item-TripCode:" + this.txtTripCode.Text + ";action-Save";
                        userAction.Log(log);

                        Globalizer.ShowMessage(MessageType.Information, "Saved Successfully");
                        this.ResetControl();
                    }
                    break;

                case "&Update":
                    if (this.CheckRequiredFields())
                    {
                        TripController       tripController       = new TripController();
                        TripInfo             tripInfo             = new TripInfo();
                        TripDetailCollection tripDetailCollection = new TripDetailCollection();

                        recordID = this.cboTripCode.SelectedValue.ToString();
                        GetHeaderInfo(tripInfo);
                        tripDetailCollection = GetItemCollection();

                        tripController.UpdateByTripID(tripInfo, tripDetailCollection);

                        string log = "Form-TripPlan;Item-TripCode:" + this.cboTripCode.Text + ";action-Update";
                        userAction.Log(log);

                        Globalizer.ShowMessage(MessageType.Information, "Updated Successfully");
                        this.ResetControl();
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Globalizer.ShowMessage(MessageType.Critical, ex.Message);
            }
        }