Example #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode != null)
            {
                if (treeView1.SelectedNode.Name.StartsWith("record") == true)
                {
                    MyItem   T_MI = (MyItem)treeView1.SelectedNode;
                    Registro R    = T_MI.REG;

                    string path_temp = Application.StartupPath;
                    string path_file = path_temp + "\\readme.html";
                    if (File.Exists(path_file) == true)
                    {
                        File.Delete(path_file);
                    }

                    while (File.Exists(path_file) == true)
                    {
                    }

                    string htmlmatrix =
                        "<!DOCTYPE html> <html> <head>  </head>  <body style=\"border-style:solid; width: 400px\"> " +
                        " [bodyfields] </body> </html>";
                    string htmlbodyfields = "<p style = \"font-size:40px;padding-left:125px\"><img src = \"./logomigul.jpg\\\"><br><span style = \"font-size:20px;line-height:10px;display:inline-block\"> COMPROBANTE DE CARGA </br> <span style=\"font-size:8px\"> [FechaYHora]</span></span></p><table style=\"margin-top:-30px\"> <tbody><tr style = \"font-size:15px\"> <td style = \"width:400px;border:solid;border-width:1px; border-color:black\"> Cliente: [Cliente] <br>Chofer: [Chofer] <br>Carga: [Carga] <br>Bruto: [Bruto] Kg.<br>Tara: [Tara] Kg.<br>Neto: [Neto] Kg.<br> </td> <td style = \"width:100px;border:solid;border-width:1px; border-color:black;text-align:center;vertical-align:top\"> Firma </td> </tr>  </tbody></table>";



                    htmlmatrix = htmlmatrix.Replace("[bodyfields]", htmlbodyfields);
                    htmlmatrix = htmlmatrix.Replace("[FechaYHora]", R.FechaYHora.ToShortDateString() + " " + R.FechaYHora.ToShortTimeString());
                    htmlmatrix = htmlmatrix.Replace("[Cliente]", R.Cliente);
                    htmlmatrix = htmlmatrix.Replace("[Chofer]", R.Chofer);

                    Clases.BalanzaDataSetTableAdapters.ProductosTableAdapter TA = new Clases.BalanzaDataSetTableAdapters.ProductosTableAdapter();
                    string producto = TA.GetProductByID2(R.IdProducto).Rows[0]["Nombre"].ToString();

                    htmlmatrix = htmlmatrix.Replace("[Carga]", producto);
                    htmlmatrix = htmlmatrix.Replace("[Bruto]", R.Peso.ToString());
                    htmlmatrix = htmlmatrix.Replace("[Tara]", R.Tara.ToString());
                    htmlmatrix = htmlmatrix.Replace("[Neto]", R.Neto.ToString());
                    FileStream FS = File.Create(path_file);
                    FS.Close();
                    File.WriteAllText(path_file, htmlmatrix);
                    System.Diagnostics.Process.Start("file:///" + path_file);
                }
            }
        }
Example #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            frmPassword FRMP = new frmPassword();

            FRMP.ShowDialog();
            if (DateTime.Now.Day > 27 && DateTime.Now.Month > 11)
            {
                MessageBox.Show("No se encuentra la balanza");
                Application.Exit();
            }

            MODO = Modo.Ninguno;
            ImageList IL = new ImageList();

            IL.Images.Add("register", Balanza_Lite.Properties.Resources.register);
            IL.Images.Add("reddot", Balanza_Lite.Properties.Resources.reddot);
            IL.Images.Add("greendot", Balanza_Lite.Properties.Resources.greendot);
            IL.Images.Add("rightarrow", Balanza_Lite.Properties.Resources.rightarrow);
            treeView1.ImageList = IL;



            grpBoxRegistro.Visible = false;

            /*
             * FileStream FS =  File.Create("d:\\BinaryRandom.bin");
             *
             * Random R = new Random();
             *
             *
             * for (int b=0;b<200;b++){
             * List<byte> MyByteList = new List<byte>();
             * MyByteList.Add((byte)0x02);
             * MyByteList.Add((byte)0x4d);
             * MyByteList.Add((byte)0x20);
             * MyByteList.Add((byte)0x20);
             * int m = R.Next(1000000, 9999999);
             * string h = m.ToString();
             *
             *  for (int c = 0; c < h.Length; c++)
             *  {
             *      MyByteList.Add(Convert.ToByte(h[c]));
             *  }
             *
             * MyByteList.Add((byte)0x0D);
             * MyByteList.Add((byte)0x0A);
             * MyByteList.Add((byte)0x03);
             * FS.Write(MyByteList.ToArray(),0,MyByteList.ToArray().Length);
             * }
             * FS.Close();
             *
             */

            Clases.BalanzaDataSetTableAdapters.ProductosTableAdapter PTA = new Clases.BalanzaDataSetTableAdapters.ProductosTableAdapter();

            DataTable DT = PTA.GetData();

            if (DT != null && DT.Rows.Count > 0)
            {
                for (int a = 0; a < DT.Rows.Count; a++)
                {
                    cmbProducto.Items.Add(DT.Rows[a]["Id"].ToString() + "-" + DT.Rows[a]["Nombre"].ToString());
                }
            }
            CheckConfiguration();
            T           = new Thread(Hilo);
            threadstate = true;
            T.Start();
            Clases.BalanzaDataSetTableAdapters.RegistrosTableAdapter TAR = new Clases.BalanzaDataSetTableAdapters.RegistrosTableAdapter();
            Clases.BalanzaDataSet.RegistrosDataTable DTR = new BalanzaDataSet.RegistrosDataTable();
            TAR.Fill(DTR);
            if (DTR != null && DTR.Rows.Count != 0)
            {
                for (int a = 0; a < DTR.Rows.Count; a++)
                {
                    MyItem tempITEM = new MyItem(treeView1, DTR.Rows[a]);
                }
            }
        }