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

                case "&Save":
                    if (this.CheckRequiredFields())
                    {
                        BusController busController = new BusController();
                        BusInfo       busInfo       = new BusInfo();

                        busInfo.BusID      = string.Empty;
                        busInfo.BusCode    = this.txtBusCode.Text.Trim();
                        busInfo.BusNo      = this.txtBusNumber.Text.Trim();
                        busInfo.BusTypeID  = this.cboBusType.SelectedValue.ToString();
                        busInfo.TotalSeats = Convert.ToInt32(this.lblTotalSeat.Text.Trim());

                        busController.Insert(busInfo);

                        string log = "Form-Bus;Item-BusCode:" + this.txtBusCode.Text + ";action-Save";
                        userAction.Log(log);

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

                        this.txtBusCode.Focus();
                    }
                    break;

                case "&Update":
                    if (this.CheckRequiredFields())
                    {
                        BusController busController = new BusController();
                        BusInfo       busInfo       = new BusInfo();

                        busInfo.BusID      = this.cboBusCode.SelectedValue.ToString();
                        busInfo.BusCode    = this.cboBusCode.Text.Trim();
                        busInfo.BusNo      = this.txtBusNumber.Text.Trim();
                        busInfo.BusTypeID  = this.cboBusType.SelectedValue.ToString();
                        busInfo.TotalSeats = Convert.ToInt32(this.lblTotalSeat.Text.Trim());

                        busController.UpdateByBusID(busInfo);

                        string log = "Form-Bus;Item-BusCode:" + this.cboBusCode.Text + ";action-Update";
                        userAction.Log(log);

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