private void btn_print_Click(object sender, EventArgs e) { int rcpt; if (int.TryParse(txt_rcpt_no.Text.ToString().Trim(), out rcpt) == false) { MessageBox.Show("Invalid Receipt No."); return; } switch (cmb_type.Text.Trim()) { case "Fees": Print_Documents.printFeesReceipt(rcpt.ToString()); break; case "Rent": Print_Documents.printRentReceipt(rcpt.ToString()); break; case "Inc/Exp": Print_Documents.printIncExpReceipt(rcpt.ToString()); break; } }
private void btn_save_Click(object sender, EventArgs e) { //string fees = txt_fees.Text.Trim(); float fltFees; //if (fees == string.Empty || float.TryParse(fees, out fltFees) == false) //{ // MessageBox.Show("Please Enter Valid Amount for Fees"); // return; //} dp_from_month.Value = DateTime.ParseExact(dp_from_month.Value.ToString("01/MMM/yyyy"), "dd/MMM/yyyy", CultureInfo.InvariantCulture); dp_to_month.Value = DateTime.ParseExact(dp_to_month.Value.AddMonths(1).ToString("01/MMM/yyyy"), "dd/MMM/yyyy", CultureInfo.InvariantCulture); dp_to_month.Value = dp_to_month.Value.AddDays(-1); //last day of the month if (txt_stu_name.Text.Trim() == string.Empty) { MessageBox.Show("Please Select a Student First."); button2.Focus(); return; } if (dp_from_month.Value > dp_to_month.Value) { MessageBox.Show("From Date should be less than To Date"); return; } if (calculateFees() == false) { return; } if (txt_fees.Text.Trim() == string.Empty || float.Parse(txt_fees.Text.Trim()) <= 0) { MessageBox.Show("Invalid Fees Amount"); txt_fees.Focus(); return; } string from_month = dp_from_month.Value.ToString("dd-MMM-yyyy"); string to_month = dp_to_month.Value.ToString("dd-MMM-yyyy"); string pay_method = cmb_pay_method.Text; string incm_type = "(SELECT ID FROM INC_EXP_HEADS WHERE SUB_TYPE = 1)";//cmb_inc_type.SelectedValue.ToString(); string fees_paid = txt_fees.Text; string comments = txt_comments.Text.Trim(); string recvd_on = dp_recvd_on.Value.ToString("dd-MMM-yyyy"); string insertCmd = ""; if (checkIfDuplicate() == true) { DialogResult dlg = MessageBox.Show("Record already exists, do you still want to create a new record", "Record Exists", MessageBoxButtons.YesNo); if (dlg == System.Windows.Forms.DialogResult.No) { return; } } if (comments == string.Empty) { comments = string.Format("Received amount {0} against income head {1}", fees_paid, "Monthly Fees"); } insertCmd = string.Format(@"INSERT INTO FEES_DETAILS(STUDENT,FEES_FROM,FEES_TO,PAYMENT_METHOD,INC_EXP_HEAD,TOTAL_AMT,TOTAL_PAID,MONTHLY_FEES,COMMENTS,RECVD_ON) VALUES({0},'{1}','{2}','{3}',{4},{5},{6},{7},'{8}','{9}')", _studentID, from_month, to_month, pay_method, incm_type, _feesAmount, fees_paid, _monthlyFees, comments, recvd_on); string id_value; string returnVal = common.updateTable(insertCmd, out id_value); if (returnVal == common.SUCCESS_MSG) { DialogResult dlg = MessageBox.Show("Record Saved Successfully. Do you want to print Fees Receipt now?", "Saved Successfully", MessageBoxButtons.YesNo); if (dlg == DialogResult.Yes) { Print_Documents.printFeesReceipt(id_value); } } else { MessageBox.Show(returnVal); } }