void SaveTaller() { try { if (CustomMsgBox.Show("Teller No:\n" + txtTallerNumber.Text, "Confirm Details", "Yes", "No") == DialogResult.Yes) { //Save the taller image SqlCommand cmd = new SqlCommand(); MemoryStream ms = new MemoryStream(); pictureTaller.Image.Save(ms, pictureTaller.Image.RawFormat); byte[] a = ms.GetBuffer(); ms.Close(); cmd.Connection = con; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@Taller", a); cmd.CommandText = "INSERT INTO Taller(ID,Taller_Id,Taller) VALUES(0,'" + Taller.TallerID + "',@Taller)"; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } } catch (Exception Ex) { MessageBox.Show(Ex.Message + "\nOperation Failed", "Teller Image", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static DialogResult Show(string text, string Caption, string btnYes, string btnNo) { MsgBox = new CustomMsgBox(); MsgBox.label1.Text = text; MsgBox.Text = Caption; MsgBox.button1.Text = btnYes; MsgBox.button2.Text = btnNo; MsgBox.ShowDialog(); return(result); }
private void btnSubmit_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(combEventName.Text)) { throw new Exception("Please SELECT Fee Name"); } if (string.IsNullOrEmpty(txtname.Text)) { throw new Exception("Please SELECT a Name"); } if (string.IsNullOrEmpty(txtClass.Text)) { throw new Exception("Please SELECT A Class"); } if (string.IsNullOrEmpty(txtAmount.Text)) { throw new Exception("Please Enter Fee Amount"); } Fees fs = new Fees(); payAmount = double.Parse(string.Format("{0:00}", txtAmount.Text)); fs.setAmount(payAmount); payAmount = fs.getAmount(); //CHECK IF IS CURRENT FEE OR DEBT if (string.IsNullOrEmpty(combEventName.Text)) { throw new Exception("Please SELECT Fee Name"); } if (string.IsNullOrEmpty(combTerm.Text)) { throw new Exception("Select Term"); } if (radioCurrent.Checked == true) { Feetype = "Current"; } else if (radioDebt.Checked == true) { Feetype = "Debt"; //MAKE DEBT PAYMENT } else { throw new Exception("Please Select Fee Type to pay"); } if (string.IsNullOrEmpty(txtAmount.Text)) { throw new Exception("Please enter The Amount"); } //ON GETTING STUDENT ID, EXECUTION CONTINUES FROM HER con.Open(); //GET THE FEE AMOUNT TO BE PAID FOR //MessageBox.Show(Name + "\nStudent" + studId.ToString() + "\n sesId" + sessionId.ToString()); DataTable dtpay = new DataTable(); SqlDataAdapter dapay = new SqlDataAdapter( " SELECT Amount FROM Events WHERE Name =@event AND Fee_Name =@feename AND Event_Id =@eventid", con); dapay.SelectCommand.Parameters.AddWithValue("@event", SqlDbType.VarChar).Value = combEventName.SelectedItem; dapay.SelectCommand.Parameters.AddWithValue("@feename", SqlDbType.VarChar).Value = txtFeeName.Text; dapay.SelectCommand.Parameters.AddWithValue("@eventid", SqlDbType.VarChar).Value = EventPayment.EventId; DataSet dsId = new DataSet(); dapay.Fill(dtpay); dapay.Fill(dsId); int check = dsId.Tables[0].Rows.Count; if (check > 0) { foreach (DataRow drpay in dtpay.Rows) { var getAmount = Convert.ToInt32(drpay[0]); FeeAmount = getAmount; } } else { MessageBox.Show("Fees amount not Set"); } con.Close(); //MessageBox.Show(studId.ToString(),"Student Id"); //GET STUDENT ID OF THE PAYER DataTable dtGetId = new DataTable(); SqlDataAdapter daGetId = new SqlDataAdapter("SELECT ClassName FROM Class WHERE Student_Id =@studid and ClassName=@class", con); daGetId.SelectCommand.Parameters.AddWithValue("@studid", SqlDbType.VarChar).Value = studId; daGetId.SelectCommand.Parameters.AddWithValue("@class", SqlDbType.VarChar).Value = txtClass.Text.ToUpper(); DataSet dsGetId = new DataSet(); daGetId.Fill(dtGetId); daGetId.Fill(dsGetId); int checkId = dsGetId.Tables[0].Rows.Count; if (checkId > 0) { //CONFIRM AMOUNT if (CustomMsgBox.Show("Amount:\n" + txtAmount.Text, "Confirm Amount", "Yes", "No") == DialogResult.No) { throw new Exception("Please Check the Amount"); } //GET THE TALLER DETAILS if (checkTaller.Checked == true && string.IsNullOrEmpty(Taller.TallerID) == true) { var tallerDetails = new TallerForm(); tallerDetails.ShowDialog(); } if (Taller.TallerError == true) { Taller.TallerError = false; throw new Exception("Teller Image was NOT Uploaded");//on error with the taller upload stop the program } payEventFees(); } else { if (MessageBox.Show("Student Does not belong to the selected Class\nPromote Student?", "Payment Error", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { //CALL PROMOTION METHOD MessageBox.Show("Go To Students Section and \nPromote Student to new Class", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } //else //{ // throw new Exception("Student Not found in Event Class"); //} } printTime = 15; timerPrint.Start(); } //ene of try block catch (ExceptionHandling Ex) { con.Close(); MessageBox.Show(Ex.Message, "Payment Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception Ex) { con.Close(); MessageBox.Show(Ex.Message, "Payment Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } }