private void BindDataGridView() { TimeScheduleController timeController = new TimeScheduleController(); TimeCollections timeCollections = timeController.SelectList(); this.dgvTimeSchedule.AutoGenerateColumns = false; this.dgvTimeSchedule.DataSource = timeCollections; }
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); } }
private void TimeScheduleReport_Load(object sender, EventArgs e) { TimeScheduleController Controller = new TimeScheduleController(); rpvTimeSchedule.LocalReport.DataSources.Clear(); ReportDataSource rds = new ReportDataSource(); rds.Name = "TimeScheduleDataSet_TimeScheduleDataTable"; rds.Value = Controller.SelectList(); this.rpvTimeSchedule.LocalReport.DataSources.Add(rds); rpvTimeSchedule.ZoomMode = ZoomMode.Percent; this.rpvTimeSchedule.RefreshReport(); }
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; }
private void dgvTimeSchedule_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } try { switch (e.ColumnIndex) { case 0: this.recordID = this.dgvTimeSchedule.Rows[e.RowIndex].Cells["TimeID"].Value.ToString(); this.txtTime.Text = this.dgvTimeSchedule.Rows[e.RowIndex].Cells["Time"].Value.ToString(); this.txtDescription.Text = this.dgvTimeSchedule.Rows[e.RowIndex].Cells["Description"].Value.ToString(); this.btnSave.Text = "&Update"; break; case 1: if (Globalizer.ShowMessage(MessageType.Question, "Are you sure want to delete?") == DialogResult.Yes) { recordID = this.dgvTimeSchedule.Rows[e.RowIndex].Cells["TimeID"].Value.ToString(); TimeScheduleController timeController = new TimeScheduleController(); timeController.DeleteByTimeID(recordID); string log = "Form-TimeSchedule;Item-Time:" + this.txtTime.Text + ";action-:Delete"; userAction.Log(log); this.InitializeControls(); this.BindDataGridView(); Globalizer.ShowMessage(MessageType.Information, "Deleted Successfully"); } break; } } catch (Exception ex) { Globalizer.ShowMessage(MessageType.Critical, ex.Message); } }