예제 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            dt.Columns.Clear();
            dt.Columns.Add("Date", System.Type.GetType("System.String"));
            dt.Columns.Add("Type", System.Type.GetType("System.String"));
            dt.Columns.Add("VNo", System.Type.GetType("System.String"));
            dt.Columns.Add("Particular", System.Type.GetType("System.String"));
            dt.Columns.Add("Debit", System.Type.GetType("System.Double"));
            dt.Columns.Add("Credit", System.Type.GetType("System.Double"));

            if (dataGridView1.Rows.Count > 1)
            {
                this.Cursor = Cursors.WaitCursor;
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    DataRow dr = dt.NewRow();
                    try
                    {
                        dr[0] = dataGridView1.Rows[i].Cells["Date"].Value;
                    }
                    catch
                    {
                        dr[0] = "";
                    }
                    try
                    {
                        dr[1] = dataGridView1.Rows[i].Cells["Type"].Value;
                    }
                    catch
                    {
                        dr[1] = "";
                    }
                    try
                    {
                        dr[2] = dataGridView1.Rows[i].Cells["VNo"].Value;
                    }
                    catch
                    {
                        dr[2] = "";
                    }
                    try
                    {
                        dr[3] = dataGridView1.Rows[i].Cells["Particular"].Value;
                    }
                    catch
                    {
                        dr[3] = "";
                    }
                    try
                    {
                        dr[4] = dataGridView1.Rows[i].Cells["Debit"].Value;
                    }
                    catch
                    {
                        dr[4] = 0;
                    }
                    try
                    {
                        dr[5] = dataGridView1.Rows[i].Cells["Credit"].Value;
                    }
                    catch
                    {
                        dr[5] = 0;
                    }

                    dt.Rows.Add(dr);
                }

                ReportDocument rp    = new ReportDocument();
                string         rPath = Application.StartupPath.ToString() + "\\rptDayBook.rpt";
                rp.Load(rPath);
                rp.SetDataSource(dt);

                frmReportViewer rpt = new frmReportViewer();

                ParameterFieldDefinitions crParameterFieldDefinitions;
                ParameterFieldDefinition  crParameterFieldDefinition;
                ParameterValues           crParameterValues        = new ParameterValues();
                ParameterDiscreteValue    crParameterDiscreteValue = new ParameterDiscreteValue();

                string companyname = Global.company;

                crParameterDiscreteValue.Value = companyname;
                crParameterFieldDefinitions    = rp.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["Company"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;

                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

                crParameterDiscreteValue.Value = dtpFrom.Value.ToString("dd/MM/yyyy");
                crParameterFieldDefinitions    = rp.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["FrmDt"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;

                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

                crParameterDiscreteValue.Value = dtpTo.Value.ToString("dd/MM/yyyy");
                crParameterFieldDefinitions    = rp.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["ToDt"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;

                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

                rpt.crystalReportViewer1.ReportSource = rp;
                rpt.Text = "Day Book Report";
                rpt.ShowDialog();
                rpt.WindowState = FormWindowState.Maximized;
                this.Cursor     = Cursors.Default;
            }
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            DataTable dt = new DataTable();

            dt.TableName = "ledgprint";
            if (dt.Columns.Count > 0)
            {
                dt.Columns.Clear();
            }
            //System.String
            //System.Double

            dt.Columns.Add("LedgName", Type.GetType("System.String"));
            dt.Columns.Add("Debit", Type.GetType("System.Double"));
            dt.Columns.Add("Credit", Type.GetType("System.Double"));
            dt.Columns.Add("Closing", Type.GetType("System.Double"));


            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                DataRow dr = dt.NewRow();
                try
                {
                    dr[0] = dataGridView1.Rows[i].Cells[0].Value.ToString().Trim();
                }
                catch (Exception)
                {
                    dr[0] = "";
                }
                try
                {
                    dr[1] = dataGridView1.Rows[i].Cells[1].Value.ToString().Trim();
                }
                catch (Exception)
                {
                    dr[1] = "0";
                }
                try
                {
                    dr[2] = dataGridView1.Rows[i].Cells[2].Value.ToString().Trim();
                }
                catch (Exception)
                {
                    dr[2] = "0";
                }
                try
                {
                    dr[3] = dataGridView1.Rows[i].Cells[3].Value.ToString().Trim();
                }
                catch (Exception)
                {
                    dr[3] = "0";
                }

                dt.Rows.Add(dr);
            }

            ReportDocument rp    = new ReportDocument();
            string         rPath = Application.StartupPath.ToString() + "\\rptLedgPrint.rpt";

            rp.Load(rPath);
            rp.SetDataSource(dt);

            frmReportViewer rpt = new frmReportViewer();

            ParameterFieldDefinitions crParameterFieldDefinitions;
            ParameterFieldDefinition  crParameterFieldDefinition;
            ParameterValues           crParameterValues        = new ParameterValues();
            ParameterDiscreteValue    crParameterDiscreteValue = new ParameterDiscreteValue();

            string companyname = Global.company;

            crParameterDiscreteValue.Value = companyname;
            crParameterFieldDefinitions    = rp.DataDefinition.ParameterFields;
            crParameterFieldDefinition     = crParameterFieldDefinitions["Company"];
            crParameterValues = crParameterFieldDefinition.CurrentValues;

            crParameterValues.Clear();
            crParameterValues.Add(crParameterDiscreteValue);
            crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

            crParameterDiscreteValue.Value = mLedger;
            crParameterFieldDefinitions    = rp.DataDefinition.ParameterFields;
            crParameterFieldDefinition     = crParameterFieldDefinitions["Ledg"];
            crParameterValues = crParameterFieldDefinition.CurrentValues;

            crParameterValues.Clear();
            crParameterValues.Add(crParameterDiscreteValue);
            crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

            rpt.crystalReportViewer1.ReportSource = rp;
            rpt.Text = "Legder Report";
            rpt.ShowDialog();
            rpt.WindowState = FormWindowState.Maximized;
            this.Cursor     = Cursors.Default;
        }
