Example #1
0
        private void PrintVoucher()
        {
            try
            {
                string vWhere                 = string.Empty;
                string vVoucherType           = getVoucherType();
                Reports.RptReportViewer vForm = new Reports.RptReportViewer();

                DataTable dt = objDAL.getVouchersData(" AND VoucherHeader.VoucherID=" + txtVoucherNo.Text + " AND VoucherHeader.VoucherType='" + vVoucherType + "'");
                if (dt.Rows.Count == 0)
                {
                    MessageBox.Show("No Data To Display", "No Data");
                    return;
                }

                if (vVoucherType == "JV")
                {
                    vForm.ShowReport("JOURNAL VOUCHER", dt);
                    vForm.ShowDialog();
                }
                else if (vVoucherType == "CRV")
                {
                    DAL.Settings objSet = new DAL.Settings();
                    objSet.connectionstring = objDAL.connectionstring;

                    DataRow dr = dt.NewRow();
                    dr["VoucherNo"]   = dt.Rows[0]["VoucherNo"];
                    dr["VoucherType"] = dt.Rows[0]["VoucherType"];
                    dr["VoucherDate"] = dt.Rows[0]["VoucherDate"];
                    dr["Narration"]   = dt.Rows[0]["Narration"];
                    dr["AccountNo"]   = 100000;
                    dr["AccountName"] = "Cash"; //objSet.GetSettingValue(DAL.Settings.ProSettings.CashAccTitle);

                    decimal vTotalAmount =
                        dt.AsEnumerable().Sum(r => r.Field <Decimal>("Credit"));

                    dr["Debit"] = vTotalAmount.ToString("G29");

                    //dr["Debit"] = dt.Rows[0]["Credit"];
                    dr["Credit"]     = 0;
                    dr["TranStatus"] = "DEBIT";

                    dt.Rows.Add(dr);

                    vForm.ShowReport("CASH RECEIVING VOUCHER", dt);
                    vForm.ShowDialog();
                }
                else if (vVoucherType == "CPV")
                {
                    vForm.ShowReport("CASH PAYMENT VOUCHER", dt);
                    vForm.ShowDialog();
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Error");
            }
        }
Example #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string vMessage = string.Empty;

                if (cboVoucherType.Text == string.Empty)
                {
                    Message.ShowMessage(MyMessages.MessageType.MissingInfo, "Please Select a Voucher Type");
                    cboVoucherType.Focus();
                    return;
                }

                if (Grid.Rows.Count == 0)
                {
                    Message.ShowMessage(MyMessages.MessageType.MissingInfo, "Please Insert Accounts Information");
                    txtAccountNo.Focus();
                    return;
                }

                if (getVoucherType() == "JV")
                {
                    if (txtTotalCredit.Text != txtTotalDebit.Text)
                    {
                        Message.ShowMessage(MyMessages.MessageType.MissingInfo, "Total Debit and Credit not Equal!!! ");
                        txtAccountNo.Focus();
                        return;
                    }
                }


                Objects.VoucherHeader BAL = new Objects.VoucherHeader();

                BAL.VoucherID        = Int32.Parse(txtVoucherNo.Text);
                BAL.VoucherDate      = dtVoucherDate.Value;
                BAL.VoucherType      = getVoucherType();
                BAL.Narration        = txtNarration.Text;
                BAL.PrintVoucherType = cboPrintOnVoucher.Text;

                DAL.Settings obSet = new DAL.Settings();
                obSet.connectionstring = objDAL.connectionstring;
                BAL.IsPosted           = Convert.ToBoolean(obSet.GetSettingValue(DAL.Settings.ProSettings.IsAutoPost));

                BAL.UserID    = vUserID;
                BAL.EntryDate = DateTime.Now.Date;

                if (vOpenMode)
                {
                    objDAL.UpdateRecord(BAL);
                    objDAL.DeleteRecordBody(Int32.Parse(txtVoucherNo.Text), getVoucherType());
                }
                else
                {
                    objDAL.InsertRecord(BAL);
                }

                //Save Detail
                foreach (DataGridViewRow dr in Grid.Rows)
                {
                    if (dr.Cells[0].Value != null)
                    {
                        Objects.VoucherBody objBody = new Objects.VoucherBody();
                        objBody.VoucherID   = Int32.Parse(txtVoucherNo.Text);
                        objBody.VoucherType = getVoucherType();
                        objBody.AccountNo   = dr.Cells["AccountNo"].Value.ToString();
                        objBody.Debit       = decimal.Parse(dr.Cells["Debit"].Value.ToString());
                        objBody.Credit      = decimal.Parse(dr.Cells["Credit"].Value.ToString());
                        objBody.Remarks     = dr.Cells["Remarks"].Value.ToString();

                        objDAL.InsertRecordBody(objBody);
                    }
                }
                Message.ShowMessage(MyMessages.MessageType.SaveRecord);
                PrintVoucher(txtVoucherNo.Text, getVoucherType());

                SetMode(false);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message.ToString(), "Error");
            }
        }
