Example #1
0
        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);
            }
        }
Example #2
0
        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;
            }
        }