private void BindDataGridView() { UserLevelController userLevelController = new UserLevelController(); UserLevelCollections userLevelCollections = userLevelController.SelectList(); this.dgvUserLevel.AutoGenerateColumns = false; this.dgvUserLevel.DataSource = userLevelCollections; }
private void btnSave_Click(object sender, EventArgs e) { try { switch (this.btnSave.Text) { case "&Save": if (CheckRequiredFields()) { UserLevelController userLevelController = new UserLevelController(); UserLevelInfo userLevelInfo = new UserLevelInfo(); userLevelInfo.UserLevelID = this.recordID; userLevelInfo.UserLevelCode = this.txtUserLevelCode.Text.Trim(); userLevelInfo.UserLevel = this.txtUserLevel.Text.Trim(); userLevelController.Insert(userLevelInfo); string log = "Form-UserLevel;Item-UserLevelCode:" + this.txtUserLevelCode.Text + ";action-Save"; userAction.Log(log); this.InitializeControls(); this.BindDataGridView(); Globalizer.ShowMessage(MessageType.Information, "Saved Successfully"); } break; case "&Update": if (CheckRequiredFields()) { UserLevelController userLevelController = new UserLevelController(); UserLevelInfo userLevelInfo = new UserLevelInfo(); userLevelInfo.UserLevelID = this.recordID; userLevelInfo.UserLevelCode = this.txtUserLevelCode.Text.Trim(); userLevelInfo.UserLevel = this.txtUserLevel.Text.Trim(); userLevelController.UpdateByUserLevelID(userLevelInfo); string log = "Form-UserLevel;Item-UserLevelCode:" + this.txtUserLevelCode.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 UserLevelReport_Load(object sender, EventArgs e) { UserLevelController Controller = new UserLevelController(); rpvUserLevel.LocalReport.DataSources.Clear(); ReportDataSource rds = new ReportDataSource(); rds.Name = "UserLevelDataSet_UserLevelDataTable"; rds.Value = Controller.SelectList(); this.rpvUserLevel.LocalReport.DataSources.Add(rds); rpvUserLevel.ZoomMode = ZoomMode.Percent; this.rpvUserLevel.RefreshReport(); }
private void BindUserLevel() { UserLevelController userLevelController = new UserLevelController(); UserLevelCollections userLevelCollections = userLevelController.SelectList(); UserLevelInfo info = new UserLevelInfo(); info.UserLevel = " - Select One - "; info.UserLevelID = null; userLevelCollections.Insert(0, info); this.cboUserLevel.DisplayMember = "UserLevel"; this.cboUserLevel.ValueMember = "UserLevelID"; this.cboUserLevel.DataSource = userLevelCollections; this.cboUserLevel.SelectedIndex = 0; }
private void dgvUserLevel_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } try { switch (e.ColumnIndex) { case 0: this.recordID = this.dgvUserLevel.Rows[e.RowIndex].Cells["UserLevelID"].Value.ToString(); this.txtUserLevelCode.Text = this.dgvUserLevel.Rows[e.RowIndex].Cells["UserLevelCode"].Value.ToString(); this.txtUserLevel.Text = this.dgvUserLevel.Rows[e.RowIndex].Cells["UserLevel"].Value.ToString(); this.btnSave.Text = "&Update"; break; case 1: if (Globalizer.ShowMessage(MessageType.Question, "Are you sure want to delete?") == DialogResult.Yes) { recordID = this.dgvUserLevel.Rows[e.RowIndex].Cells["UserLevelID"].Value.ToString(); UserLevelController userLevelController = new UserLevelController(); userLevelController.DeleteByUserLevelID(recordID); string log = "Form-UserLevel;Item-UserLevelCode:" + this.txtUserLevelCode.Text + ";action-Delete"; userAction.Log(log); this.InitializeControls(); this.BindDataGridView(); Globalizer.ShowMessage(MessageType.Information, "Delete Successful"); } break; } } catch (Exception ex) { Globalizer.ShowMessage(MessageType.Critical, ex.Message); } }