} //end function public StudentSections StudentSectionsSelectByID(int intSectionID) { try { string sp_name = "StudentSectionsSelectByID"; comStudentSections.Parameters.AddWithValue("SectionID", intSectionID); ConnectAndExecute(sp_name); //no parameter will send to stored procedure if (dsStudentSections.Tables[0].Rows.Count == 1) { DataRow drStudentSections = dsStudentSections.Tables[0].Rows[0]; StudentSections objStudentSections = new StudentSections(); objStudentSections.SectionID = Convert.ToInt64(drStudentSections["SectionID"]); objStudentSections.SectionName = Convert.ToString(drStudentSections["SectionName"]); objStudentSections.SessionID = Convert.ToInt64(drStudentSections["SessionID"]); objStudentSections.CreatedByID = Convert.ToInt64(drStudentSections["CreatedByID"]); objStudentSections.CreatedDateTime = Convert.ToDateTime(drStudentSections["CreatedDateTime"]); objStudentSections.LastUpdateDateTime = Convert.ToDateTime(drStudentSections["LastUpdateDateTime"]); objStudentSections.LastUpdateByID = Convert.ToInt64(drStudentSections["LastUpdateByID"]); objStudentSections.IsEnabled = Convert.ToBoolean(drStudentSections["IsEnabled"]); objStudentSections.Remarks = Convert.ToString(drStudentSections["Remarks"]); return(objStudentSections); } return(null); } catch (Exception ex) { SetError(ex.Message); return(null); } //end try } //end function
private void btnSave_Click(object sender, EventArgs e) { try { StudentSections studentSections = new StudentSections(); studentSections.SectionID = Convert.ToInt32(txtSectionName.Tag); studentSections.SectionName = txtSectionName.Text; studentSections.SessionID = Convert.ToInt64(cmbStudentSession.SelectedValue); studentSections.CreatedDateTime = System.DateTime.Now; studentSections.CreatedByID = Convert.ToInt32(this.Tag); studentSections.LastUpdateByID = Convert.ToInt32(this.Tag); studentSections.LastUpdateDateTime = System.DateTime.Now; studentSections.IsEnabled = chkIsEnabled.Checked; studentSections.Remarks = txtSectionRemarks.Text; long section_id = StudentSectionsController.InsertUpdateStudentSections(studentSections); txtSectionName.Tag = section_id; if (section_id > 0) { SuccessMessage.SHowDialog("Record Entered Successfully "); StudentSectionDataGridView.DataSource = sections; } else { WarningMessage.SHowDialog("Error: Section Not Added"); } } catch (Exception ex) { MessageBox.Show(Convert.ToString(ex)); } }
/////////////////////////////////////////////////////////////////////////////////////////// //Private Methods/////////////////////////////////////////////////////////////////////////// //DB to Model// private void GenerateModelList() { StudentSectionsList.Clear(); foreach (DataRow drStudentSections in dsStudentSections.Tables[0].Rows) { StudentSections objStudentSections = new StudentSections(); objStudentSections.SectionID = Convert.ToInt64(drStudentSections["SectionID"]); objStudentSections.SectionName = Convert.ToString(drStudentSections["SectionName"]); objStudentSections.SessionID = Convert.ToInt64(drStudentSections["SessionID"]); objStudentSections.CreatedByID = Convert.ToInt64(drStudentSections["CreatedByID"]); objStudentSections.CreatedDateTime = Convert.ToDateTime(drStudentSections["CreatedDateTime"]); objStudentSections.LastUpdateDateTime = Convert.ToDateTime(drStudentSections["LastUpdateDateTime"]); objStudentSections.LastUpdateByID = Convert.ToInt64(drStudentSections["LastUpdateByID"]); objStudentSections.IsEnabled = Convert.ToBoolean(drStudentSections["IsEnabled"]); objStudentSections.Remarks = Convert.ToString(drStudentSections["Remarks"]); StudentSectionsList.Add(objStudentSections); } }
public static Int64 InsertUpdateStudentSections(StudentSections objIUStudentSections) { Int64 new_id = objIUStudentSections.InsertUpdateStudentSections(); return(new_id); }