public static void AddStudentDiscount(PromoCode promo, int StudentID, double ClassPrice, double TotalPrice) { Context db = new Context(); StudentPayment oDiscount = new StudentPayment(); oDiscount.StudentID = StudentID; oDiscount.type = "Discount"; oDiscount.Detail = promo.Code; oDiscount.PaymentDate = DateTime.Now; if (promo.Type == "DollarsOff") { oDiscount.Amount = promo.DiscountValue; } else { double percent = promo.DiscountValue / 100; if (promo.IsDiscountForShippingAndAdon) { oDiscount.Amount = TotalPrice * percent; } else { oDiscount.Amount = ClassPrice * percent; } } db.StudentPayment.Add(oDiscount); db.SaveChanges(); }
public IActionResult Students(Int64 Id, StudentPayment studentPayment) { var data = _context.StudentPayment.ToList(); var model = new List <StudentPayment>(); foreach (var i in data) { if (Id != i.Id) { continue; } var s = new StudentPayment(); s.Id = i.Id; s.Date = i.Date; s.AdmissionFee = i.AdmissionFee; s.MonthName = i.MonthName; s.TuitionFee = i.TuitionFee; s.ReAdmission = i.ReAdmission; s.YearlyCharge = i.YearlyCharge; s.Examination = i.Examination; s.Lab = i.Lab; s.IdCard = i.IdCard; s.Fine = i.Fine; s.Other = i.Other; s.AdvancePayment = i.AdvancePayment; model.Add(s); } return(View(model)); }
public async Task <IActionResult> Edit(int id, [Bind("SpId,StudentId,Date,FormFee,AdmissionFee,ReAdmissionFee,TcCharge,SeasonCharge,CertificateFee,TestimonialFee,WhichMonthFee,MonthFeeAmount,Ct1Fee,Ct2Fee,HalfYearlyFee,FinalYearlyFee,WaterElectricityFee,Tex,DevlopmentFee,BuildingDevFee,LabFee,LibraryFee,ComputerFee,RegistrationFee,CautionMoney,Fine,ReportCardFee,AdmitCardFee,IdCardFee,FormFillUpEFf,FormFillUpJsc,FormFillUpSsc,FormFillUpHsc,ItFee,ScienceDevelopmentFee,CareFee,OtherFeeName,OtherFeeAmount")] StudentPayment studentPayment) { if (id != studentPayment.SpId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(studentPayment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentPaymentExists(studentPayment.SpId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["StudentId"] = new SelectList(_context.StudentInfo, "StudentId", "StudentName", studentPayment.StudentId); return(View(studentPayment)); }
public static void DeleteStudentDiscount(StudentPayment discount) { Context db = new Context(); db.StudentPayment.Attach(discount); var entity = db.Entry(discount); entity.State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); }
private void Id_comboBox_SelectedIndexChanged(object sender, EventArgs e) { try{ StudentPayment spay = new StudentPayment(); individual_dataGridView.DataSource = spay.getAllReceiptOfAStudent(Id_comboBox.Text); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void Id_comboBox_SelectedIndexChanged(object sender, EventArgs e) { try{ StudentPayment spay = new StudentPayment(); individual_dataGridView.DataSource = spay.getAllReceiptOfAStudent(Id_comboBox.Text); } catch(Exception ex){ MessageBox.Show(ex.ToString()); } }
public IActionResult StudentPaymentAdd(StudentPayment studentPayment) { Int64 Id = studentPayment.Id; _context.StudentPayment.Add(studentPayment); _context.SaveChanges(); return(RedirectToAction("Students", new{ id = Id })); }
public IActionResult StudentPayment(StudentPayment StudentPayment) { //if (ModelState.IsValid) // { PaymentDetails BD = new PaymentDetails { PaymentDate = StudentPayment.PaymentDate, Createdby = Convert.ToInt32(HttpContext.Session.GetString("UserID")), CreatedDate = DateTime.Now, PaymentApproval = "P" }; var result = _IStudentPayment.BookEvent(BD); StudentPayment BV = new StudentPayment { FeeID = StudentPayment.FeeID, PaymentDate = StudentPayment.PaymentDate, CardNum = StudentPayment.CardNum, Pin = StudentPayment.Pin, Amount = StudentPayment.Amount, Createdby = Convert.ToInt32(HttpContext.Session.GetString("UserID")), CreatedDate = DateTime.Now, PaymentDetailID = result }; var VenueID = _IStudentPayment.FeePayment(BV); HttpContext.Session.SetInt32("PaymentDetailID", result); if (result > 0) { //SetSlider(); //ModelState.Clear(); ViewData["PaymentMessage"] = "Amount Paid Successfully"; //return View("Payment"); return(View(StudentPayment)); } else { //SetSlider(); //return View("Payment", Payment); return(View(StudentPayment)); } //} //else //{ //SetSlider(); // return View("Payment", Payment); //} }
public int?FeePayment(StudentPayment objBV) { try { _context.StudentPayment.Add(objBV); _context.SaveChanges(); return(objBV.PayID); } catch (Exception) { throw; } }
private StudentPayment PopulateStudentByRow(DataRow r) { StudentPayment student = new StudentPayment(); student.FirstName = r["FirstName"].ToString(); student.LastName = r["LastName"].ToString(); student.BalanceDue = (decimal)r["BalanceDue"]; student.Program = r["Program"].ToString(); student.StartDate = (DateTime)r["StartDate"]; student.EndDate = (DateTime)r["EndDate"]; student.Status = (StudentStatus)Convert.ToInt32(r["Status"]); return(student); }
public IEnumerable <StudentPayment> getpayment([FromBody] int id) { List <int> ids = new List <int>(); List <string> tnames = new List <string>(); List <string> cnames = new List <string>(); List <string> phones = new List <string>(); List <string> fees = new List <string>(); List <string> pmss = new List <string>(); StudentPayment sp = new StudentPayment(); string connectionstring = configuration.GetConnectionString("DefaultConnectionString"); SqlConnection connection = new SqlConnection(connectionstring); connection.Open(); string query = @"select Teacher.FirstName,PurchaseCourse.CourseName,Teacher.Phone,PurchaseCourse.CourseFee,PurchaseCourse.PaymentMethod from Teacher inner join PurchaseCourse on Teacher.TeacherID= PurchaseCourse.TeacherId where PurchaseCourse.TeacherId=@TeacherId"; SqlCommand cmd = new SqlCommand(query, connection); cmd.Parameters.Add(new SqlParameter("@TeacherId", id)); SqlDataReader reader = cmd.ExecuteReader(); int m = 0; //sudo while (reader.Read()) { m++; ids.Add(m); tnames.Add(reader["FirstName"].ToString()); cnames.Add(reader["CourseName"].ToString()); phones.Add(reader["Phone"].ToString()); fees.Add(reader["CourseFee"].ToString()); pmss.Add(reader["PaymentMethod"].ToString()); } connection.Close(); reader.Close(); return(Enumerable.Range(1, m).Select(index => new StudentPayment { PaymentId = ids.ElementAt(index - 1), TeacherName = tnames.ElementAt(index - 1), CourseName = cnames.ElementAt(index - 1), Phone = phones.ElementAt(index - 1), CourseFee = fees.ElementAt(index - 1), PaymentMethod = pmss.ElementAt(index - 1) }).ToArray()); }
public IActionResult ReceivePaymentNo(ReceivePaymentNoViewModel objectPayNo) { if (ModelState.IsValid) { if (objectPayNo.StudentNo != null) { string pNo = StudentPayment.GetPayment(objectPayNo.StudentNo); ViewData["pNo"] = pNo; return(View("Index", objectPayNo)); } return(RedirectToAction(nameof(Index))); } return(View(objectPayNo)); }
private void save_button_Click(object sender, EventArgs e) { // try // { StudentPayment sp = new StudentPayment(); string id = Id_comboBox.Text; string recept = recept_textBox.Text; string due = amount_textBox.Text; string remark = remarks_textBox.Text; double dueamnt = Convert.ToDouble(sp.getDueAmountOfA_Student(id)); dueamnt = dueamnt - Convert.ToDouble(due); sp.UpdateDuePayment(id, dueamnt.ToString(), remark); sp.InsertRecipt(id, date, recept); MessageBox.Show("Saved Successfully"); //} // catch (Exception ex) { // MessageBox.Show(ex.ToString()); // } }
public static int InsertStudentPayment(StudentPayment studentPayment) { try { using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { //todo check if not appear scolarship in that month int insert = studentPayment.Id = StudentDataManager.InsertStudentPayment(studentPayment); scope.Complete(); return(insert); } } catch (Exception ex) { _logger.Debug($"Failed to insert payment of student.", ex); throw; } }
public int InsertStudentPayment(StudentPayment studentPayment) { IList <DbParameter> parameters = new List <DbParameter>() { new MySqlParameter("@student_id", studentPayment.Student.Id), new MySqlParameter("@month", studentPayment.Month), new MySqlParameter("@year", studentPayment.Year), new MySqlParameter("@payment_sum", studentPayment.PaymentSum), new MySqlParameter("@attendance_sum", studentPayment.AttendanceSum), new MySqlParameter("@exams_sum", studentPayment.ExamsSum), new MySqlParameter("@state_budget_sum", studentPayment.StateBudgetSum), new MySqlParameter("@health_support_sum", studentPayment.HealthSupportSum), new MySqlParameter("@dental_health_support_sum", studentPayment.DentalHealthSupportSum), new MySqlParameter("@financial_support_sum", studentPayment.FinancialSupportSum), new MySqlParameter("@loans_given_sum", studentPayment.LoansGivenSum), new MySqlParameter("@loans_return_sum", studentPayment.LoansReturnSum), }; return(_dbContext.Insert(Tables.StudentPayment.InsertTable, true, parameters)); }
public HttpResponseMessage InsertStudentPayment([FromBody] StudentPaymentDto studentPaymentDto) { try { StudentPayment studentPayment = Converters.Convert(studentPaymentDto); if (!ValidateModel.IsValid(new List <object>() { studentPayment })) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ValidateModel.ModelsResults)); } StudentManager.InsertStudentPayment(studentPayment); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"Failed to insert the payment of student, {ex.Message}")); } }
public IActionResult EditStudentPayment(StudentPayment sp) { if (ModelState.IsValid) { StudentPayment t = new StudentPayment(); t.PaymentId = sp.PaymentId; t.StudentId = sp.StudentId; t.Month = sp.Month; t.Year = sp.Year; t.TuitionFee = sp.TuitionFee; t.ExtraFeeCategory = sp.ExtraFeeCategory; t.ExtraFee = sp.ExtraFee; t.PaymentDate = sp.PaymentDate; t.TotalAmount = sp.TotalAmount; t.SPayAmount = t.TuitionFee + t.ExtraFee; t.PaymentStatus = t.TotalAmount - t.SPayAmount; db.StudentPayment.Update(t); db.SaveChanges(); } return(RedirectToAction("ViewStudentPaymentList")); }
public IActionResult StudentPaymentEdit(StudentPayment i) { var s = _context.StudentPayment.Where(u => u.Id == i.Id && u.No == i.No).FirstOrDefault(); s.Id = i.Id; s.Date = i.Date; s.AdmissionFee = i.AdmissionFee; s.MonthName = i.MonthName; s.TuitionFee = i.TuitionFee; s.ReAdmission = i.ReAdmission; s.YearlyCharge = i.YearlyCharge; s.Examination = i.Examination; s.Lab = i.Lab; s.IdCard = i.IdCard; s.Fine = i.Fine; s.Other = i.Other; s.AdvancePayment = i.AdvancePayment; // _context.StudentPayment.Update(s); _context.SaveChanges(); return(RedirectToAction("Students", new { id = i.Id })); }
public ActionResult OnAuthorizedPayment(string data, string paymentID, string payerID) { try { Context db = new Context(); JavaScriptSerializer jss = new JavaScriptSerializer(); Student model = jss.Deserialize <Student>(data); var payment = PaypalService.ExecutePayment(paymentID, payerID); if (payment.state == "approved") { int StudentID = SaveRegistration(model); StudentPayment pay = new StudentPayment(); pay.PaymentID = 0; pay.PaymentDate = DateTime.Now.Date; pay.TransactionID = payment.id; pay.type = "Paypal"; pay.StudentID = StudentID; pay.Detail = ""; pay.Amount = (model.TotalClassPrice - model.DiscountPrice); db.StudentPayment.Add(pay); db.SaveChanges(); Utilities.AssignKeycodesToCourseAddons(model.SelectedOptions, model.FirstName, model.LastName, model.Email, model.ClassID, StudentID); Utilities.SendClassRegistrationConfirmationToStudent(model); return(RedirectToAction("RegistrationConfirmed", new { id = StudentID })); } else { FlashMessage.Warning("Paypal Transaction Fail"); return(RedirectToAction("RegistrationError")); } } catch (Exception ex) { FlashMessage.Warning(ex.Message); return(RedirectToAction("RegistrationError")); } }
private static StudentPaymentDto ConvertToDto(StudentPayment studentPayment) { if (studentPayment == null) { return(null); } return(new StudentPaymentDto() { AttendanceSum = studentPayment.AttendanceSum, DentalHealthSupportSum = studentPayment.DentalHealthSupportSum, ExamsSum = studentPayment.ExamsSum, FinancialSupportSum = studentPayment.FinancialSupportSum, HealthSupportSum = studentPayment.HealthSupportSum, LoansGivenSum = studentPayment.LoansGivenSum, LoansReturnSum = studentPayment.LoansReturnSum, Month = studentPayment.Month, Year = studentPayment.Year, PaymentSum = studentPayment.PaymentSum, StateBudgetSum = studentPayment.StateBudgetSum, Student = studentPayment.Student }); }
private void AddStudent_button_Click(object sender, EventArgs e) { StudentProfile sp = new StudentProfile(); StudentPayment pay = new StudentPayment(); string id = Id_textBox.Text; string session = Session_textBox.Text; string batch = Batch_textBox.Text; string name = Name_textBox.Text; Byte [] image = buffer; string fname = FatherName_textBox.Text; string mname = MotherName_textBox.Text; string foccupation = FatherOccupation_textBox.Text; string paddress = PresentAddress_textBox.Text; string stdmbl = stdmbl_textBox.Text; string grdmbl = Guardianmbl_textBox.Text; string blood = BloodGroup_comboBox.SelectedItem.ToString(); string payment = Payment_textBox.Text; string infomedia = InfoMedia_textBox.Text; string schoolname = school_textBox.Text; string sscgpa = SSC_Gpa_textBox.Text; string sscpassyear = SSCPassingYear_comboBox.SelectedItem.ToString(); string collegename = College_textBox.Text; string hscgpa = hscgpa_textBox.Text; string hscpassyear = HSCPassingYear_comboBox.SelectedItem.ToString(); try { sp.AddStudent(id, session, batch, name, image, fname, mname, foccupation, paddress, stdmbl, grdmbl, blood, payment, infomedia); sp.AddEducationalBackground(id, "SSC", schoolname, sscgpa, sscpassyear); sp.AddEducationalBackground(id, "HSC", collegename, hscgpa, hscpassyear); pay.insert_DuePayment(id, payment, "Not Paid"); MessageBox.Show("Information Saved Successfully"); } catch (Exception ex) { MessageBox.Show(ex.ToString() + ex.StackTrace); } }
public async Task <IActionResult> OnPostAsync() { int id = (int)HttpContext.Session.GetInt32(SD.UserSessionId); PayBillResponse response = await stripeHelper.PayBill(billingSubmission); if (response.responseMessage.StatusCode != HttpStatusCode.OK) { return(RedirectToPage("./Billing/PaymentFailed")); } else { StudentPayment studentPayment = new StudentPayment(); studentPayment.StudentId = id; studentPayment.StripeTokenId = response.studentPayments.StripeTokenId; studentPayment.Payment = response.studentPayments.Payment; studentPayment.CreatedOn = DateTime.UtcNow; await _context.StudentPayments.AddAsync(studentPayment); await _context.SaveChangesAsync(); return(RedirectToPage("./Billing/PaymentSuccessful")); } }
private void AddStudent_button_Click(object sender, EventArgs e) { StudentProfile sp = new StudentProfile(); StudentPayment pay = new StudentPayment(); string id = Id_textBox.Text; string session = Session_textBox.Text; string batch = Batch_textBox.Text; string name = Name_textBox.Text; Byte [] image = buffer; string fname = FatherName_textBox.Text; string mname = MotherName_textBox.Text; string foccupation = FatherOccupation_textBox.Text; string paddress = PresentAddress_textBox.Text; string stdmbl = stdmbl_textBox.Text; string grdmbl = Guardianmbl_textBox.Text; string blood=BloodGroup_comboBox.SelectedItem.ToString(); string payment = Payment_textBox.Text; string infomedia = InfoMedia_textBox.Text; string schoolname = school_textBox.Text; string sscgpa = SSC_Gpa_textBox.Text; string sscpassyear = SSCPassingYear_comboBox.SelectedItem.ToString(); string collegename = College_textBox.Text; string hscgpa = hscgpa_textBox.Text; string hscpassyear = HSCPassingYear_comboBox.SelectedItem.ToString(); try { sp.AddStudent(id,session,batch,name,image,fname,mname,foccupation,paddress,stdmbl,grdmbl,blood,payment,infomedia); sp.AddEducationalBackground(id, "SSC", schoolname, sscgpa, sscpassyear); sp.AddEducationalBackground(id, "HSC", collegename, hscgpa, hscpassyear); pay.insert_DuePayment(id, payment, "Not Paid"); MessageBox.Show("Information Saved Successfully"); } catch (Exception ex) { MessageBox.Show(ex.ToString()+ex.StackTrace); } }
public IActionResult StudentPayment(StudentPayment sp) { if (ModelState.IsValid) { StudentPayment t = new StudentPayment(); t.PaymentId = sp.PaymentId; t.StudentId = sp.StudentId; t.Month = sp.Month; t.Year = sp.Year; t.TuitionFee = sp.TuitionFee; t.ExtraFeeCategory = sp.ExtraFeeCategory; t.ExtraFee = sp.ExtraFee; t.PaymentDate = sp.PaymentDate; t.TotalAmount = sp.TotalAmount; t.SPayAmount = t.TuitionFee + t.ExtraFee; t.PaymentStatus = t.TotalAmount - t.SPayAmount; db.StudentPayment.Add(t); db.SaveChanges(); ViewBag.Success = "Student Payment Added Successfully."; ModelState.Clear(); } return(View()); //return Redirect("ViewStudentPaymentList"); }
public void SaveAccountInformation(StudentPayment aStudentPayment, List <StudentPayment> studentPaymentList) { aStudentAccountsGatewayObj.SaveAccountInformation(aStudentPayment, studentPaymentList); }
public IActionResult StudentPaymentAdd(Int64 Id, StudentPayment studentPayment) { studentPayment.Id = Id; return(View()); }
public async Task <PayBillResponse> PayBill(BillingSubmission billingSubmission) { HttpStatusCode statusCode = new HttpStatusCode(); PayBillResponse payBillResponse = new PayBillResponse(); try { if (!PayBillRequestValid(billingSubmission)) { statusCode = HttpStatusCode.BadRequest; } else { var cardValues = new Dictionary <string, string> { { "card[number]", billingSubmission.CreditCardNum }, { "card[exp_month]", billingSubmission.ExpMonth }, { "card[exp_year]", billingSubmission.ExpYear }, { "card[cvc]", billingSubmission.SecurityCode } }; var formUrlEncodedContent = new FormUrlEncodedContent(cardValues); //Post request to Stripe var response = await httpClient.PostAsync(BaseURL + CreateURL, formUrlEncodedContent); //Parse the json var responsejson = await response.Content.ReadAsStringAsync(); //Parse the token id string token = JObject.Parse(responsejson).SelectToken("id").ToString(); var chargeValues = new Dictionary <string, string> { { "amount", billingSubmission.Amount.ToString() }, { "currency", "usd" }, { "description", "Test Charge Through Learning Management System" }, { "source", token } }; var formUrlEncodedContent2 = new FormUrlEncodedContent(chargeValues); var response2 = await httpClient.PostAsync(BaseURL + ChargeURL, formUrlEncodedContent2); var responsejson2 = await response.Content.ReadAsStringAsync(); if (response2.StatusCode == HttpStatusCode.OK) { StudentPayment payment = new StudentPayment(); payment.StripeTokenId = JObject.Parse(responsejson2).SelectToken("id").ToString(); payment.Payment = billingSubmission.Amount; payment.CreatedOn = DateTime.UtcNow; payBillResponse.studentPayments = payment; payBillResponse.responseMessage = response2; } } } catch (Exception e) { payBillResponse = new PayBillResponse(); } return(payBillResponse); }
private int SaveRegistration(Student model) { Context db = new Context(); string subdomain = Request.Url.Host.Split(new char[] { '.' })[0]; int companyid = db.EnrolSetting.Where(x => x.SiteName == subdomain).Select(x => x.CompanyID).FirstOrDefault(); model.CompanyID = companyid; if (model.QuestionID != null) { model.QuestionIDs = String.Join(",", model.QuestionID); } if (model.Answer != null) { string answers = ""; for (int i = 0; i < model.Answer.Length; i++) { if (i + 1 == model.Answer.Length) { answers = answers + model.Answer[i]; } else { answers = answers + model.Answer[i] + Environment.NewLine; } } model.Answers = answers; } if (model.KeycodeBankID > 0) { Keycode keycode = Utilities.RegisterKeycode(Convert.ToInt32(model.KeycodeBankID), model.FirstName, model.LastName, model.Email, model.ClassID); if (keycode != null && keycode.KeycodeID > 0) { model.KeycodeID = keycode.KeycodeID; model.Keycode = keycode.Key; } } if (model.IsAcceptedPromoCode == false) { model.PromoCode = ""; } model.RegisterionDate = DateTime.Now; model.CompanyID = companyid; model.ReceiptCode = DateTime.Now.ToString("hhmmssMMyydd"); db.Configuration.ValidateOnSaveEnabled = false; db.Student.Add(model); int rowsAffected = db.SaveChanges(); int studentid = model.StudentID; if (model.DiscountPrice > 0) { StudentPayment oDiscount = new StudentPayment(); oDiscount.StudentID = studentid; oDiscount.type = "Discount"; oDiscount.Detail = model.PromoCode; oDiscount.PaymentDate = DateTime.Now; oDiscount.Amount = model.DiscountPrice; db.StudentPayment.Add(oDiscount); db.SaveChanges(); } return(studentid); }
private void session_comboBox_SelectedIndexChanged(object sender, EventArgs e) { StudentPayment spay = new StudentPayment(); due_dataGridView.DataSource = spay.getDueAmountOfStudents(session_comboBox.Text); }
public ActionResult CompleteRegistration(Student model) { Context db = new Context(); //JavaScriptSerializer jss = new JavaScriptSerializer(); //Student model = jss.Deserialize<Student>(st); string subdomain = Request.Url.Host.Split(new char[] { '.' })[0]; EnrollSetting seting = db.EnrolSetting.Where(x => x.SiteName == subdomain).FirstOrDefault(); try { if (model.PaymentType == 2) { var mycharge = new StripeChargeCreateOptions(); mycharge.Amount = (int)((model.TotalClassPrice - model.DiscountPrice) * 100); int paymentAmount = (int)((model.TotalClassPrice - model.DiscountPrice) * 100); mycharge.Currency = "USD"; mycharge.SourceCard = new SourceCard() { Number = model.CardNo, ExpirationYear = Convert.ToInt32(model.ExpirationYear), ExpirationMonth = Convert.ToInt32(model.ExpirationMonth), AddressCountry = "US", AddressLine1 = model.MailingAddress1, AddressLine2 = model.MailingAddress2, AddressCity = model.MailingCity, AddressState = model.MailingState, AddressZip = model.MailingZip, Name = model.LastName + " " + model.FirstName + " (" + model.Email + ")", Cvc = model.SecurityCode }; mycharge.Description = "Payment received from student registration"; mycharge.Capture = true; //mycharge.CustomerId = current.Id; string key = seting.StripeLiveSecretKey; //"sk_test_2LVKznWm1WA4kvWngmGaPdLx"; var chargeservice = new StripeChargeService(key); StripeCharge currentcharge = chargeservice.Create(mycharge); //StripeCustomer current = GetCustomer(); if (currentcharge.Status == "succeeded" && currentcharge.Paid == true) { int StudentID = SaveRegistration(model); StudentPayment payment = new StudentPayment(); payment.PaymentID = 0; payment.PaymentDate = DateTime.Now; payment.TransactionID = currentcharge.Id; payment.type = "Credit Card"; payment.StudentID = StudentID; payment.Detail = ""; payment.Amount = (model.TotalClassPrice - model.DiscountPrice); db.StudentPayment.Add(payment); db.SaveChanges(); Utilities.AssignKeycodesToCourseAddons(model.SelectedOptions, model.FirstName, model.LastName, model.Email, model.ClassID, StudentID); Utilities.SendClassRegistrationConfirmationToStudent(model); return(RedirectToAction("RegistrationConfirmed", new { id = StudentID })); } else { FlashMessage.Warning("Credit Card Transaction Fail"); return(RedirectToAction("RegistrationError")); } } else { int StudentID = SaveRegistration(model); //SendRegistrationConfirmationToStudent(model); return(RedirectToAction("RegistrationConfirmed", new { id = StudentID })); } } catch (Exception ex) { FlashMessage.Warning(ex.Message); return(RedirectToAction("RegistrationError")); } }
private void mbtnPayAdd_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(txtChanges.Text)) { if (double.Parse(txtChanges.Text) < 0) { MessageBox.Show("Invalid transaction"); } else { if (cmbPaymentType.Text == "Second Issue of Certificate") { StudentPayment sp = new StudentPayment(); sp.StudentID = int.Parse(txtSTID.Text); sp.Amount = decimal.Parse(txtAmount.Text); sp.PaymentID = int.Parse(cmbPaymentType.SelectedValue.ToString()); sp.Date = DateTime.Now; db.StudentPayments.InsertOnSubmit(sp); db.SubmitChanges(); MessageBox.Show("Successfully Payed!"); var studpayment = from s in db.StudentPayments join p in db.Payments on s.PaymentID equals p.PaymentID where s.StudentID == int.Parse(txtSTID.Text) select new { p.Payment1, s.Amount, s.Date }; dgvPayment.DataSource = studpayment; getTotalBalance(); PaymentReceipt pr = new PaymentReceipt(txtSTID.Text, txtPayStudname.Text, cmbPaymentType.Text, txtCOH.Text, txtAmount.Text, txtChanges.Text); pr.ShowDialog(); txtCOH.Text = "0"; txtAmount.Text = "0"; txtChanges.Text = "0"; } else if (cmbPaymentType.Text == "Book Penalty") { StudentPayment sp = new StudentPayment(); sp.StudentID = int.Parse(txtSTID.Text); sp.Amount = decimal.Parse(txtAmount.Text); sp.PaymentID = int.Parse(cmbPaymentType.SelectedValue.ToString()); sp.Date = DateTime.Now; db.StudentPayments.InsertOnSubmit(sp); db.SubmitChanges(); MessageBox.Show("Successfully Payed!"); var studpayment = from s in db.StudentPayments join p in db.Payments on s.PaymentID equals p.PaymentID where s.StudentID == int.Parse(txtSTID.Text) select new { p.Payment1, s.Amount, s.Date }; dgvPayment.DataSource = studpayment; getTotalBalance(); PaymentReceipt pr = new PaymentReceipt(txtSTID.Text, txtPayStudname.Text, cmbPaymentType.Text, txtCOH.Text, txtAmount.Text, txtChanges.Text); pr.ShowDialog(); txtCOH.Text = "0"; txtAmount.Text = "0"; txtChanges.Text = "0"; } else if (double.Parse(txtAmount.Text) > amounts) { MessageBox.Show("Amount is invalid!"); } else { StudentPayment sp = new StudentPayment(); sp.StudentID = int.Parse(txtSTID.Text); sp.Amount = decimal.Parse(txtAmount.Text); sp.PaymentID = int.Parse(cmbPaymentType.SelectedValue.ToString()); sp.Date = DateTime.Now; db.StudentPayments.InsertOnSubmit(sp); db.SubmitChanges(); MessageBox.Show("Successfully Payed!"); var studpayment = from s in db.StudentPayments join p in db.Payments on s.PaymentID equals p.PaymentID where s.StudentID == int.Parse(txtSTID.Text) select new { p.Payment1, s.Amount, s.Date }; dgvPayment.DataSource = studpayment; getTotalBalance(); PaymentReceipt pr = new PaymentReceipt(txtSTID.Text, txtPayStudname.Text, cmbPaymentType.Text, txtCOH.Text, txtAmount.Text, txtChanges.Text); pr.ShowDialog(); txtCOH.Text = "0"; txtAmount.Text = "0"; txtChanges.Text = "0"; } } } }