private void btn_save_Click(object sender, EventArgs e) { if (txt_desc.Text.Trim() == string.Empty) { MessageBox.Show("Please Enter " + lbl_rcvd_from.Text); return; } float amt; if (float.TryParse(txt_amount.Text, out amt) == false) { MessageBox.Show("Invalid Amount"); txt_amount.Focus(); return; } if (float.Parse(txt_amount.Text) <= 0) { MessageBox.Show("Invalid Amount"); txt_amount.Focus(); return; } string incExpHd = cmb_heads.SelectedValue.ToString(); string incExpHdName = cmb_heads.Text; string description = txt_desc.Text.Trim(); string rcvdDate = dp_rcvd_dt.Value.ToString("yyyy-MMMM-dd"); string amount = txt_amount.Text; string pay_method = cmb_pay_method.Text; string studentID = "0"; string comments = txt_comments.Text.Trim(); if (studentDtls != null) { studentID = studentDtls["id"].ToString(); } if (comments == string.Empty) { string type = cmb_type.Text == "Income" ? "Received" : "Paid"; comments = string.Format("{0} amount {1} against income head {2}", type, amount, incExpHdName); } string insrtCmd = string.Format(@"INSERT INTO INC_EXP_TRANS(DESCRIPTION,INC_EXP_HEAD,AMOUNT,TRANS_DATE,STUDENT,PAY_METHOD,COMMENTS) VALUES('{0}',{1},{2},'{3}',{4},'{5}','{6}')", description, incExpHd, amount, rcvdDate, studentID, pay_method, comments); string id_value; string retVal = common.updateTable(insrtCmd, out id_value); if (retVal == common.SUCCESS_MSG) { DialogResult dlg = MessageBox.Show("Record Saved Successfully, Do you want to print it now?", "Record Saved", MessageBoxButtons.YesNo); if (dlg == DialogResult.Yes) { Print_Documents.printIncExpReceipt(id_value); } } else { MessageBox.Show(retVal); } }
private void btn_save_Click(object sender, EventArgs e) { if (cmb_properties.Items.Count == 0) { MessageBox.Show("No Properties To Collect Rent, Please make a Lease Entry."); return; } if (dp_from.Value > dp_to.Value) { MessageBox.Show("From Date can not be less than To Date"); dp_from.Focus(); return; } calculateTotalRent(); dp_from.Value = DateTime.ParseExact(dp_from.Value.ToString("01/MMM/yyyy"), "dd/MMM/yyyy", CultureInfo.InvariantCulture); dp_to.Value = DateTime.ParseExact(dp_to.Value.AddMonths(1).ToString("01/MMM/yyyy"), "dd/MMM/yyyy", CultureInfo.InvariantCulture); dp_to.Value = dp_to.Value.AddDays(-1); //last day of the month string property = cmb_properties.SelectedValue.ToString(); string from_dt = dp_from.Value.ToString("yyyy-MMM-dd"); string to_dt = dp_to.Value.ToString("yyyy-MMM-dd"); string amount = txt_tot_rent.Text; string date = dp_recvd_on.Value.ToString("yyyy-MMM-dd"); string pay_method = cmb_pay_method.Text; string comments = txt_comments.Text.Trim(); DataRow dr = ds_prop_dtls.Tables[0].Select("ID = '" + property + "'")[0]; string inc_exp_head = dr["inc_exp_head"].ToString(); string inc_exp_name = dr["inc_exp_name"].ToString(); if (comments == string.Empty) { comments = string.Format("Received amount {0} against rent for {1}", amount, inc_exp_name); } string insrtCmd = string.Format(@"INSERT INTO RENT_DETAILS(LEASE_ID,RENT_FROM,RENT_TO,RECVD_ON,AMOUNT,PAY_METHOD,COMMENTS,INC_EXP_HEAD) VALUES({0},'{1}','{2}','{3}',{4},'{5}','{6}',{7})", property, from_dt, to_dt, date, amount, pay_method, comments, inc_exp_head); string id_value; string retVal = common.updateTable(insrtCmd, out id_value); if (retVal == common.SUCCESS_MSG) { var dlg = MessageBox.Show("Record Saved Successfully, Do you want to print receipt now ?", "Record Saved", MessageBoxButtons.YesNo); if (dlg == DialogResult.Yes) { Print_Documents.printRentReceipt(id_value); } loadGridData(); } else { MessageBox.Show(retVal); } }
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); } }