Example #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string vMessage = string.Empty;

                if (txtCheqNo.Text.Trim() == string.Empty)
                {
                    vMessage = "Please Enter Cheque Number.";
                    new Speak().SayIt(vMessage);
                    MessageBox.Show(vMessage, "Information Missing");
                    txtCheqNo.Focus();
                    return;
                }

                if (txtBankAccName.Text.Trim() == string.Empty)
                {
                    vMessage = "Please Select Bank Account.";
                    new Speak().SayIt(vMessage);
                    MessageBox.Show(vMessage, "Information Missing");
                    txtBankAccNo.Focus();
                    return;
                }

                Int64 vAmount, vChqAmount, vWHTAmnt;

                Int64.TryParse(txtTotalAmount.Text, out vAmount);
                Int64.TryParse(txtTotalCheqAmount.Text, out vChqAmount);
                Int64.TryParse(txtWHTAmount.Text, out vWHTAmnt);

                if (vAmount != vChqAmount)
                {
                    vMessage = "Amount Detail not equal to Total Cheques Amount.";
                    new Speak().SayIt(vMessage);
                    MessageBox.Show(vMessage, "Information Missing");
                    txtAccountNo.Focus();
                    return;
                }

                if (Grid.Rows.Count == 0)
                {
                    vMessage = "Amount Detail not entered.";
                    new Speak().SayIt(vMessage);
                    MessageBox.Show(vMessage, "Information Missing");
                    txtAccountNo.Focus();
                    return;
                }


                Int64.TryParse(txtChqAmount.Text, out vChqAmount);

                Objects.BankIssues obj = new Objects.BankIssues();
                obj.IssueID       = Int64.Parse(txtID.Text);
                obj.IssueDate     = dtDepositDate.Value;
                obj.BankAccountNo = txtBankAccNo.Text;
                obj.Amount        = vChqAmount;
                obj.WHTAccountNo  = "200000";
                obj.WHTAmount     = vWHTAmnt;
                obj.ReceivedBy    = txtReceivedby.Text;
                obj.Narration     = txtNarration.Text;

                DAL.Settings obSet = new DAL.Settings();
                obSet.connectionstring = objDAL.connectionstring;
                obj.IsPosted           = Convert.ToBoolean(obSet.GetSettingValue(DAL.Settings.ProSettings.IsAutoPost));

                obj.UserID    = vUserID;
                obj.EntryDate = DateTime.Now.Date;

                obj.ChequeDate = dtCheqDate.Value;
                obj.ChequeNo   = txtCheqNo.Text;
                obj.IsLost     = false;



                if (!vOpenMode)
                {
                    //Insert Activity
                    obj.IssueID = Int64.Parse(objDAL.getNextNo().ToString());
                    objDAL.DeleteRecordBody(obj.IssueID);

                    objDAL.InsertRecord(obj);
                }
                else
                {
                    objDAL.DeleteRecordBody(obj.IssueID);
                    objDAL.UpdateRecord(obj);
                }

                //Save Detail
                foreach (DataGridViewRow dr in Grid.Rows)
                {
                    if (dr.Cells[0].Value != null)
                    {
                        Objects.BankIssueBody objDon = new Objects.BankIssueBody();
                        objDon.IssueID   = obj.IssueID;
                        objDon.AccountNo = dr.Cells["AccountNo"].Value.ToString();
                        objDon.Amount    = decimal.Parse(dr.Cells["Amount"].Value.ToString());
                        objDAL.InsertRecordBody(objDon);
                    }
                }

                vMessage = "Record Saved Successfully.";
                new Speak().SayIt(vMessage);
                MessageBox.Show(vMessage, "Confirmation");
                PrintVoucher(obj.IssueID);
                btnClear_Click(sender, e);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message.ToString(), "Error");
            }
        }
