//------------------------------------------------------------------------------------

        //crear codigo de barras
        public int crearBarCode()
        {
            if (!ValidaCampos("barra"))
            {
                return(0);
            }

            if (randomNumber != -1)
            {
                Image.FromFile(Application.StartupPath + @"\temp\" + randomNumber + ".bmp").Dispose();
            }


            code128.Code = txtProductor.Text + "" + comboEspecie.SelectedValue.ToString() + "" + comboVariedad.SelectedValue.ToString();

            // Create a blank image
            System.Drawing.Bitmap bmpimg = new Bitmap(600, 80);
            //bmpimg.SetResolution(960.0F, 960.0F);

            // provide width and height based on the barcode image to be generated. harcoded for sample purpose

            Graphics bmpgraphics = Graphics.FromImage(bmpimg);

            bmpgraphics.Clear(Color.White); // Provide this, else the background will be black by default
            Point ulCorner = new Point(0, 0);
            Point urCorner = new Point(250, 0);
            Point llCorner = new Point(0, 38);

            Point[] destPara = { ulCorner, urCorner, llCorner };
            // generate the code128 barcode
            bmpgraphics.DrawImage(code128.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White), 15, 0);
            bmpgraphics.DrawImage(code128.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White), 15, 10);

            //generate the text below the barcode image. If you want the placement to be dynamic, calculate the point based on size of the image
            bmpgraphics.DrawString(code128.Code, new System.Drawing.Font("Arial", 8, FontStyle.Regular), SystemBrushes.WindowText, new Point(35, 38));

            // Save the output stream as gif. You can also save it to external file
            MemoryStream ms = new MemoryStream();

            randomNumber = random.Next(0, 100000);
            bmpimg.Save(Application.StartupPath + @"\temp\" + randomNumber + ".bmp", System.Drawing.Imaging.ImageFormat.Gif);

            imgBarcode.Image = Image.FromFile(Application.StartupPath + @"\temp\" + randomNumber + ".bmp");

            return(0);
        }
        /// <summary>
        /// Generate a barcode based on the string passed to the method
        /// </summary>
        /// <param name="barcodeSource">string to convert to barcode</param>
        /// <returns>return a barcode image based in the parameter.</returns>
        public Image GenerateBarcode(string barcodeSource)
        {
            Barcode128 barcode128 = new Barcode128 {
                Code = barcodeSource
            };

            return(barcode128.CreateDrawingImage(Color.Black, Color.White));
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            iTextSharp.text.Rectangle pageSize = new iTextSharp.text.Rectangle(300, 720);
            Document  pdfToCreate = new Document(pageSize, 0, 0, 0, 0);
            PdfWriter writer      = PdfWriter.GetInstance(pdfToCreate, new FileStream(@"D:\\testfile.pdf", FileMode.Create));

            pdfToCreate.Open();

            PdfPTable table    = new PdfPTable(1);
            PdfPTable tableout = new PdfPTable(1);

            WriteLineToPdf("This is first row. Below is image generated using SystemDrawing.", table, out tableout);
            table = tableout;

            // Create bar code
            Barcode128 code128 = new Barcode128();

            code128.CodeType         = Barcode.CODE128;
            code128.ChecksumText     = true;
            code128.GenerateChecksum = true;
            code128.Code             = "00100370006756555316";

            // Create a new PdfWrite object, writing the output to a MemoryStream
            var            outputStream = new MemoryStream();
            var            pdfWriter    = PdfWriter.GetInstance(pdfToCreate, outputStream);
            PdfContentByte cb           = new PdfContentByte(writer);

            // Image generated using System.Drawing and rendering
            System.Drawing.Bitmap bm         = new System.Drawing.Bitmap(code128.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
            iTextSharp.text.Image bmCoverted = iTextSharp.text.Image.GetInstance(bm, System.Drawing.Imaging.ImageFormat.Bmp);
            table.AddCell(bmCoverted);

            pdfToCreate.Open();

            // Image generated using iTextSharp.text.Image
            WriteLineToPdf("This is third row. Below is image generated using code128.CreateImageWithBarcode.", table, out tableout);
            table = tableout;
            iTextSharp.text.Image image128 = code128.CreateImageWithBarcode(cb, null, null);
            table.AddCell(image128);
            table = tableout;

            WriteLineToPdf("This is fifth row.", table, out tableout);
            pdfToCreate.Add(tableout);

            // Create new document with height that depends on number of lines in document.
            iTextSharp.text.Rectangle psFinal = new iTextSharp.text.Rectangle(200, 300);
            Document  pdfFinal = new Document(psFinal, 0, 0, 0, 0);
            PdfWriter writer1  = PdfWriter.GetInstance(pdfFinal, new FileStream(@"D:\\finalfile.pdf", FileMode.Create));

            pdfFinal.Open();
            pdfFinal.Add(tableout);

            cb = null;

            pdfToCreate.Close();
            pdfFinal.Close();
        }
Exemplo n.º 4
0
        public System.Drawing.Image GerarBarcode(string code)
        {
            Barcode128 bc = new Barcode128();

            bc.Code = code;
            //bc.Font = null;

            return(bc.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
        }
Exemplo n.º 5
0
        public System.Drawing.Image codigob(string codigo, Boolean Contexto = false, Single alto = 0, String texto = "")
        {
            Barcode128 barcode = new Barcode128();

            barcode.StartStopText = true;
            if (alto != 0)
            {
                barcode.BarHeight = alto;
            }


            barcode.Code         = codigo;
            barcode.ChecksumText = true;
            barcode.CodeType     = BarcodeEANSUPP.UPCA;

            try
            {
                String letras;
                letras = codigo + "\n" + texto;
                Size talla = new Size();
                talla.Width  = 200;
                talla.Height = 75;
                Bitmap bm = new Bitmap(barcode.CreateDrawingImage(Color.Black, Color.White), talla);
                System.Drawing.Image bmt = new Bitmap(bm.Width, bm.Height + 14);
                Graphics             g   = Graphics.FromImage(bmt);
                SolidBrush           bru = new SolidBrush(Color.White);
                g.FillRectangle(bru, 0, 0, bm.Width, bm.Height + 14);
                System.Drawing.Font PintarTexto = new System.Drawing.Font("arial", 10);
                SolidBrush          brocha      = new SolidBrush(Color.Black);
                SizeF stringsize;
                stringsize = g.MeasureString(codigo, PintarTexto);
                float centrox;
                centrox = (bm.Width - stringsize.Width) / 2;
                float x;
                float y;
                x = centrox;
                y = bm.Height;
                StringFormat drawformat = new StringFormat();
                drawformat.FormatFlags = StringFormatFlags.NoWrap;
                g.DrawImage(bm, 0, 0);
                string ncode = codigo.Substring(1, codigo.Length - 2);
                g.DrawString(codigo, PintarTexto, brocha, x, y, drawformat);
                return(bmt);
            }
            catch (Exception ex)
            {
                throw new Exception("Error al genera el codigo:" + ex.ToString());
            }
        }
Exemplo n.º 6
0
 public System.Drawing.Bitmap GenerarBarcode(string prodCode)
 {
     if (prodCode.Length > 0)
     {
         Barcode128 code128 = new Barcode128();
         code128.CodeType         = Barcode.CODE128;
         code128.ChecksumText     = true;
         code128.GenerateChecksum = true;
         code128.StartStopText    = true;
         code128.Code             = prodCode;
         System.Drawing.Bitmap bm = new System.Drawing.Bitmap(code128.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
         return(bm);
     }
     return(null);
 }
Exemplo n.º 7
0
        private void BarcodeGenerator(string id)
        {
            string prodCode = id;

            //context.Response.ContentType = "image/gif";
            if (prodCode.Length > 0)
            {
                Barcode128 code128 = new Barcode128();
                code128.CodeType         = Barcode.CODE128;
                code128.ChecksumText     = true;
                code128.GenerateChecksum = true;
                code128.Code             = prodCode;
                System.Drawing.Bitmap bm = new System.Drawing.Bitmap(code128.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
                bm.Save(HttpContext.Current.Server.MapPath("~/PDF/" + id + ".gif"), System.Drawing.Imaging.ImageFormat.Gif);
            }
        }
Exemplo n.º 8
0
        public static Bitmap Codigos128(string _Code, Boolean vertexto = false, Single Height = 0)
        {
            Barcode128 barcode = new Barcode128();

            if (Height != 0)
            {
                barcode.BarHeight = Height;
            }

            barcode.Code = _Code;
            try
            {
                Bitmap bm = new Bitmap(barcode.CreateDrawingImage(Color.Black, Color.White));
                if (vertexto == false)
                {
                    return(bm);
                }
                else
                {
                    Bitmap   bmT = new Bitmap(bm.Width, bm.Height + 14);
                    Graphics g   = Graphics.FromImage(bmT);
                    g.FillRectangle(new SolidBrush(Color.White), 0, 0, bm.Width, bm.Height + 14);

                    Font       pintarTexto = new Font("Arial", 8);
                    SolidBrush brocha      = new SolidBrush(Color.Black);

                    SizeF stringSize = new SizeF();
                    stringSize = g.MeasureString(_Code, pintarTexto);
                    Single centrox = (bm.Width - stringSize.Width) / 2;
                    Single x       = centrox;
                    Single y       = bm.Height;

                    StringFormat drawformat = new StringFormat();
                    drawformat.FormatFlags = StringFormatFlags.NoWrap;
                    g.DrawImage(bm, 0, 0);

                    String ncode = _Code.Substring(0, _Code.Length);
                    g.DrawString(ncode, pintarTexto, brocha, x, y, drawformat);
                    return(bmT);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error al generar el codigo" + ex.ToString());
            }
        }
Exemplo n.º 9
0
    /// <summary>
    /// this version outputs gif to web page
    /// ProcessRequest is intrinsic function of hppthandler, do not change the name
    /// </summary>
    /// <param name="context"></param>
    public void ProcessRequest(HttpContext context)
    {
        //for a custom httphandler make sure it's referenced in web.config in httpHandlers
        //<add verb="GET" path="*barcode.gif" type="barcode_handler" validate ="false" />
        //
        if (context.Request["code"] != null)
        {
            string _code = wwi_security.DecryptString(context.Request["code"].ToString(), "publiship"); //code to use
            int    _wd   = 120;                                                                         //context.Request["wd"] != null ? wwi_func.vint(context.Request["wd"].ToString()) : 120; //width
            int    _ht   = 30;                                                                          //context.Request["ht"] != null ? wwi_func.vint(context.Request["ht"].ToString()) : 30; //height

            Barcode128 _bc = new Barcode128();
            _bc.CodeType         = Barcode.CODE128;
            _bc.ChecksumText     = true;
            _bc.GenerateChecksum = true;
            _bc.Code             = _code;

            //draws directly to web page with no code underneath bar
            //System.Drawing.Bitmap _bm = new System.Drawing.Bitmap(_bc.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
            //_bm.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);

            //draws with actual code underneath bar
            //create bitmap from System.Drawing library, add some height for actual code underneath
            Bitmap _bm = new Bitmap(_wd, _ht + 10);
            //provide this, else the background will be black by default
            Graphics _gr = Graphics.FromImage(_bm);

            _gr.PageUnit = GraphicsUnit.Pixel;
            _gr.Clear(Color.White);
            //draw the barcode
            _gr.DrawImage(_bc.CreateDrawingImage(Color.Black, System.Drawing.Color.White), new Point(0, 0));
            //place text underneath - if you want the placement to be dynamic, calculate the point based on size of the image
            System.Drawing.Font _ft = new System.Drawing.Font("Arial", 8, FontStyle.Regular);
            SizeF _sz = _gr.MeasureString(_code, _ft);
            //position text
            _wd = (_wd - (int)_sz.Width) / 2;

            StringFormat _sf = new StringFormat();
            _sf.Alignment     = StringAlignment.Center;
            _sf.LineAlignment = StringAlignment.Center;

            _gr.DrawString(_code, _ft, SystemBrushes.WindowText, _wd, _ht, _sf);
            //output as gif to web page,  can also save it to external file
            _bm.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
        }//end if
    }
Exemplo n.º 10
0
        public ActionResult AfterRegistration()
        {
            User       us    = (User)TempData["User"];
            string     stb2  = "";
            Barcode128 code2 = new Barcode128();

            code2.CodeType         = Barcode.CODE128_UCC;
            code2.ChecksumText     = true;
            code2.GenerateChecksum = true;
            code2.StartStopText    = true;
            code2.Code             = stb2;

            System.Drawing.Bitmap bm2 = new System.Drawing.Bitmap(code2.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));

            ViewBag.UserId = us.UserId;

            bm2.Save(Server.MapPath("~/Template/barcode" + us.UserId + ".gif"), System.Drawing.Imaging.ImageFormat.Gif);
            return(View());
        }
Exemplo n.º 11
0
        public static Bitmap CodigosBarra(string _Code, Single Height = 0)
        {
            Barcode128 uccEan128 = new Barcode128();

            uccEan128.CodeType = Barcode.CODE128;
            if (Height != 0)
            {
                uccEan128.BarHeight = 10;
            }
            uccEan128.Code = _Code;
            try
            {
                Bitmap bm = new Bitmap(uccEan128.CreateDrawingImage(Color.Black, Color.White));
                return(bm);
            }
            catch (Exception ex)
            {
                throw new Exception("Error al generar el codigo" + ex.ToString());
            }
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            string prodCode = "123456";

            //context.Response.ContentType = "image/gif";
            if (prodCode.Length > 0)
            {
                Barcode128 code128 = new Barcode128();
                code128.CodeType         = Barcode.CODE128;
                code128.ChecksumText     = true;
                code128.GenerateChecksum = true;
                code128.Code             = prodCode;
                code128.AltText          = prodCode;
                code128.GenerateChecksum = true;



                System.Drawing.Bitmap bm = new System.Drawing.Bitmap(code128.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
                bm.Save(@"E:\Praveen\Barcodes\" + Guid.NewGuid() + ".png");
            }
        }
Exemplo n.º 13
0
        private void btn_add_prod_Click(object sender, RoutedEventArgs e)    // Tuotteen lisäys nappulan koodit
        {
            Random rnd            = new Random();                            // Random num generaattori
            string random_barcode = rnd.Next(10000000, 99999999).ToString(); // Tehdään barcode random numerolla

            // Luodaan barcode
            Barcode128 code128 = new Barcode128();

            code128.CodeType = Barcode.CODE128_UCC;
            code128.Code     = random_barcode;

            // Generoidaan barcode png image /barcodes hakemistoon
            System.Drawing.Bitmap barcode = new System.Drawing.Bitmap(code128.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White)); // Mustaa valkoiselle
            barcode.Save("barcodes/" + random_barcode + ".png");                                                                                           // Tallennetaan /barcodes hakemistoon

            // Ihan samat SQL Connectionit kun aina.
            string           dbConnectionString = @"Data Source=database.db;Version=3;";
            SQLiteConnection sqliteCon          = new SQLiteConnection(dbConnectionString);

            if (tb_name_update.Text != "" && tb_brand_update.Text != "" && tb_qty_update.Text != "")    // Jos nimi, brändi ja määrä kentät EIvät ole tyhjiä niin eteenpäin. (Muuten tulee vähän huono tuotemerkintä.)
            {
                try
                {
                    sqliteCon.Open();
                    string Query = "INSERT INTO products (name, brand, price, qty, desc, barcode) VALUES('" + this.tb_name_update.Text + "','" + this.tb_brand_update.Text + "','" + this.tb_price_update.Text + "','" + this.tb_qty_update.Text + "','" + this.tb_desc_update.Text + "','" + random_barcode + "') ";

                    SQLiteCommand createCommand = new SQLiteCommand(Query, sqliteCon);
                    createCommand.ExecuteNonQuery();

                    sqliteCon.Close();                                                  // Sinne vaan pusketaan tiedot taas tietokantaan ja näytetään käyttäjälle ilmoitus ja suljetaan db-yhteys.
                    MessageBox.Show("Product added successfully!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                // Kun tiedot on uploadattu niin päivitetäänpä samalla vaivalla datagrid niin ei pysyy käyttäjäkin ajan tasalla.
                updateGrid();
            }
        }
Exemplo n.º 14
0
        public void ProcessRequest(HttpContext context)
        {
            string prodCode = context.Request.QueryString.Get("code");
            var    w        = context.Request.QueryString.Get("w");
            var    h        = context.Request.QueryString.Get("h");
            int    width    = 320;
            int    height   = 100;

            if (w != null)
            {
                try { width = Convert.ToInt32(w); } catch { width = 320; }
            }
            if (h != null)
            {
                try { height = Convert.ToInt32(h); } catch { height = 100; }
            }

            var filename = context.Request.Url.Segments.Last().Replace(".barcode", "").Replace(".Barcode", "").Replace(".BARCODE", "");

            context.Response.ContentType = "image/png";
            if (prodCode.Length > 0)
            {
                if (prodCode.Length > Global.Library.Settings.AssetNumberLength)
                {
                    prodCode = prodCode.Substring(0, Global.Library.Settings.AssetNumberLength);
                }
                Barcode128 code128 = new Barcode128();
                code128.CodeType         = Barcode.CODE128;
                code128.ChecksumText     = true;
                code128.GenerateChecksum = true;
                code128.StartStopText    = true;
                code128.Code             = prodCode;
                System.Drawing.Bitmap bm = new System.Drawing.Bitmap(code128.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
                Bitmap resized           = new Bitmap(bm, new Size(width, height));

                resized.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);
            }
        }
Exemplo n.º 15
0
Arquivo: NFe.cs Projeto: ertprs/Estudo
        private static byte[] GetBarCode(string texto)
        {
            if (String.IsNullOrEmpty(texto))
            {
                return(null);
            }

            Barcode128 barCode = new Barcode128();

            barCode.CodeType         = Barcode128.CODE_C;
            barCode.ChecksumText     = true;
            barCode.GenerateChecksum = true;
            barCode.StartStopText    = true;
            barCode.BarHeight        = 60;
            barCode.Code             = texto.Replace(" ", ""); //"31090807301671000131550010001000200905000585"

            System.Drawing.Image image = barCode.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White);

            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
            {
                image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                return(ms.ToArray());
            }
        }
Exemplo n.º 16
0
        private void frmCLS_dathu_Load(object sender, EventArgs e)
        {
            //rptCLS rpt = new rptCLS();
            string    MaPhieuCLS = "";
            string    TenNhom    = "";
            string    sql        = @"SELECT	 
		                DOITUONG=(CASE WHEN DKK.LOAIKHAMID<>1 THEN NULL ELSE (CASE WHEN DKK.LOAIKHAMID=1 AND  ISNULL(B.ISSUDUNGCHOBH,0)=1  AND  ISNULL(A.ISBHYT_SAVE,0)=1 THEN N'BHYT' ELSE N'DỊCH VỤ' END) END)             
		                        ,TENCHIDINH= case when isnull(a.ghichu,'')<> '' then B.TENDICHVU +' ('+ a.ghichu +')' else B.TENDICHVU end
		                        ,SL=ISNULL(A.SOLUONG,0)
		                        ,CHANDOAN=ISNULL(C.CHANDOANBANDAU,DBO.[nvk_ListMoTaChanDoan_1KhamBenh](C.IDKHAMBENH))
		                        ,C.MAPHIEUKHAM
		                        ,C.NGAYKHAM
                                ,E.TENPHONGKHAMBENH
                                ,TENNHOM='(' + REPLACE( TENNHOMCD,N'DỊCH VỤ',N'DỊCH VỤ KỸ THUẬT') + (CASE WHEN DKK.LOAIKHAMID<>1 THEN  ''   ELSE ( CASE WHEN ISNULL(B.ISSUDUNGCHOBH,0)=1  AND  ISNULL(A.ISBHYT_SAVE,0)=1 THEN N'-BHYT' ELSE N'-DỊCH VỤ' END ) END )+')'
                                ,HOTENBS=G.TENBACSI
                                ,MaVach=CONVERT(IMAGE,NULL)
                                ,SH.MACH
                                ,SH.HUYETAP1
                                ,SH.HUYETAP2
                                ,nvk_phong= (CASE WHEN ISNULL(C.PHONGID,0)<>0 THEN DBO.HS_TENPHONG(C.PHONGID) ELSE    isnull(
								    (select top 1 tenphong from benhnhannoitru nn inner join kb_phong pp on pp.id=nn.idphongnoitru  where idchitietdangkykham =c.idchitietdangkykham order by ngayvaovien desc)
								    ,0
								        ) END)
                                ,c.idphongkhambenh,c.idchitietdangkykham
                                ,A.MAPHIEUCLS
								,d.tenbenhnhan
								,(CASE WHEN d.gioiTinh='0' THEN 'Nam' ELSE N'Nữ' END) as gioitinh
								,d.ngaysinh
								,d.diachi
								,bhyt.sobhyt
								,dkk.LoaiKhamID
								,CONVERT(varchar,bhyt.ngaybatdau,103) as ngaybatdau
								,CONVERT(varchar,bhyt.ngayhethan,103) as ngayhethan
								,ndk.TENNOIDANGKY 
                                ,bhyt.IsDungTuyen
								,bhyt.IsCapCuu
                                ,ngt.TENNOIDANGKY as NoiGT
                        FROM KHAMBENHCANLAMSAN A
                        LEFT JOIN BANGGIADICHVU B ON A.IDCANLAMSAN=B.IDBANGGIADICHVU
                        LEFT JOIN KHAMBENH C ON A.IDKHAMBENH=C.IDKHAMBENH
                        LEFT JOIN DANGKYKHAM DKK ON C.IDDANGKYKHAM=DKK.IDDANGKYKHAM
						left join BENHNHAN_BHYT bhyt on bhyt.IDBENHNHAN_BH=dkk.IDBENHNHAN_BH
						left join KB_NOIDANGKYKB ndk on ndk.IDNOIDANGKY=bhyt.IdNoiDangKyBH
                        left join KB_NOIDANGKYKB ngt on ngt.IDNOIDANGKY=bhyt.IdNoiGioiThieu
                        LEFT JOIN BENHNHAN D ON C.IDBENHNHAN=D.IDBENHNHAN                       
                        LEFT JOIN PHONGKHAMBENH E ON E.IDPHONGKHAMBENH=ISNULL(C.IDKHOA,C.IDPHONGKHAMBENH)
                        LEFT JOIN PHONGKHAMBENH F ON F.IDPHONGKHAMBENH=B.IDPHONGKHAMBENH 
                        LEFT JOIN BACSI G ON C.IDBACSI=G.IDBACSI
                        LEFT JOIN SINHHIEU SH ON C.IDKHAMBENH=SH.IDKHAMBENH
                     WHERE  ISNULL(A.dahuy,0)=0 and ISNULL(A.dathu,0)=1 AND  A.IDKHAMBENH='" + Truyendulieu.idkhambenh + "'";
            DataTable dtmavach   = DataAcess.Connect.GetTable(sql);

            if (dtmavach == null || dtmavach.Rows.Count == 0)
            {
                MessageBox.Show("Không tìm thấy bệnh nhân");
                return;
            }
            else
            {
                MaPhieuCLS = dtmavach.Rows[0]["MAPHIEUCLS"].ToString();
                for (int i = 0; i < dtmavach.Rows.Count; i++)
                {
                    TenNhom = dtmavach.Rows[i]["TenNhom"].ToString();
                }
                KhamBenhPro.rptCLS crystalReport = new KhamBenhPro.rptCLS();
                #region ma vach
                Barcode128 barcode = new Barcode128();
                barcode.ChecksumText = false;
                barcode.Code         = MaPhieuCLS;
                //barcode.Code = MaPhieuCLS.Replace("PT", "").Replace("-", "").Replace("CT", "") + "";
                System.Drawing.Image bmp = barcode.CreateDrawingImage(Color.Black, Color.White);
                Byte[] arrByte           = (Byte[])TypeDescriptor.GetConverter(bmp).ConvertTo(bmp, typeof(Byte[]));
                for (int k = 0; k < dtmavach.Rows.Count; k++)
                {
                    dtmavach.Rows[k]["MaVach"] = arrByte;
                }
                #endregion
                string   TenBenhNhan = dtmavach.Rows[0]["tenbenhnhan"].ToString();
                string   gioitinh    = dtmavach.Rows[0]["gioitinh"].ToString();
                string   NamSinh     = dtmavach.Rows[0]["ngaysinh"].ToString();
                string   DiaChi      = dtmavach.Rows[0]["diachi"].ToString();
                string   MaTheBHYT   = dtmavach.Rows[0]["sobhyt"].ToString();
                string   PhongCD     = dtmavach.Rows[0]["nvk_phong"].ToString();
                string   KhoaCD      = dtmavach.Rows[0]["TENPHONGKHAMBENH"].ToString();
                DateTime NgayKham    = DateTime.Parse(dtmavach.Rows[0]["NgayKham"].ToString());
                string   Gioitinh    = dtmavach.Rows[0]["Gioitinh"].ToString();
                string   NgayBatdau  = dtmavach.Rows[0]["NgayBatdau"].ToString();
                string   NgayHethan  = dtmavach.Rows[0]["NgayHethan"].ToString();
                string   NoiDKbandau = dtmavach.Rows[0]["TENNOIDANGKY"].ToString();
                string   ChanDoan    = dtmavach.Rows[0]["ChanDoan"].ToString();
                string   NoiGT       = dtmavach.Rows[0]["NoiGT"].ToString();
                string   BacsiCD     = dtmavach.Rows[0]["HOTENBS"].ToString();
                // string isCapcuu=dtmavach.Rows[0]["IsCapCuu"].ToString();
                //string CoBHYT=dtmavach.Rows[0]["LoaiKhamID"].ToString();
                crystalReport.SetDataSource(dtmavach);
                crystalReport.SetParameterValue("MaPhieuCLS", MaPhieuCLS);
                crystalReport.SetParameterValue("TenNhom", TenNhom);
                crystalReport.SetParameterValue("TenBenhNhan", TenBenhNhan);
                crystalReport.SetParameterValue("NamSinh", NamSinh);
                crystalReport.SetParameterValue("DiaChi", DiaChi);
                crystalReport.SetParameterValue("MaTheBHYT", MaTheBHYT);
                crystalReport.SetParameterValue("PhongCD", PhongCD);
                crystalReport.SetParameterValue("KhoaCD", KhoaCD);
                if (dtmavach.Rows[0]["LoaikhamID"].ToString() == "1")
                {
                    crystalReport.SetParameterValue("CoBHYT", "a");
                }
                else
                {
                    crystalReport.SetParameterValue("CoBHYT", "");
                }
                crystalReport.SetParameterValue("NgayKham", "Ngày " + NgayKham.ToString("dd") + " tháng " + NgayKham.ToString("MM") + " năm " + NgayKham.ToString("yyyy") + "");
                crystalReport.SetParameterValue("Gioitinh", Gioitinh);
                crystalReport.SetParameterValue("NgayBatdau", NgayBatdau);
                crystalReport.SetParameterValue("NgayHethan", NgayHethan);
                crystalReport.SetParameterValue("NoiDKbandau", NoiDKbandau);
                crystalReport.SetParameterValue("ChanDoan", ChanDoan);
                if (dtmavach.Rows[0]["IsDungTuyen"].ToString() == "1" || dtmavach.Rows[0]["IsDungTuyen"].ToString().ToLower() == "true" || dtmavach.Rows[0]["IsDungTuyen"].ToString().ToLower() == "y")
                {
                    crystalReport.SetParameterValue("Dungtuyen", "a");
                }
                else
                {
                    crystalReport.SetParameterValue("Dungtuyen", "");
                }

                if (dtmavach.Rows[0]["iscapcuu"].ToString() == "1" || dtmavach.Rows[0]["iscapcuu"].ToString().ToLower() == "true")
                {
                    crystalReport.SetParameterValue("isCapcuu", "a");
                }
                else
                {
                    crystalReport.SetParameterValue("isCapcuu", "");
                }
                crystalReport.SetParameterValue("NoiGT", NoiGT);
                crystalReport.SetParameterValue("BacsiCD", BacsiCD);
                rptviewdathu.ReportSource = crystalReport;
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 获取条码图片
        /// </summary>
        /// <param name="content">条码内容</param>
        /// <param name="type">编码类型</param>
        /// <param name="height">高度(磅)</param>
        /// <param name="unit">单位宽度(磅)</param>
        /// <param name="fore">前景色/条码颜色</param>
        /// <param name="back">背景色</param>
        /// <returns>条码Image</returns>
        public static Image getBarcode(string content, BarcodeType type, float height, float unit, Color fore, Color back)
        {
            if (content.isNull())
            {
                content = "1234567";
            }
            try
            {
                var test = Convert.ToInt64(content);
                if (test < 0)
                {
                    content = "1234567";
                }
            }
            catch { content = "1234567"; }
            Image img = null;

            if (fore.A == 0)
            {
                fore = Color.Black;
            }
            if (back.A == 0)
            {
                back = Color.White;
            }
            try
            {
                switch (type)
                {
                case BarcodeType.Code39:
                default:
                    Barcode39 code39 = new Barcode39();
                    code39.BarHeight = height;
                    code39.Code      = content;
                    if (unit > 0)
                    {
                        code39.N = unit;
                    }
                    img = code39.CreateDrawingImage(fore, back);
                    break;

                case BarcodeType.Code128:
                    Barcode128 code128 = new Barcode128();
                    code128.BarHeight = height;
                    code128.Code      = content;
                    if (unit > 0)
                    {
                        code128.N = unit;
                    }
                    code128.CodeType = Barcode.CODE128;
                    img = code128.CreateDrawingImage(fore, back);
                    break;

                case BarcodeType.Inter25:
                    BarcodeInter25 codeInter25 = new BarcodeInter25();
                    codeInter25.BarHeight = height;
                    codeInter25.Code      = content;
                    if (unit > 0)
                    {
                        codeInter25.N = unit;
                    }
                    img = codeInter25.CreateDrawingImage(fore, back);
                    break;

                case BarcodeType.Postnet:
                    BarcodePostnet codePostnet = new BarcodePostnet();
                    codePostnet.BarHeight = height;
                    codePostnet.Code      = content;
                    if (unit > 0)
                    {
                        codePostnet.N = unit;
                    }
                    img = codePostnet.CreateDrawingImage(fore, back);
                    break;

                case BarcodeType.CodeBar:
                    BarcodeCodabar codeCodeBar = new BarcodeCodabar();
                    codeCodeBar.BarHeight = height;
                    codeCodeBar.Code      = "A" + content + "A";
                    if (unit > 0)
                    {
                        codeCodeBar.N = unit;
                    }
                    img = codeCodeBar.CreateDrawingImage(fore, back);
                    break;
                }
            }
            catch { }
            return(img);
        }
Exemplo n.º 18
0
        public async Task <ActionResult> RegisterForm(ExpoUser expoUser)
        {
            int    statusCode;
            string message;

            if (ModelState.IsValid)
            {
                using (_db)
                {
                    try
                    {
                        string path;
                        LiteCollection <ExpoUser> liteCollection = _db.GetCollection <ExpoUser>("ExpoUser");
                        ExpoUser findedExpoUser = liteCollection.FindOne(f => f.UserName == expoUser.UserName && f.UserEmail == expoUser.UserEmail && f.UserPhoneNumber == expoUser.UserPhoneNumber);
                        if (findedExpoUser != null)
                        {
                            path = Server.MapPath("/Template/barcode-" + findedExpoUser.Id + ".gif");
                            if (!System.IO.File.Exists(path))
                            {
                                liteCollection.Delete(findedExpoUser.Id);
                            }
                            else
                            {
                                await findedExpoUser.SendMessageAsync(path);

                                return(RedirectToAction("UserRegistrationInfo", "User", new { expoUserId = findedExpoUser.Id }));
                            }
                        }
                        Guid userIdGuid = Guid.NewGuid();
                        expoUser.Id = userIdGuid;
                        expoUser.DateOfRegistration = DateTime.Now;
                        expoUser.DateOfVisiting     = null;
                        Barcode128 code2 = new Barcode128
                        {
                            CodeType         = Barcode.CODE128_UCC,
                            ChecksumText     = true,
                            GenerateChecksum = true,
                            StartStopText    = true,
                            Code             = userIdGuid.ToString()
                        };

                        System.Drawing.Bitmap bm2 = new System.Drawing.Bitmap(code2.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
                        path = Server.MapPath("/Template/barcode-" + expoUser.Id + ".gif");
                        bm2.Save(path, System.Drawing.Imaging.ImageFormat.Gif);

                        liteCollection.Insert(expoUser);
                        liteCollection.EnsureIndex(e => e.Id);
                        await expoUser.SendMessageAsync(path);

                        return(RedirectToAction("UserRegistrationInfo", "User", new { expoUserId = expoUser.Id }));
                    }
                    catch (Exception e)
                    {
                        statusCode = 2;
                        message    = e.ToString();
                    }
                }
            }
            else
            {
                statusCode = 1;
                message    = "Данные пришли пустыми";
            }
            return(RedirectToAction("Register", "User", new { statusCode, message }));
        }
Exemplo n.º 19
0
 private byte[] RetornarArrayBytesTemplate(List <DadosImagem> imagens)
 {
     using (MemoryStream memoryStream = new MemoryStream())
     {
         PdfStamper pdfStamper = new PdfStamper(new PdfReader(this.Template.Caminho), (Stream)memoryStream);
         AcroFields acroFields = pdfStamper.AcroFields;
         foreach (KeyValuePair <string, string> parametro in this.Template.Parametros)
         {
             acroFields.SetField(parametro.Key, parametro.Value);
         }
         foreach (DadosImagem imagen in imagens)
         {
             if (imagen.Barcode)
             {
                 Barcode128 barcode128 = new Barcode128();
                 barcode128.Code = imagen.AtributosImagem;
                 iTextSharp.text.Image instance = iTextSharp.text.Image.GetInstance(barcode128.CreateDrawingImage(Color.Black, Color.White), BaseColor.White);
                 pdfStamper.GetOverContent(1).AddImage(instance, (float)Convert.ToInt32((double)instance.Width * 0.98), 0.0f, 0.0f, instance.Height, 25f, 445f);
             }
             else
             {
                 iTextSharp.text.Image instance = iTextSharp.text.Image.GetInstance(imagen.Imagem, BaseColor.White);
                 pdfStamper.GetOverContent(1).AddImage(instance, instance.Width, 0.0f, 0.0f, instance.Height, (float)imagen.PosicaoVertical, (float)imagen.PosicaoHorizontal);
             }
         }
         pdfStamper.FormFlattening = true;
         pdfStamper.Close();
         return(memoryStream.ToArray());
     }
 }
Exemplo n.º 20
0
        private void frmToaThuocBH_Load(object sender, EventArgs e)
        {
            string idkhambenh = GetIdkhambenh();
            string MaBN       = "";

            KhamBenhPro.rptToaThuocBH crystalReport2 = new KhamBenhPro.rptToaThuocBH();
            #region subReportCLS

            if (idkhambenh == null || idkhambenh == "" || idkhambenh == "0")
            {
                return;
            }

            DataTable dtCLS = loadDV(idkhambenh);
            if (dtCLS != null)
            {
                dtCLS.TableName = "dtSubCLS";
                crystalReport2.OpenSubreport("rptSubReportCLS.rpt").SetDataSource(dtCLS);
            }
            else
            {
                return;
            }
            #endregion

            DataTable dtsrc     = dtSource(idkhambenh);
            DateTime  Ngayratoa = DateTime.Now;
            if (dtsrc.Rows[0]["ngayratoa"].ToString() != "" || dtsrc.Rows[0]["ngayratoa"].ToString() != "")
            {
                Ngayratoa = DateTime.Parse(dtsrc.Rows[0]["ngayratoa"].ToString());
            }

            if (dtsrc == null)
            {
                MessageBox.Show("Không có toa thuốc bảo hiểm");
            }
            else
            {
                dtsrc.TableName = "dtThuoc";
                DataSet ds = new DataSet();
                ds.Tables.Add(dtsrc);
                MaBN = dtsrc.Rows[0]["mabenhnhan"].ToString();
                #region ma vach
                Barcode128 barcode = new Barcode128();
                barcode.ChecksumText = false;
                barcode.Code         = MaBN;
                //barcode.Code = MaPhieuCLS.Replace("PT", "").Replace("-", "").Replace("CT", "") + "";
                System.Drawing.Image bmp = barcode.CreateDrawingImage(Color.Black, Color.White);
                Byte[] arrByte           = (Byte[])TypeDescriptor.GetConverter(bmp).ConvertTo(bmp, typeof(Byte[]));
                for (int k = 0; k < dtsrc.Rows.Count; k++)
                {
                    dtsrc.Rows[k]["MaVach"] = arrByte;
                }
                #endregion
                crystalReport2.SetDataSource(ds);
                crystalReport2.SetParameterValue("TenBacsi", dtsrc.Rows[0]["tenbacsi"].ToString());
                crystalReport2.SetParameterValue("MaBenhNhan", dtsrc.Rows[0]["mabenhnhan"].ToString());
                crystalReport2.SetParameterValue("TuoiBN", dtsrc.Rows[0]["TuoiBN"].ToString());
                crystalReport2.SetParameterValue("CanNang", dtsrc.Rows[0]["cannang"].ToString());
                crystalReport2.SetParameterValue("HuyetAp1", dtsrc.Rows[0]["huyetap1"].ToString());
                crystalReport2.SetParameterValue("HuyetAp2", dtsrc.Rows[0]["huyetap2"].ToString());
                if (dtsrc.Rows[0]["NguoiGiamHo"].ToString() == "")
                {
                    crystalReport2.SetParameterValue("TenNguoiGiamHo", "");
                }
                else
                {
                    crystalReport2.SetParameterValue("TenNguoiGiamHo", "- Tên bố hoặc mẹ của trẻ hoặc người đưa trẻ đến khám bệnh, chữa bệnh :" + dtsrc.Rows[0]["NguoiGiamHo"].ToString());
                }
                crystalReport2.SetParameterValue("Mach", dtsrc.Rows[0]["mach"].ToString());
                crystalReport2.SetParameterValue("GhiChu", dtsrc.Rows[0]["GhiChu"].ToString());
                crystalReport2.SetParameterValue("LoiDan", dtsrc.Rows[0]["loidan"].ToString());
                //for (int i = 0; i < dtsrc.Rows.Count - 1; i++)
                //{
                //    crystalReport2.SetParameterValue("CachDung", dtsrc.Rows[i]["CachDung"].ToString());
                //}
                crystalReport2.SetParameterValue("NgayKham", "Ngày " + Ngayratoa.ToString("dd") + " tháng " + Ngayratoa.ToString("MM") + " năm " + Ngayratoa.ToString("yyyy") + "");

                nvk_SetPara_HanhChinh(dtsrc.Rows[0]["idbenhnhan"].ToString(), dtsrc.Rows[0]["idchitietdangkykham"].ToString(), idkhambenh, crystalReport2);
                crystalReportViewer2.ReportSource = crystalReport2;
            }
        }
Exemplo n.º 21
0
        private void frmBV01_Load(object sender, EventArgs e)
        {
            string Ma_LK = "";

            KhamBenhPro.rptBV01 crystalReport4 = new KhamBenhPro.rptBV01();
            DataTable           dt             = hs_tinhtien.dtSource_BV(Truyendulieu.idphieutt);


            DateTime ngayravien  = DateTime.Parse(dt.Rows[0]["NgayTinhBH_Thuc"].ToString());
            DateTime ngayvaovien = DateTime.Parse(dt.Rows[0]["NgayTinhBH"].ToString());

            bool IsCapCuu    = (hs_tinhtien.IsCheck(dt.Rows[0]["IsCapCuu"].ToString()) ? true : false);
            bool IsDungTuyen = (dt.Rows[0]["DUNGTUYEN"].ToString().ToUpper() == "Y" || hs_tinhtien.IsCheck(dt.Rows[0]["IsDungTuyen"].ToString()));
            bool IsTraiTuyen = (!IsCapCuu && !IsDungTuyen);


            string IsNoiTru               = (hs_tinhtien.IsCheck(dt.Rows[0]["IsNoiTru"].ToString()) ? "1" : "0");
            double TongTienBNPT_BV        = double.Parse(dt.Rows[0]["TongTienBNPT"].ToString() == "" ? "0" : dt.Rows[0]["TongTienBNPT"].ToString());
            double TONGTIEN_DATRA_BV      = double.Parse(dt.Rows[0]["TONGTIEN_DATRA"].ToString() == "" ? "0" : dt.Rows[0]["TONGTIEN_DATRA"].ToString());
            double TongTien_ConLai        = TongTienBNPT_BV - TONGTIEN_DATRA_BV;
            string SoTienHoanTra          = "";
            string SoTienThuThem          = "";
            bool   IsKhamBenh_bool        = (IsNoiTru != "1" && (dt.Rows[0]["ID_KHOA_VIEW"].ToString() == "1" || dt.Rows[0]["ID_KHOA_VIEW"].ToString() == "3") ? true : false);
            bool   IsNoiTru_bool          = (IsNoiTru == "1" ? true : false);
            bool   IsDieuTriNgoaiTru_bool = (!IsKhamBenh_bool && !IsNoiTru_bool);
            double THANHTIENDV_total      = 0;
            double THANHTIEN_total        = 0;
            double BNTRA_total            = 0;
            double QUYBHYT_total          = 0;
            double BN_TU_TRA_total        = 0;
            double TongChiPhi_total       = 0;
            double TongTienBNPT_total     = 0;
            float  TongChiPhi1            = 0;

            DataSet   dsDetail = hs_tinhtien.dtSourceDetail_BV(Truyendulieu.idphieutt, IsNoiTru_bool, dt.Rows[0]["ngaytrinhthe1"].ToString(), dt.Rows[0]["ngaytrinhthe2"].ToString(), dt.Rows[0]["idbenhnhan_bh1"].ToString(), dt.Rows[0]["idbenhnhan_bh2"].ToString());
            DataTable dtDetail = dsDetail.Tables[0].Copy();

            if (dtDetail == null)
            {
                MessageBox.Show("Không có BV01");
            }
            else
            {
                Ma_LK = dt.Rows[0]["Ma_LK"].ToString();
                #region ma vach
                Barcode128 barcode = new Barcode128();
                barcode.ChecksumText = false;
                barcode.Code         = Ma_LK;
                //barcode.Code = MaPhieuCLS.Replace("PT", "").Replace("-", "").Replace("CT", "") + "";
                System.Drawing.Image bmp = barcode.CreateDrawingImage(Color.Black, Color.White);
                Byte[] arrByte           = (Byte[])TypeDescriptor.GetConverter(bmp).ConvertTo(bmp, typeof(Byte[]));
                for (int k = 0; k < dt.Rows.Count; k++)
                {
                    dtDetail.Rows[k]["MaVach"] = arrByte;
                }
                #endregion
                dtDetail.TableName = "dtBangKeChiPhi";
                dsDetail.Tables.Add(dtDetail);
                crystalReport4.SetDataSource(dsDetail);
                string idbenhnhan_bh_clause = "";
                object THANHTIENDV = dtDetail.Compute("SUM(THANHTIENDV)", idbenhnhan_bh_clause); string s_THANHTIENDV = (THANHTIENDV == null ? "" : (THANHTIENDV.ToString() == "0" ? "" : hs_tinhtien.FormatSNumberToPrint(THANHTIENDV.ToString())));
                object THANHTIEN = dtDetail.Compute("SUM(THANHTIEN)", idbenhnhan_bh_clause); string s_THANHTIEN = (THANHTIEN == null ? "" : (THANHTIEN.ToString() == "0" ? "" : hs_tinhtien.FormatSNumberToPrint(THANHTIEN.ToString())));
                object BNTRA = dtDetail.Compute("SUM(BNTRA)", idbenhnhan_bh_clause); string s_BNTRA = (BNTRA == null ? "" : (BNTRA.ToString() == "0" ? "" : hs_tinhtien.FormatSNumberToPrint(BNTRA.ToString())));
                object QUYBHYT = dtDetail.Compute("SUM(QUYBHYT)", idbenhnhan_bh_clause); string s_QUYBHYT = (QUYBHYT == null ? "" : (QUYBHYT.ToString() == "0" ? "" : hs_tinhtien.FormatSNumberToPrint(QUYBHYT.ToString())));
                object BN_TU_TRA = dtDetail.Compute("SUM(NGUOIBENH)", idbenhnhan_bh_clause); string s_BN_TU_TRA = (BN_TU_TRA == null ? "" : (BN_TU_TRA.ToString() == "0" ? "" : hs_tinhtien.FormatSNumberToPrint(BN_TU_TRA.ToString())));
                double TongChiPhi   = double.Parse(s_THANHTIENDV == "" ? "0" : s_THANHTIENDV);
                double TongTienBNPT = double.Parse(s_BNTRA == "" ? "0" : s_BNTRA) + double.Parse(s_BN_TU_TRA == "" ? "0" : s_BN_TU_TRA);
                if (THANHTIENDV != null && THANHTIENDV.ToString() != "")
                {
                    THANHTIENDV_total += double.Parse(THANHTIENDV.ToString());
                }
                if (THANHTIEN != null && THANHTIEN.ToString() != "")
                {
                    THANHTIEN_total += double.Parse(THANHTIEN.ToString());
                }
                if (BNTRA != null && BNTRA.ToString() != "")
                {
                    BNTRA_total += double.Parse(BNTRA.ToString());
                }
                if (QUYBHYT != null && QUYBHYT.ToString() != "")
                {
                    QUYBHYT_total += double.Parse(QUYBHYT.ToString());
                }
                if (BN_TU_TRA != null && BN_TU_TRA.ToString() != "")
                {
                    BN_TU_TRA_total += double.Parse(BN_TU_TRA.ToString());
                }
                if (TongChiPhi != null && TongChiPhi.ToString() != "")
                {
                    TongChiPhi_total += double.Parse(TongChiPhi.ToString());
                }
                if (TongTienBNPT != null && TongTienBNPT.ToString() != "")
                {
                    TongTienBNPT_total += double.Parse(TongTienBNPT.ToString());
                }
                string s_THANHTIENDV_total = (THANHTIENDV_total == null ? "" : (THANHTIENDV_total.ToString() == "0" ? "" : hs_tinhtien.FormatSNumberToPrint(THANHTIENDV_total.ToString())));
                string s_THANHTIEN_total   = (THANHTIEN_total == null ? "" : (THANHTIEN_total.ToString() == "0" ? "" : hs_tinhtien.FormatSNumberToPrint(THANHTIEN_total.ToString())));
                string s_BNTRA_total       = (BNTRA_total == null ? "" : (BNTRA_total.ToString() == "0" ? "" : hs_tinhtien.FormatSNumberToPrint(BNTRA_total.ToString())));
                string s_QUYBHYT_total     = (QUYBHYT_total == null ? "" : (QUYBHYT_total.ToString() == "0" ? "" : hs_tinhtien.FormatSNumberToPrint(QUYBHYT_total.ToString())));
                string s_BN_TU_TRA_total   = (BN_TU_TRA_total == null ? "" : (BN_TU_TRA_total.ToString() == "0" ? "" : hs_tinhtien.FormatSNumberToPrint(BN_TU_TRA_total.ToString())));

                crystalReport4.SetParameterValue("thanhtiendvT", s_THANHTIENDV_total);
                crystalReport4.SetParameterValue("thanhtienbhT", s_THANHTIEN_total);
                crystalReport4.SetParameterValue("bntraT", s_BNTRA_total);
                crystalReport4.SetParameterValue("quybhytT", s_QUYBHYT_total);
                crystalReport4.SetParameterValue("nguoibenhT", s_BN_TU_TRA_total);

                crystalReport4.SetParameterValue("TenKhoa", dt.Rows[0]["TEN_KHOA_VIEW"].ToString());
                crystalReport4.SetParameterValue("MaKhoa", dt.Rows[0]["MA_KHOA_VIEW"].ToString());
                crystalReport4.SetParameterValue("MaBN", dt.Rows[0]["mabenhnhan"].ToString());
                crystalReport4.SetParameterValue("SoKB", dt.Rows[0]["id"].ToString());
                crystalReport4.SetParameterValue("HoTenBN", dt.Rows[0]["tenbenhnhan"].ToString());
                crystalReport4.SetParameterValue("NgaySinh", dt.Rows[0]["ngaysinh"].ToString());
                crystalReport4.SetParameterValue("GioiTinh", dt.Rows[0]["gioi_tinh"].ToString());
                crystalReport4.SetParameterValue("DiaChi", dt.Rows[0]["dia_chi"].ToString());
                crystalReport4.SetParameterValue("SoBHYT", dt.Rows[0]["ma_the"].ToString());
                crystalReport4.SetParameterValue("NgayBD", dt.Rows[0]["gt_the_tu"].ToString());
                crystalReport4.SetParameterValue("NgayHH", dt.Rows[0]["gt_the_den"].ToString());
                crystalReport4.SetParameterValue("NoiDKKCB", dt.Rows[0]["ten_dkbd"].ToString());
                crystalReport4.SetParameterValue("MaNoiDK", dt.Rows[0]["ma_dkbd"].ToString());
                crystalReport4.SetParameterValue("NgayKham", ngayvaovien.ToString("HH") + "  giờ, " + ngayvaovien.ToString("mm") + " phút, ngày " + ngayvaovien.ToString("dd/MM/yyyy"));
                crystalReport4.SetParameterValue("TGxuatvien", ngayravien.ToString("HH") + "   giờ,  " + ngayravien.ToString("mm") + "   phút, ngày   " + ngayravien.ToString("dd/MM/yyyy"));
                crystalReport4.SetParameterValue("SoNgayDT", dt.Rows[0]["SO_NGAY_DTRI"].ToString());
                crystalReport4.SetParameterValue("TTravien", dt.Rows[0]["tinh_trang_rv_BV"].ToString());
                if (IsCapCuu == true)
                {
                    crystalReport4.SetParameterValue("isCapcuu", "a");
                }
                else
                {
                    crystalReport4.SetParameterValue("isCapcuu", "");
                }
                if (IsDungTuyen == true)
                {
                    crystalReport4.SetParameterValue("IsDungTuyen", "a");
                }
                else
                {
                    crystalReport4.SetParameterValue("IsDungTuyen", "");
                }
                crystalReport4.SetParameterValue("ChanDoanXD", dt.Rows[0]["ten_benh"].ToString());
                crystalReport4.SetParameterValue("MaCDXD", dt.Rows[0]["MA_BENH"].ToString());
                crystalReport4.SetParameterValue("ChanDoanPH", dt.Rows[0]["ChanDoanKhac"].ToString());
                crystalReport4.SetParameterValue("MaCDPH", dt.Rows[0]["ma_benhkhac"].ToString());
                crystalReport4.SetParameterValue("5nam", DateTime.Parse(dt.Rows[0]["ngaydu_5namlientuc"].ToString()).ToString("dd/MM/yyyy"));
                crystalReport4.SetParameterValue("isMienCCT", dt.Rows[0]["ngaybd_miendct"].ToString());
                crystalReport4.SetParameterValue("KhuVuc", dt.Rows[0]["MA_KHUVUC"].ToString());
                crystalReport4.SetParameterValue("MucHuong", dt.Rows[0]["MUC_HUONG"].ToString());
                crystalReport4.SetParameterValue("NoiGT", dt.Rows[0]["ten_noi_chuyen"].ToString());
                crystalReport4.SetParameterValue("NoiCD", dt.Rows[0]["TenBV_ChuyenDi"].ToString());

                for (int i = 0; i < dtDetail.Rows.Count; i++)
                {
                    TongChiPhi1 += (dtDetail.Rows[i]["THANHTIENDV"].ToString() != "" ? float.Parse(dtDetail.Rows[i]["THANHTIENDV"].ToString()) : 0);
                }
                crystalReport4.SetParameterValue("TongChiPhikcb", hs_tinhtien.ConvertMoneyToText(TongChiPhi1.ToString()));
                crystalReport4.SetParameterValue("TongTienBNDT", hs_tinhtien.FormatSNumberToPrint(TONGTIEN_DATRA_BV.ToString()));
                crystalReport4.SetParameterValue("TongTienBNPT", hs_tinhtien.FormatSNumberToPrint(TongTienBNPT_BV.ToString()));
                if (TongTien_ConLai > 0)
                {
                    SoTienThuThem = TongTien_ConLai.ToString();
                    crystalReport4.SetParameterValue("ConLai", "Số tiền thu thêm: " + hs_tinhtien.FormatSNumberToPrint(SoTienThuThem) + "đồng");
                    crystalReport4.SetParameterValue("ConLaiBangChu", hs_tinhtien.ConvertMoneyToText(SoTienThuThem));
                }
                else
                {
                    SoTienHoanTra = (-1 * TongTien_ConLai).ToString();
                    crystalReport4.SetParameterValue("ConLai", "Số tiền hoàn trả: " + hs_tinhtien.FormatSNumberToPrint(SoTienHoanTra) + "đồng");
                    crystalReport4.SetParameterValue("ConLaiBangChu", hs_tinhtien.ConvertMoneyToText(SoTienHoanTra));
                }
                crystalReport4.SetParameterValue("ngaythangnam", "Ngày " + ngayravien.ToString("dd") + " tháng " + ngayravien.ToString("MM") + " năm " + ngayravien.ToString("yyyy") + "");
                crpv01.ReportSource = crystalReport4;
            }
        }