예제 #3
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            DataTable dt = new DataTable();

            dt.TableName = "Debit";
            dt.Columns.Clear();

            int cnt  = dataGridView1.Rows.Count;
            int cnt1 = dataGridView2.Rows.Count;

            int finalcnt = 0;

            if (cnt > cnt1)
            {
                finalcnt = cnt;
            }
            else if (cnt1 > cnt)
            {
                finalcnt = cnt1;
            }
            else
            {
                finalcnt = cnt;
            }

            dt.Columns.Add("DrLedger", Type.GetType("System.String"));
            dt.Columns.Add("DrAmount", Type.GetType("System.Double"));
            dt.Columns.Add("CrLedger", Type.GetType("System.String"));
            dt.Columns.Add("CrAmount", Type.GetType("System.Double"));
            this.Cursor = Cursors.WaitCursor;
            for (int i = 0; i < finalcnt; i++)
            {
                DataRow dr = dt.NewRow();
                try
                {
                    dr[0] = dataGridView1.Rows[i].Cells["Column2"].Value;
                }
                catch
                {
                    dr[0] = "";
                }
                try
                {
                    dr[1] = dataGridView1.Rows[i].Cells["Column3"].Value;
                }
                catch
                {
                    dr[1] = 0;
                }
                try
                {
                    dr[2] = dataGridView2.Rows[i].Cells["dataGridViewTextBoxColumn3"].Value;
                }
                catch
                {
                    dr[2] = "";
                }
                try
                {
                    dr[3] = dataGridView2.Rows[i].Cells["dataGridViewTextBoxColumn4"].Value;
                }
                catch
                {
                    dr[3] = 0;
                }

                dt.Rows.Add(dr);
            }
            ReportDocument rp    = new ReportDocument();
            string         rPath = Application.StartupPath.ToString() + "\\rptPL.rpt";

            rp.Load(rPath);
            rp.SetDataSource(dt);

            frmReportViewer rpt = new frmReportViewer();

            ParameterFieldDefinitions crParameterFieldDefinitions;
            ParameterFieldDefinition  crParameterFieldDefinition;
            ParameterValues           crParameterValues        = new ParameterValues();
            ParameterDiscreteValue    crParameterDiscreteValue = new ParameterDiscreteValue();

            string companyname = Global.company;

            crParameterDiscreteValue.Value = companyname;
            crParameterFieldDefinitions    = rp.DataDefinition.ParameterFields;
            crParameterFieldDefinition     = crParameterFieldDefinitions["Company"];
            crParameterValues = crParameterFieldDefinition.CurrentValues;

            crParameterValues.Clear();
            crParameterValues.Add(crParameterDiscreteValue);
            crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

            crParameterDiscreteValue.Value = System.DateTime.Today.ToString("dd/MM/yyyy");
            crParameterFieldDefinitions    = rp.DataDefinition.ParameterFields;
            crParameterFieldDefinition     = crParameterFieldDefinitions["ToDt"];
            crParameterValues = crParameterFieldDefinition.CurrentValues;

            crParameterValues.Clear();
            crParameterValues.Add(crParameterDiscreteValue);
            crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

            rpt.crystalReportViewer1.ReportSource = rp;
            rpt.Text = "PL Report";
            rpt.ShowDialog();
            rpt.WindowState = FormWindowState.Maximized;
            this.Cursor     = Cursors.Default;
        }
