예제 #1
0
        private void showAccountButton_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            if (!this.ValidateChildren(ValidationConstraints.Enabled))
            {
                SystemSounds.Exclamation.Play();
                Cursor.Current = Cursors.Default;
                return;
            }

            DateTime openingDate;

            if (accountDatePicker.Checked)
            {
                openingDate = accountDatePicker.Value.Date;
            }
            else
            {
                openingDate = Global.CurrentFinancialYear.BooksStartDate;
            }

            AccountStatementDataSet dataSet = new AccountStatementDataSet();

            if (!populateOpeningBalance(openingDate, dataSet))
            {
                return;
            }

            if (!populateInvoiceStatements(openingDate, dataSet))
            {
                return;
            }

            if (!populatePaymentStatements(openingDate, dataSet))
            {
                return;
            }

            AccountStatementView form = new AccountStatementView(dataSet,
                                                                 (string)customerComboBox.Text);

            form.MdiParent = this.MdiParent;

            try
            {
                form.Show();
            }
            catch (Exception ex)
            {
                SystemSounds.Hand.Play();
                Cursor.Current = Cursors.Default;
                string message = "An error occurred in showing the Print Preview of the account statement."
                                 + "\nThe error text is as follows:\n" + Global.getExceptionText(ex);
                MessageBox.Show(message, "Error Occurred", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                ErrorLogger.LogError(ex);
            }
            Cursor.Current = Cursors.Default;
        }
        public override global::System.Data.DataSet Clone()
        {
            AccountStatementDataSet cln = ((AccountStatementDataSet)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            AccountStatementDataSet ds = new AccountStatementDataSet();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
예제 #4
0
        private bool populateOpeningBalance(DateTime openingDate,
                                            AccountStatementDataSet dataset)
        {
            decimal?openingBalance;
            string  errorText;
            int     customerID = (int)customerComboBox.SelectedValue;

            if (openingDate.CompareTo(Global.CurrentFinancialYear.BooksStartDate) == 0)
            {
                openingBalance = GlobalMethods.GetCustomerOpeningBalance(customerID, out errorText);
            }
            else
            {
                openingBalance = GlobalMethods.GetCustomerBalance(customerID, out errorText, null,
                                                                  openingDate.Subtract(new TimeSpan(1, 0, 0, 0)));
            }

            if (errorText != null)
            {
                SystemSounds.Hand.Play();
                string message = "An error occurred in fetching the customer's account details from "
                                 + "the database. \nThe error text is as follows:\n" + errorText;
                Cursor.Current = Cursors.Default;
                MessageBox.Show(message, "Error Occurred", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            AccountStatementDataSet.AccountStatementRow row =
                dataset.AccountStatement.NewAccountStatementRow();
            row.TransactionDate = openingDate;
            row.Description     = "Opening Balance";

            if (openingBalance.Value > 0.0M)
            {
                row.CreditAmount = openingBalance.Value;
            }
            else
            {
                row.DebitAmount = Math.Abs(openingBalance.Value);
            }

            dataset.AccountStatement.AddAccountStatementRow(row);
            return(true);
        }
예제 #5
0
        public void Read()
        {
            this.reportQuary = fromdateTimePicker.Text + "  to  " + todateTimePicker2.Text;
            string query = "";

            query = "Select * From TbAccountStatement Where CreateDate BETWEEN  '" + fromdateTimePicker.Value.Date + "' AND  '" + todateTimePicker2.Value.Date + "' Order By AutoId";
            if (query != "")
            {

                SqlConnection conn = new SqlConnection(this.connectionString);
                SqlCommand comm = new SqlCommand(query, conn);

                SqlDataAdapter adap = new SqlDataAdapter();
                AccountStatementDataSet dataset = new AccountStatementDataSet();
                AccountStatementCrystalReport crp = new AccountStatementCrystalReport();

                try
                {
                    conn.Open();
                    adap.SelectCommand = comm;
                    adap.Fill(dataset, "DataTable1");
                    crp.SetDataSource(dataset);
                    ParameterValues v = new ParameterValues();
                    ParameterDiscreteValue dv = new ParameterDiscreteValue();

                    dv = new ParameterDiscreteValue();
                    dv.Value = this.reportQuary;
                    v.Add(dv);
                    crp.DataDefinition.ParameterFields["report_query"].ApplyCurrentValues(v);

                    crystalReportViewer1.ReportSource = crp;

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
                finally
                {
                    conn.Close();
                }
            }
        }
예제 #6
0
        private bool populatePaymentStatements(DateTime openingDate, AccountStatementDataSet dataset)
        {
            string          sql = getPaymentRetrievalSQL(openingDate);
            string          errorText;
            SqlCeConnection connection = Global.getDatabaseConnection(out errorText);

            try
            {
                using (SqlCeCommand command = connection.CreateCommand())
                {
                    command.CommandText = sql;
                    using (SqlCeDataReader reader = command.ExecuteReader())
                    {
                        AccountStatementDataSet.AccountStatementRow row;
                        string mode;
                        while (reader.Read())
                        {
                            row = dataset.AccountStatement.NewAccountStatementRow();
                            row.TransactionDate = reader.GetDateTime(0);
                            mode            = reader.GetString(2);
                            row.Description = "Payment received through " +
                                              (mode == "C" ? "cash" : (mode == "Q" ? "cheque" : "DD"));
                            row.CreditAmount = reader.GetDecimal(1);
                            dataset.AccountStatement.AddAccountStatementRow(row);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string message = "An error occurred in fetching the account details from " +
                                 "the database. The error text is as follows:\n" +
                                 Global.getExceptionText(ex);
                Cursor.Current = Cursors.Default;
                MessageBox.Show(message, "Error Occurred", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                ErrorLogger.LogError(ex);
                return(false);
            }

            return(true);
        }
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                AccountStatementDataSet ds = new AccountStatementDataSet();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "AccountStatementDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }
예제 #8
0
 public AccountStatementView(AccountStatementDataSet dataset, string customerName)
     : this()
 {
     this.dataset      = dataset;
     this.customerName = customerName;
 }