示例#1
0
        private void btnPrintBarcode_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("BARCODE");
            dt.Columns.Add("DOCTYPE_NAME");

            bool IsSelect = false;
            for (int i = 0; i < dgDocType.Rows.Count;i++ )
            {
                if (dgDocType.Rows[i].Cells["colCheckBox"].Value == "Y")
                {
                    IsSelect = true;
                    DataRow dr = dt.NewRow();
                    DocTypeFunc fnc = new DocTypeFunc();
                    DocTypePara para = fnc.GetDocTypePara(Convert.ToInt64(dgDocType.Rows[i].Cells["colID"].Value.ToString()), null);

                    dr["BARCODE"] = "*" + Config.BarcodeStartDigit + para.DOCTYPE_CODE + "*";
                    dr["DOCTYPE_NAME"] = para.DOCTYPE_CODE + " " + para.DOCTYPE_NAME;
                    dt.Rows.Add(dr);
                }
            }

            if (IsSelect == false)
            {
                MessageBox.Show("กรุณาเลือกประเภทเอกสารที่ต้องการพิมพ์");
                dgDocType.Focus();
                return;
            }

            if (dt.Rows.Count > 0)
            {
                TableLogOnInfo logonInfo = new TableLogOnInfo();
                logonInfo.ConnectionInfo.DatabaseName = Config.DbGetDbName;
                logonInfo.ConnectionInfo.ServerName = Config.DbGetDataSource;
                logonInfo.ConnectionInfo.UserID = Config.DbGetUserID;
                logonInfo.ConnectionInfo.Password = Config.DbGetPwd;

                crtPrintBarcode rpt = new crtPrintBarcode();
                frmPrintPreview frm = new frmPrintPreview();
                rpt.SetDataSource(dt);
                rpt.Database.Tables[0].ApplyLogOnInfo(logonInfo);
                frm.crystalReportViewer1.ReportSource = rpt;
                frm.StartPosition = FormStartPosition.CenterScreen;
                frm.WindowState = FormWindowState.Maximized;
                frm.Show();
            }
        }
示例#2
0
        private void gvDoctype_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow dgv = new DataGridViewRow();
            dgv = gvDoctype.Rows[e.RowIndex];

            DocTypeFunc fnc = new DocTypeFunc();
            DocTypePara para = fnc.GetDocTypePara(Convert.ToInt64(dgv.Cells["colID"].Value), null);

            txtID.Text = para.ID.ToString();
            txtDocTypeCode.Text = para.DOCTYPE_CODE;
            txtDoctypeName.Text = para.DOCTYPE_NAME;
        }