예제 #4
0
        public void button1_Click(object sender, EventArgs e)
        {
            string str = cmbLedger.SelectedValue.ToString();

            string glid = str.Substring(0, str.IndexOf("-"));
            string slid = str.Substring(str.IndexOf("-") + 1, str.Length - (str.IndexOf("-") + 1));
            string qry  = "";

            if (slid == "00" || slid == "0" || slid == "")
            {
                if (comboBox1.Text == "Only This Ledger")
                {
                    qry = "select b.vno,b.vdt,b.TRANTYPE,b.InventoryVNo,a.AMT,a.AMTTYPE,a.SLID,a.GLID  from TblLEDGER a, TblVOUCHER b " +
                          "where a.BrCode = b.BrCode and a.VNO = b.VNO and a.TRANTYPE = b.TRANTYPE and a.finyr=b.finyr and a.glid = " + glid +
                          " and vdt >='" + frmDt.Value.ToString("dd/MM/yyyy") + "' and vdt < '" +
                          toDt.Value.AddDays(1).ToString("dd/MM/yyyy") + "'";
                }
                else if (comboBox1.Text == "Total Voucher")
                {
                    qry = "select b.vno,b.vdt,b.TRANTYPE,b.InventoryVNo,a.AMT,a.AMTTYPE,a.SLID,a.GLID  from TblLEDGER a, TblVOUCHER b " +
                          "where a.BrCode = b.BrCode and a.VNO = b.VNO and a.TRANTYPE = b.TRANTYPE and a.finyr=b.finyr and (CONVERT(varchar, b.vno)+b.TRANTYPE) in (" +
                          "select (CONVERT(varchar,vno)+TRANTYPE) from TblLEDGER where glid = " + glid + ")" +
                          " and vdt >='" + frmDt.Value.ToString("dd/MM/yyyy") + "' and vdt < '" +
                          toDt.Value.AddDays(1).ToString("dd/MM/yyyy") + "'";
                }
            }
            else
            {
                if (comboBox1.Text == "Only This Ledger")
                {
                    qry = "select b.vno,b.vdt,b.TRANTYPE,b.InventoryVNo,a.AMT,a.AMTTYPE,a.SLID,a.GLID  from TblLEDGER a, TblVOUCHER b " +
                          "where a.BrCode = b.BrCode and a.VNO = b.VNO and a.TRANTYPE = b.TRANTYPE and a.finyr=b.finyr and a.glid = " + glid +
                          " and a.slid = " + slid +
                          " and vdt >='" + frmDt.Value.ToString("dd/MM/yyyy") + "' and vdt < '" +
                          toDt.Value.AddDays(1).ToString("dd/MM/yyyy") + "'";
                }
                else if (comboBox1.Text == "Total Voucher")
                {
                    qry = "select b.vno,b.vdt,b.TRANTYPE,b.InventoryVNo,a.AMT,a.AMTTYPE,a.SLID,a.GLID  from TblLEDGER a, TblVOUCHER b " +
                          "where a.BrCode = b.BrCode and a.VNO = b.VNO and a.TRANTYPE = b.TRANTYPE and a.finyr=b.finyr and (CONVERT(varchar, b.vno)+b.TRANTYPE) in (" +
                          "select (CONVERT(varchar,vno)+TRANTYPE) from TblLEDGER where glid = " + glid + " and slid = " + slid + ")" +
                          " and vdt >='" + frmDt.Value.ToString("dd/MM/yyyy") + "' and vdt < '" +
                          toDt.Value.AddDays(1).ToString("dd/MM/yyyy") + "'";
                }
            }

            this.Cursor = Cursors.WaitCursor;
            string companyname = Global.company;

            SqlDataAdapter da = new SqlDataAdapter(qry, clsConnection.Conn);
            DataSet        ds = new DataSet();

            if (ds.Tables["voucher1"] != null)
            {
                ds.Tables["voucher1"].Clear();
            }
            da.Fill(ds, "voucher1");

            DataTable dt = new DataTable();

            dt.TableName = "voucher";
            dt.Columns.Clear();
            dt.Columns.Add("Vno");
            dt.Columns.Add("vdt");
            dt.Columns.Add("TRANTYPE");
            dt.Columns.Add("InventoryVNo");
            dt.Columns.Add("CAMT");
            dt.Columns.Add("AMTTYPE");
            dt.Columns.Add("VName");
            dt.Columns.Add("DAMT");

            for (int i = 0; i < ds.Tables["voucher1"].Rows.Count; i++)
            {
                string glid1 = ds.Tables["voucher1"].Rows[i]["GLID"].ToString();
                string slid1 = ds.Tables["voucher1"].Rows[i]["SLID"].ToString();

                string tablename   = "TblSLmast";
                string fieldname   = "SL_L_NAME";
                string whereclause = " SLID = " + slid1 + " and GLID = " + glid1;

                if (slid1 == "00" || slid1 == "" || slid1 == "0")
                {
                    tablename   = "TblGLmast";
                    fieldname   = "GL_L_Name";
                    whereclause = " GLID = " + glid1;
                }

                qry = "select " + fieldname + " from " + tablename + " where " + whereclause;
                SqlCommand com  = new SqlCommand(qry, clsConnection.Conn);
                string     name = Convert.ToString(com.ExecuteScalar());

                DataRow dr = dt.NewRow();
                dr[0] = ds.Tables["voucher1"].Rows[i]["vno"].ToString();
                dr[1] = ds.Tables["voucher1"].Rows[i]["vdt"].ToString();

                string trantype = ds.Tables["voucher1"].Rows[i]["TRANTYPE"].ToString();
                if (trantype == "J")
                {
                    dr[2] = "Journal";
                }
                else if (trantype == "Y")
                {
                    dr[2] = "Payment";
                }
                else if (trantype == "R")
                {
                    dr[2] = "Receipt";
                }
                else if (trantype == "T")
                {
                    dr[2] = "Contra";
                }

                //dr[2] = ds.Tables["voucher1"].Rows[i]["TRANTYPE"].ToString();

                string amttype = ds.Tables["voucher1"].Rows[i]["AMTTYPE"].ToString();
                if (amttype == "D")
                {
                    dr[7] = Math.Round(Convert.ToDouble(ds.Tables["voucher1"].Rows[i]["AMT"].ToString()), 2);
                    dr[4] = 0;
                }
                else
                {
                    dr[7] = 0;
                    dr[4] = Math.Round(Convert.ToDouble(ds.Tables["voucher1"].Rows[i]["AMT"].ToString()), 2);
                }

                dr[6] = name;
                dr[3] = ds.Tables["voucher1"].Rows[i]["InventoryVNo"].ToString();

                dt.Rows.Add(dr);
            }

            //Display Report

            ReportDocument rp    = new ReportDocument();
            string         rPath = Application.StartupPath.ToString() + "\\rptVoucher.rpt";

            rp.Load(rPath);

            // rp.DataDefinition.FormulaFields["LedgerName"].Text = cmbLedger.Text;
            //   rp.DataDefinition.FormulaFields["brname"].Text =  Global.branch;
            // rp.DataDefinition.FormulaFields["fin_period"].Text = "\"" + Global.gFromDt.ToString("dd/MM/yyyy") + " - " + Global.gToDt.ToString("dd/MM/yyyy") + "\"";

            rp.SetDataSource(dt);

            frmReportViewer rpt = new frmReportViewer();

            ParameterFieldDefinitions crParameterFieldDefinitions;
            ParameterFieldDefinition  crParameterFieldDefinition;
            ParameterValues           crParameterValues        = new ParameterValues();
            ParameterDiscreteValue    crParameterDiscreteValue = new ParameterDiscreteValue();

            crParameterDiscreteValue.Value = companyname;
            crParameterFieldDefinitions    = rp.DataDefinition.ParameterFields;
            crParameterFieldDefinition     = crParameterFieldDefinitions["Company"];
            crParameterValues = crParameterFieldDefinition.CurrentValues;

            crParameterValues.Clear();
            crParameterValues.Add(crParameterDiscreteValue);
            crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

            rpt.crystalReportViewer1.ReportSource = rp;
            rpt.Text = "Voucher Report";
            rpt.ShowDialog();
            rpt.WindowState = FormWindowState.Maximized;
            this.Cursor     = Cursors.Default;
        }