public static string ChangeStatus(string strPaymentID) { try { using (KungFuEntities2 entities = new KungFuEntities2()) { int iPaymentID = int.Parse(strPaymentID); var query = (from c in entities.tblPayments where c.PAYMENT_ID == iPaymentID select c).Single(); if (query.PAYMENT_STATUS == true) { query.PAYMENT_STATUS = false; } else { query.PAYMENT_STATUS = true; } entities.SaveChanges(); } return("True"); } catch (Exception ex) { throw ex; } }
public static string ChangeStatus(string strAssignRankID) { try { using (KungFuEntities2 entities = new KungFuEntities2()) { int iAssignRankID = int.Parse(strAssignRankID); var query = (from c in entities.tblStudentProgresses where c.STU_PROG_ID == iAssignRankID select c).Single(); if (query.STU_PROG_STATUS == true) { query.STU_PROG_STATUS = false; } else { query.STU_PROG_STATUS = true; } entities.SaveChanges(); } return("True"); } catch (Exception ex) { throw ex; } }
public static string ChangeStatus(string strClassTypeID) { try { using (KungFuEntities2 entities = new KungFuEntities2()) { int iClassTypeID = int.Parse(strClassTypeID); var query = (from c in entities.tblClassLevels where c.CLASS_LEVEL_ID == iClassTypeID select c).Single(); if (query.CLASS_STATUS == true) { query.CLASS_STATUS = false; } else { query.CLASS_STATUS = true; } entities.SaveChanges(); } return("True"); } catch (Exception ex) { throw ex; } }
public void InsertBeltType() { try { using (KungFuEntities2 entities = new KungFuEntities2()) { int ihdnPKID = int.Parse(hdnPKId.Value); Int32 beltColorID = 0; if (ihdnPKID == 0) { beltColorID = (from obj in entities.tblRanks where obj.RANK_BELT_COLOR == txtBeltColor.Text select obj.RANK_ID).FirstOrDefault(); } else { beltColorID = (from obj in entities.tblRanks where obj.RANK_BELT_COLOR == txtBeltColor.Text && obj.RANK_ID != ihdnPKID select obj.RANK_ID).FirstOrDefault(); } if (beltColorID == 0) { var objRank = entities.tblRanks.Where(s => s.RANK_ID == ihdnPKID).OrderByDescending(s => s.RANK_ID).FirstOrDefault(); if (objRank == null) { objRank = new tblRank(); } objRank.RANK_BELT_COLOR = txtBeltColor.Text; objRank.RANK_REQUIREMENTS = txtRequirements.Text; objRank.RANK_CREATED_BY = entities.tblInstructors.AsEnumerable().FirstOrDefault().INSTRUCTOR_ID; objRank.RANK_CREATED_DATE = DateTime.Now; objRank.RANK_STATUS = chkIsApprove.Checked; if (chkIsDefault.Checked) { (from x in entities.tblRanks select x).ToList().ForEach(xx => xx.RANK_IS_DEFAULT = false); entities.SaveChanges(); } objRank.RANK_IS_DEFAULT = chkIsDefault.Checked; if (objRank.RANK_ID == 0) { entities.tblRanks.Add(objRank); } else { objRank.RANK_MODIFY_BY = entities.tblInstructors.Select(x => x.INSTRUCTOR_ID).FirstOrDefault(); objRank.RANK_MODIFIED_DATE = DateTime.Now; entities.Entry(objRank).State = System.Data.Entity.EntityState.Modified; } entities.SaveChanges(); objRank = null; if (hdnPKId.Value != "0") { Response.Redirect("RankTypeList.aspx"); } ResetControls(); divMessage.Visible = true; divErrorMsg.Visible = false; } else { divErrorMsg.Visible = true; divMessage.Visible = false; return; } } } catch (Exception ex) { } }
public void InsertClass() { try { using (KungFuEntities2 entities = new KungFuEntities2()) { var classTypeID = int.Parse(ddlClassType.SelectedValue); int ihdnPKID = int.Parse(hdnPKId.Value); Int32 ClassID = 0; if (ihdnPKID == 0) { ClassID = (from obj in entities.tblClasses where obj.CLASS_LEVEL_ID == classTypeID && obj.CLASS_DAY == txtDay.Text && obj.CLASS_TIME == txtTime.Text select obj.CLASS_ID).FirstOrDefault(); } else { ClassID = (from obj in entities.tblClasses where obj.CLASS_LEVEL_ID == classTypeID && obj.CLASS_DAY == txtDay.Text && obj.CLASS_TIME == txtTime.Text && obj.CLASS_ID != ihdnPKID select obj.CLASS_ID).FirstOrDefault(); } if (ClassID == 0) { var objClass = entities.tblClasses.Where(s => s.CLASS_ID == ihdnPKID).OrderByDescending(s => s.CLASS_ID).FirstOrDefault(); if (objClass == null) { objClass = new tblClass(); } objClass.CLASS_LEVEL_ID = Convert.ToInt32(ddlClassType.SelectedValue); objClass.CLASS_DAY = txtDay.Text; objClass.CLASS_TIME = txtTime.Text; objClass.CLASS_CREATED_BY = entities.tblInstructors.AsEnumerable().FirstOrDefault().INSTRUCTOR_ID; objClass.CLASS_CREATED_DATE = DateTime.Now; objClass.CLASS_STATUS = chkIsApprove.Checked; if (objClass.CLASS_ID == 0) { entities.tblClasses.Add(objClass); } else { objClass.CLASS_MODIFY_BY = entities.tblInstructors.Select(x => x.INSTRUCTOR_ID).FirstOrDefault(); objClass.CLASS_MODIFIED_DATE = DateTime.Now; entities.Entry(objClass).State = System.Data.Entity.EntityState.Modified; } entities.SaveChanges(); objClass = null; if (hdnPKId.Value != "0") { Response.Redirect("ClassList.aspx"); } ResetControls(); divMessage.Visible = true; divErrorMsg.Visible = false; } else { divErrorMsg.Visible = true; divMessage.Visible = false; return; } } } catch (Exception ex) { } }
public void InsertAttendance() { try { using (KungFuEntities2 entities = new KungFuEntities2()) { var studentID = (from obj in entities.tblStudents where obj.STU_NUM == txtStudentNumber.Text select obj.STU_ID).FirstOrDefault(); var classID = int.Parse(ddlClassType.SelectedValue); //DateTime dtFrom = Convert.ToDateTime(txtDate.Text); //var AttendanceID = (from obj in entities.tblAttendences // where obj.CLASS_ID == ddlClassType.SelectedIndex && obj.STU_ID == studentID && obj.ATT_DATE == dtFrom // select obj.ATT_ID).FirstOrDefault(); int ihdnPKID = int.Parse(hdnPKId.Value); Int32 AttendanceID = 0; if (ihdnPKID == 0) { AttendanceID = (from obj in entities.tblAttendences where obj.CLASS_ID == classID && obj.STU_ID == studentID select obj.ATT_ID).FirstOrDefault(); } else { AttendanceID = (from obj in entities.tblAttendences where obj.CLASS_ID == classID && obj.STU_ID == studentID && obj.ATT_ID != ihdnPKID select obj.ATT_ID).FirstOrDefault(); } if (studentID != 0 && AttendanceID == 0) { var objAttendence = entities.tblAttendences.Where(s => s.ATT_ID == ihdnPKID).OrderByDescending(s => s.ATT_ID).FirstOrDefault(); if (objAttendence == null) { objAttendence = new tblAttendence(); } objAttendence.STU_ID = Convert.ToInt32(studentID); objAttendence.ATT_DATE = DateTime.ParseExact(txtDate.Text, "MM/dd/yyyy", null); objAttendence.CLASS_ID = Convert.ToInt32(ddlClassType.SelectedValue); objAttendence.ATT_CREATED_BY = entities.tblInstructors.AsEnumerable().FirstOrDefault().INSTRUCTOR_ID; objAttendence.ATT_CREATED_DATE = DateTime.Now; objAttendence.STU_ID = Convert.ToInt32(studentID); objAttendence.ATT_STATUS = chkIsPresent.Checked; if (objAttendence.ATT_ID == 0) { entities.tblAttendences.Add(objAttendence); } else { objAttendence.ATT_MODIFY_BY = entities.tblInstructors.Select(x => x.INSTRUCTOR_ID).FirstOrDefault(); objAttendence.ATT_MODIFIED_DATE = DateTime.Now; entities.Entry(objAttendence).State = System.Data.Entity.EntityState.Modified; } entities.SaveChanges(); objAttendence = null; if (hdnPKId.Value != "0") { Response.Redirect("AttendanceList.aspx"); } ResetControls(); divMessage.Visible = true; divErrorMsg.Visible = false; } else { if (studentID == 0) { divErrorMsg.InnerHtml = ""; divErrorMsg.InnerText = "Student does not exist with this number."; } else { divErrorMsg.InnerHtml = ""; divErrorMsg.InnerText = "Attendance for this student with class time and date already exist."; } divErrorMsg.Visible = true; divMessage.Visible = false; return; } } } catch (Exception ex) { } }
public void InsertPayment() { try { using (KungFuEntities2 entities = new KungFuEntities2()) { var studentID = (from obj in entities.tblStudents where obj.STU_NUM == txtStudentNumber.Text select obj.STU_ID).FirstOrDefault(); //var query = entities.tblStudents.AsEnumerable().Where(s => s.STU_NUM.Contains(txtStudentNumber.Text)).Select(s => s.STU_ID).Distinct(); if (studentID != 0) { int ihdnPKID = int.Parse(hdnPKId.Value); var objPayment = entities.tblPayments.Where(s => s.PAYMENT_ID == ihdnPKID).OrderByDescending(s => s.PAYMENT_ID).FirstOrDefault(); if (objPayment == null) { objPayment = new tblPayment(); } objPayment.PAYMENT_AMOUNT = Convert.ToDecimal(txtAmount.Text); objPayment.PAYMENT_DATE = DateTime.ParseExact(txtDOP.Text, "MM/dd/yyyy", null); objPayment.PAYMENT_TYPE_ID = Convert.ToInt32(ddlPaymentType.SelectedValue); objPayment.PAYMENT_CREATED_BY = entities.tblInstructors.AsEnumerable().FirstOrDefault().INSTRUCTOR_ID; objPayment.PAYMENT_CREATED_DATE = DateTime.Now; objPayment.STU_ID = Convert.ToInt32(studentID); objPayment.PAYMENT_STATUS = chkIsApprove.Checked; if (objPayment.PAYMENT_ID == 0) { entities.tblPayments.Add(objPayment); } else { objPayment.PAYMENT_MODIFY_BY = entities.tblInstructors.Select(x => x.INSTRUCTOR_ID).FirstOrDefault(); objPayment.PAYMENT_MODIFIED_DATE = DateTime.Now; entities.Entry(objPayment).State = System.Data.Entity.EntityState.Modified; } entities.SaveChanges(); objPayment = null; if (hdnPKId.Value != "0") { Response.Redirect("PaymentList.aspx"); } ResetControls(); divMessage.Visible = true; divErrorMsg.Visible = false; } else { divErrorMsg.Visible = true; divMessage.Visible = false; return; } } } catch (Exception ex) { } }
public void InsertStudent() { try { using (KungFuEntities2 entities = new KungFuEntities2()) { //tblStudent obj = entities.tblStudents.AsEnumerable().LastOrDefault<tblStudent>(); int ihdnPKID = int.Parse(hdnPKId.Value); tblStudentProgress objStudentProgress = new tblStudentProgress(); var objStudent = entities.tblStudents.Where(s => s.STU_ID == ihdnPKID).OrderByDescending(s => s.STU_ID).FirstOrDefault(); if (objStudent == null) { objStudent = new tblStudent(); } objStudent.STU_FNAME = txtFName.Text; objStudent.STU_MNAME = txtMName.Text; objStudent.STU_LNAME = txtLName.Text; objStudent.STU_MNUM = txtMobileNumber.Text; objStudent.STU_EMAIL = txtEmail.Text; objStudent.STU_CREATED_BY = entities.tblInstructors.AsEnumerable().FirstOrDefault().INSTRUCTOR_ID; objStudent.STU_CREATED_DATE = DateTime.Now; objStudent.STU_DOB = DateTime.ParseExact(txtDOB.Text, "MM/dd/yyyy", null); objStudent.STU_DOJ = DateTime.ParseExact(txtDOJ.Text, "MM/dd/yyyy", null); if (rbtnMale.Checked) { objStudent.STU_GENDER = true; } else { objStudent.STU_GENDER = false; } if (entities.tblStudents.AsEnumerable().OrderByDescending(s => s.STU_ID).FirstOrDefault() == null) { objStudent.STU_NUM = "104911000"; } else { if (Convert.ToInt32(hdnPKId.Value) == 0) { objStudent.STU_NUM = Convert.ToString(Convert.ToInt32(entities.tblStudents.AsEnumerable().OrderByDescending(s => s.STU_ID).FirstOrDefault().STU_NUM) + 1); } } objStudent.STU_STATUS = chkIsApprove.Checked; objStudent.STU_STREET = txtStreet.Text; objStudent.STU_CITY = txtCity.Text; objStudent.STU_STATE = txtState.Text; objStudent.STU_ZIP = txtZIP.Text; if (objStudent.STU_ID == 0) { entities.tblStudents.Add(objStudent); } else { objStudent.STU_MODIFY_BY = entities.tblInstructors.Select(x => x.INSTRUCTOR_ID).FirstOrDefault(); objStudent.STU_MODIFIED_DATE = DateTime.Now; entities.Entry(objStudent).State = System.Data.Entity.EntityState.Modified; } entities.SaveChanges(); if (hdnPKId.Value == "0") { objStudentProgress.RANK_ID = entities.tblRanks.AsEnumerable().Where(r => r.RANK_IS_DEFAULT == true).FirstOrDefault().RANK_ID; objStudentProgress.STU_ID = objStudent.STU_ID; objStudentProgress.STU_PROG_CREATED_BY = entities.tblInstructors.AsEnumerable().FirstOrDefault().INSTRUCTOR_ID; objStudentProgress.STU_PROG_CREATED_DATE = DateTime.Now; objStudentProgress.STU_PROG_RANK_DATE = DateTime.Now; objStudentProgress.STU_PROG_STATUS = true; entities.tblStudentProgresses.Add(objStudentProgress); entities.SaveChanges(); var PaymentTypeID = (from c in entities.tblPaymentTypes where c.PAYMENT_TYPE_STATUS == true orderby c.PAYMENT_TYPE_ID descending select new { c.PAYMENT_TYPE_ID, c.PAYMENT_TYPE_AMOUNT }).ToList(); foreach (var item in PaymentTypeID) { tblPayment objPayment = new tblPayment(); objPayment.PAYMENT_AMOUNT = item.PAYMENT_TYPE_AMOUNT; objPayment.PAYMENT_DATE = DateTime.Now; objPayment.PAYMENT_TYPE_ID = item.PAYMENT_TYPE_ID; objPayment.PAYMENT_CREATED_BY = entities.tblInstructors.AsEnumerable().FirstOrDefault().INSTRUCTOR_ID; objPayment.PAYMENT_CREATED_DATE = DateTime.Now; objPayment.STU_ID = objStudent.STU_ID; objPayment.PAYMENT_STATUS = false; entities.tblPayments.Add(objPayment); entities.SaveChanges(); objPayment = null; } } else { Response.Redirect("StudentList.aspx"); } hdnPKId.Value = objStudent.STU_ID.ToString(); objStudent = null; objStudentProgress = null; ResetControls(); divMessage.Visible = true; } } catch (Exception ex) { } }
public void InsertParent() { try { using (KungFuEntities2 entities = new KungFuEntities2()) { var studentID = (from obj in entities.tblStudents where obj.STU_NUM == txtStudentNumber.Text select obj.STU_ID).FirstOrDefault(); //var query = entities.tblStudents.AsEnumerable().Where(s => s.STU_NUM.Contains(txtStudentNumber.Text)).Select(s => s.STU_ID).Distinct(); if (studentID != 0) { int ihdnPKID = int.Parse(hdnPKId.Value); var objParent = entities.tblParents.Where(s => s.PARENT_ID == ihdnPKID).OrderByDescending(s => s.PARENT_ID).FirstOrDefault(); if (objParent == null) { objParent = new tblParent(); } objParent.PARENT_FNAME = txtFName.Text; objParent.PARENT_MNAME = txtMName.Text; objParent.PARENT_LNAME = txtLName.Text; objParent.PARENT_MNUM = txtMobileNumber.Text; objParent.PARENT_EMAIL = txtEmail.Text; objParent.PARENT_CREATED_BY = entities.tblInstructors.AsEnumerable().FirstOrDefault().INSTRUCTOR_ID; objParent.PARENT_CREATED_DATE = DateTime.Now; objParent.STU_ID = Convert.ToInt32(studentID); if (rbtnMale.Checked) { objParent.PARENT_GENDER = true; } else { objParent.PARENT_GENDER = false; } objParent.PARENT_IS_STUDENT = chkIsStudent.Checked; objParent.PARENT_STATUS = chkIsApprove.Checked; if (objParent.PARENT_ID == 0) { entities.tblParents.Add(objParent); } else { objParent.PARENT_MODIFY_BY = entities.tblInstructors.Select(x => x.INSTRUCTOR_ID).FirstOrDefault(); objParent.PARENT_MODIFIED_DATE = DateTime.Now; entities.Entry(objParent).State = System.Data.Entity.EntityState.Modified; } entities.SaveChanges(); objParent = null; if (hdnPKId.Value != "0") { Response.Redirect("ParentList.aspx"); } ResetControls(); divMessage.Visible = true; divErrorMsg.Visible = false; } else { divErrorMsg.Visible = true; divMessage.Visible = false; return; } } } catch (Exception ex) { } }
public void InsertPaymentType() { try { using (KungFuEntities2 entities = new KungFuEntities2()) { int ihdnPKID = int.Parse(hdnPKId.Value); Int32 PaymentTypeID = 0; if (ihdnPKID == 0) { PaymentTypeID = (from obj in entities.tblPaymentTypes where obj.PAYMENT_TYPE == txtPaymentType.Text select obj.PAYMENT_TYPE_ID).FirstOrDefault(); } else { PaymentTypeID = (from obj in entities.tblPaymentTypes where (obj.PAYMENT_TYPE == txtPaymentType.Text && obj.PAYMENT_TYPE_ID != ihdnPKID) select obj.PAYMENT_TYPE_ID).FirstOrDefault(); } if (PaymentTypeID == 0) { var objPaymentType = entities.tblPaymentTypes.Where(s => s.PAYMENT_TYPE_ID == ihdnPKID).OrderByDescending(s => s.PAYMENT_TYPE_ID).FirstOrDefault(); if (objPaymentType == null) { objPaymentType = new tblPaymentType(); } objPaymentType.PAYMENT_TYPE = txtPaymentType.Text; objPaymentType.PAYMENT_TYPE_CREATED_BY = entities.tblInstructors.AsEnumerable().FirstOrDefault().INSTRUCTOR_ID; objPaymentType.PAYMENT_TYPE_CREATED_DATE = DateTime.Now; objPaymentType.PAYMENT_TYPE_STATUS = chkIsApprove.Checked; objPaymentType.PAYMENT_TYPE_AMOUNT = Convert.ToDecimal(txtAmount.Text); if (objPaymentType.PAYMENT_TYPE_ID == 0) { entities.tblPaymentTypes.Add(objPaymentType); } else { objPaymentType.PAYMENT_TYPE_MODIFY_BY = entities.tblInstructors.Select(x => x.INSTRUCTOR_ID).FirstOrDefault(); objPaymentType.PAYMENT_TYPE_MODIFIED_DATE = DateTime.Now; entities.Entry(objPaymentType).State = System.Data.Entity.EntityState.Modified; } entities.SaveChanges(); objPaymentType = null; if (hdnPKId.Value != "0") { Response.Redirect("PaymentTypeList.aspx"); } ResetControls(); divMessage.Visible = true; divErrorMsg.Visible = false; } else { divErrorMsg.Visible = true; divMessage.Visible = false; return; } } } catch (Exception ex) { } }