public bool add_TemStudentData(studentBean st_Bean) { //Creating variable and objects bool status = false; SqlConnection sqlConn = null; SqlTransaction sqlTrn = null; dbConnection dbConn = null; studentDB stDB = null; try { //Inizing objects stDB = new studentDB(); dbConn = new dbConnection(); sqlConn = new SqlConnection(); //Inizing Sql Connection sqlConn = dbConn.getConnection(); //Connection Open sqlConn.Open(); //Transaction Beging sqlTrn = sqlConn.BeginTransaction(); //Assing the return valeu status = stDB.add_TemStudentData(st_Bean,sqlConn, sqlTrn); } catch (SqlException ex) { //throw exception to next layer throw ex; } finally { //disposing creating objects if (sqlConn != null) { sqlConn.Close(); } sqlTrn.Dispose(); } //returning tha value return status; }
public bool add_TemStudentData(studentBean st_Bean) { bool status = true; //Assigning the values to struct array stu_Array[count].studentId = st_Bean.Studentid; stu_Array[count].st_Name = st_Bean.St_name; stu_Array[count].st_DOB = st_Bean.Dob; stu_Array[count].st_GradePointAvg = st_Bean.St_gradepointavg; stu_Array[count].st_Active = st_Bean.St_active; /* stu_Array[count].studentId = 10; stu_Array[count].st_Name = "dfsgfg"; stu_Array[count].st_DOB = DateTime.Now; stu_Array[count].st_GradePointAvg = 2; stu_Array[count].st_Active = "yes";*/ //Array count increment by 1 count = count + 1; //return status return status; }
private void btnOK_Click(object sender, EventArgs e) { studentBean stBean = null; studentInfo stInfo = null; if (valid_control()) { try { stBean = new studentBean(); stInfo = new studentInfo(); stBean.Studentid = Int32.Parse(this.txtStudentId.Text.ToString().Trim()); stBean.St_name = this.txtStudentName.Text.Trim(); stBean.Dob = DateTime.Parse(this.dtpDOB.Text.Trim()); stBean.St_gradepointavg = Decimal.Parse(this.txtGradeAvg.Text.Trim()); if (this.cbTrue.Checked) { stBean.St_active = "Yes"; } else { stBean.St_active = "No"; } if (stInfo.add_TemStudentData(stBean)) { MessageBox.Show(systemMessage.TEMP_SAVE, systemMessage.MESSAGEBOXTITLE_SUCCESS, MessageBoxButtons.OK, MessageBoxIcon.Information); frmStuden_Details frm_Stdetail = new frmStuden_Details(); globleVeriables.STU_ID = globleVeriables.STU_ID - 1; frmMain frm_M = new frmMain(); frm_Stdetail.MdiParent = frm_M; frm_M.mainPanel.Controls.Clear(); frm_M.mainPanel.Controls.Add(frm_Stdetail); frm_M.mainPanel.Dock = DockStyle.Fill; frm_Stdetail.Show(); // Close form this.Dispose(); } else { MessageBox.Show(systemMessage.TEMP_INSERT, systemMessage.MESSAGEBOXTITLE, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { globleVeriables.STU_ID = globleVeriables.STU_ID - 1; if (ex.Message.Equals("Database Not Found!")) { MessageBox.Show(systemMessage.DATABASE_NOTFOUND, systemMessage.MESSAGEBOXTITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(systemMessage.TEMP_INSERT, systemMessage.MESSAGEBOXTITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); } } clear_Content(); setStudentId(); } }