예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                switch (this.btnSave.Text)
                {
                case "&Save":
                    if (CheckRequiredFields())
                    {
                        TimeScheduleController timeController = new TimeScheduleController();
                        TimeScheduleInfo       timeInfo       = new TimeScheduleInfo();

                        timeInfo.TimeID      = this.recordID;
                        timeInfo.Time        = this.txtTime.Text.Trim();
                        timeInfo.Description = this.txtDescription.Text.Trim();

                        timeController.Insert(timeInfo);

                        string log = "Form-TimeSchedule;Item-Time:" + this.txtTime.Text + ";action-Save";
                        userAction.Log(log);

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

                case "&Update":
                    if (CheckRequiredFields())
                    {
                        TimeScheduleController timeController = new TimeScheduleController();
                        TimeScheduleInfo       timeInfo       = new TimeScheduleInfo();

                        timeInfo.TimeID      = this.recordID;
                        timeInfo.Time        = this.txtTime.Text.Trim();
                        timeInfo.Description = this.txtDescription.Text.Trim();

                        timeController.UpdateByTimeID(timeInfo);

                        string log = "Form-TimeSchedule;Item-Time:" + this.txtTime.Text + ";action-Update";
                        userAction.Log(log);

                        this.InitializeControls();
                        this.BindDataGridView();
                        Globalizer.ShowMessage(MessageType.Information, "Updated Successfully");
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Globalizer.ShowMessage(MessageType.Critical, ex.Message);
            }
        }
예제 #2
0
        private void BindTime()
        {
            TimeScheduleController timeController  = new TimeScheduleController();
            TimeCollections        timeCollections = timeController.SelectList();
            TimeScheduleInfo       info            = new TimeScheduleInfo();

            info.Time   = " - Select One - ";
            info.TimeID = null;
            timeCollections.Insert(0, info);

            this.cboTime.DisplayMember = "Time";
            this.cboTime.ValueMember   = "TimeID";
            this.cboTime.DataSource    = timeCollections;
            this.cboTime.SelectedIndex = 0;
        }