Example #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string vMessage = string.Empty;


                if (txtSlipNo.Text.Trim() == string.Empty)
                {
                    vMessage = "Please Enter Bank Deposit Slip Number.";
                    new Speak().SayIt(vMessage);
                    MessageBox.Show(vMessage, "Information Missing");
                    txtSlipNo.Focus();
                    return;
                }

                if (txtCheqNo.Text.Trim() == string.Empty)
                {
                    vMessage = "Please Enter Cheque Number.";
                    new Speak().SayIt(vMessage);
                    MessageBox.Show(vMessage, "Information Missing");
                    txtCheqNo.Focus();
                    return;
                }

                if (txtAccountName.Text.Trim() == string.Empty)
                {
                    vMessage = "Please Select From Account.";
                    new Speak().SayIt(vMessage);
                    MessageBox.Show(vMessage, "Information Missing");
                    txtAccountNo.Focus();
                    return;
                }

                if (txtBankAccName.Text.Trim() == string.Empty)
                {
                    vMessage = "Please Select Bank Account.";
                    new Speak().SayIt(vMessage);
                    MessageBox.Show(vMessage, "Information Missing");
                    txtBankAccNo.Focus();
                    return;
                }

                Int64 vAmount;
                Int64.TryParse(txtAmount.Text, out vAmount);

                if (vAmount == 0)
                {
                    vMessage = "Deposited Amount not entered.";
                    new Speak().SayIt(vMessage);
                    MessageBox.Show(vMessage, "Information Missing");
                    txtAmount.Focus();
                    return;
                }



                Objects.BankDeposits obj = new Objects.BankDeposits();
                obj.DepositID     = Int64.Parse(txtID.Text);
                obj.DepositDate   = dtDepositDate.Value;
                obj.SlipNo        = txtSlipNo.Text.Trim();
                obj.AccountNo     = txtAccountNo.Text;
                obj.BankAccountNo = txtBankAccNo.Text;
                obj.Amount        = vAmount;
                obj.DepositedBy   = txtDepositby.Text;
                obj.Narration     = txtNarration.Text;

                DAL.Settings obSet = new DAL.Settings();
                obSet.connectionstring = objDAL.connectionstring;
                obj.IsPosted           = Convert.ToBoolean(obSet.GetSettingValue(DAL.Settings.ProSettings.IsAutoPost));

                obj.UserID    = vUserID;
                obj.EntryDate = DateTime.Now.Date;

                obj.ChequeDate = dtCheqDate.Value;
                obj.ChequeNo   = txtCheqNo.Text;
                obj.IsCheque   = true;

                if (!vOpenMode)
                {
                    //Insert Activity
                    obj.DepositID = Int64.Parse(objDAL.getNextNo().ToString());
                    objDAL.InsertRecord(obj);
                }
                else
                {
                    objDAL.UpdateRecord(obj);
                }

                vMessage = "Record Saved Successfully.";
                new Speak().SayIt(vMessage);
                MessageBox.Show(vMessage, "Confirmation");

                PrintVoucher(obj.DepositID);

                btnClear_Click(sender, e);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message.ToString(), "Error");
            }
        }