Ejemplo n.º 1
0
        private void btnDeclare_Click(object sender, EventArgs e)
        {
            System.Data.DataTable result = new System.Data.DataTable();
            result.Columns.Add(new DataColumn("dr", typeof(String)));
            result.Columns.Add(new DataColumn("drDate", typeof(DateTime)));
            result.Columns.Add(new DataColumn("poNo", typeof(String)));
            result.Columns.Add(new DataColumn("custname", typeof(String)));
            result.Columns.Add(new DataColumn("address", typeof(String)));
            result.Columns.Add(new DataColumn("tin", typeof(String)));
            result.Columns.Add(new DataColumn("productCode", typeof(String)));
            result.Columns.Add(new DataColumn("description", typeof(String)));
            result.Columns.Add(new DataColumn("batch", typeof(String)));
            result.Columns.Add(new DataColumn("exDate", typeof(DateTime)));
            result.Columns.Add(new DataColumn("pack", typeof(String)));
            result.Columns.Add(new DataColumn("pcs", typeof(Decimal)));
            result.Columns.Add(new DataColumn("cases", typeof(int)));
            result.Columns.Add(new DataColumn("terms", typeof(String)));
            DataRow resultRow = result.NewRow();
            var     dt        = DataSupport.RunDataSet("Select * from Global_drTrans dr join Global_drTransDetails D on dr.dr_Id = D.dr_Id join base_customer c on dr.custCode = c.custCode where dr.drNo = '" + txtdr.Text + "'").Tables[0];

            foreach (DataRow row in dt.Rows)
            {
                resultRow                = result.NewRow();
                resultRow["dr"]          = row["drNo"].ToString();
                resultRow["drDate"]      = row["drDate"].ToString();
                resultRow["poNo"]        = row["poNo"].ToString();
                resultRow["custname"]    = row["custName"].ToString();
                resultRow["address"]     = row["address"].ToString();
                resultRow["tin"]         = row["tinNo"].ToString();
                resultRow["productCode"] = row["product_code"].ToString();
                resultRow["description"] = row["description"].ToString();
                resultRow["batch"]       = row["batchno"].ToString();
                if (row["expiryDate"].ToString() == "")
                {
                    resultRow["exDate"] = DBNull.Value;
                }
                else
                {
                    resultRow["exDate"] = row["expiryDate"].ToString();
                }
                resultRow["pack"]  = row["packSize"].ToString();
                resultRow["pcs"]   = row["pcs"].ToString();
                resultRow["cases"] = row["cases"].ToString();
                resultRow["terms"] = DBNull.Value;
                result.Rows.Add(resultRow);
            }
            var            viewer     = new Reports.ReportViewer();
            ReportDocument ReportDocs = new ReportDocument();

            if (cbxchoose.Text == "Extra Copy")
            {
                ReportDocs = new Reports.Extracopy.ExtraDr();
            }
            else
            {
                ReportDocs = new Reports.Dr();
            }
            ReportDocs.Database.Tables[0].SetDataSource(result);
            viewer.Viewer.ReportSource = ReportDocs;
            viewer.btnDeclare.Visible  = false;
            viewer.ShowDialog();
        }
Ejemplo n.º 2
0
        private void btnDeclare_Click(object sender, EventArgs e)
        {
            System.Data.DataTable result = new System.Data.DataTable();
            result.Columns.Add(new DataColumn("dr", typeof(String)));
            result.Columns.Add(new DataColumn("drDate", typeof(DateTime)));
            result.Columns.Add(new DataColumn("poNo", typeof(String)));
            result.Columns.Add(new DataColumn("custname", typeof(String)));
            result.Columns.Add(new DataColumn("address", typeof(String)));
            result.Columns.Add(new DataColumn("tin", typeof(String)));
            result.Columns.Add(new DataColumn("productCode", typeof(String)));
            result.Columns.Add(new DataColumn("description", typeof(String)));
            result.Columns.Add(new DataColumn("batch", typeof(int)));
            result.Columns.Add(new DataColumn("exDate", typeof(DateTime)));
            result.Columns.Add(new DataColumn("pack", typeof(String)));
            result.Columns.Add(new DataColumn("pcs", typeof(Decimal)));
            result.Columns.Add(new DataColumn("cases", typeof(int)));
            result.Columns.Add(new DataColumn("terms", typeof(String)));
            DataRow resultRow = result.NewRow();

            resultRow             = result.NewRow();
            resultRow["dr"]       = txtDRNo.Text;
            resultRow["drDate"]   = txtDRDate.Text;
            resultRow["poNo"]     = txtREf.Text;
            resultRow["custname"] = txtCustName.Text;
            resultRow["address"]  = txtaddress.Text;
            resultRow["tin"]      = txtTin.Text;
            resultRow["terms"]    = txtTerms.Text;
            result.Rows.Add(resultRow);
            foreach (DataGridViewRow dRow in dataGridView1.Rows)
            {
                if (dataGridView1.Rows.IndexOf(dRow) == dataGridView1.Rows.Count - 1)
                {
                    break;
                }
                resultRow = result.NewRow();
                resultRow["productCode"] = dRow.Cells[colCode.Name].Value.ToString();
                resultRow["description"] = dRow.Cells[coldescription.Name].Value.ToString();
                if (string.IsNullOrEmpty(dRow.Cells[colbatch.Name].Value as string))
                {
                    resultRow["batch"] = "0";
                }
                else
                {
                    resultRow["batch"] = dRow.Cells[colbatch.Name].Value.ToString();
                }
                if (dRow.Cells[colExdate.Name].Value == null)
                {
                    resultRow["exDate"] = DBNull.Value;
                }
                else
                {
                    resultRow["exDate"] = dRow.Cells[colExdate.Name].Value.ToString();
                }
                resultRow["pack"]  = dRow.Cells[colPack.Name].Value.ToString();
                resultRow["pcs"]   = dRow.Cells[colpcs.Name].Value.ToString();
                resultRow["cases"] = dRow.Cells[colcases.Name].Value.ToString();
                result.Rows.Add(resultRow);
            }
            var            viewer     = new Reports.ReportViewer();
            ReportDocument ReportDocs = new ReportDocument();

            ReportDocs = new Reports.Dr();
            ReportDocs.Database.Tables[0].SetDataSource(result);
            viewer.Viewer.ReportSource = ReportDocs;
            viewer.btnPrint.Visible    = false;
            viewer.ShowDialog();
            if (viewer._status == "save")
            {
                save(); clear();
            }
        }