Пример #1
0
        public int AddToPrintList(PicBox picbox)
        {
            for(int i=0;i<toPrintList.Count;i++){
            if (toPrintList[i].coin.cat == picbox.coin.cat && toPrintList[i].coin.image == picbox.coin.image && toPrintList[i].coin.number == picbox.coin.number)
            {

            return 0;

            }

            }

            coin coin =new coin();

            coin = picbox.coin;
            PicBox pic = new PicBox(coin, ItemSizeX, ItemSizeY);
            pic.Click += new System.EventHandler(toPrintBox_Click);
            toPrintList.Add(pic);
            return 1;
        }
Пример #2
0
        public void LoadCoin()
        {
            SQL sql = new SQL();
            FbDataReader reader = sql.StartQuery("SELECT * FROM COINS");

            try
            {
                while (reader.Read())
                {
                    coin cn = new coin();
                    if (!reader.IsDBNull(4))
                        cn.JPGPath = reader.GetString(4);
                    if (reader.GetString(4) != "")
                    {
                        WebClient wc = new WebClient();
                        String name = reader.GetString(4).Substring(0, reader.GetString(4).Length - reader.GetString(8).Length);
                        wc.DownloadFile(Program.JPGserver + reader.GetString(4), Application.StartupPath +"\\"+ name);
                        System.IO.FileStream fs = new System.IO.FileStream(Application.StartupPath+"\\" + name, System.IO.FileMode.Open);

                        System.Drawing.Image img = System.Drawing.Image.FromStream(fs);
                        fs.Close();
                        System.IO.File.Delete(Application.StartupPath + "\\" + name);

                        Bitmap bm = (Bitmap)img;
                        cn.image = bm;
                    }
                    if (!reader.IsDBNull(8))
                        cn.sec = reader.GetInt32(8);
                    if (!reader.IsDBNull(7))
                        cn.tag = reader.GetString(7);
                    if (!reader.IsDBNull(5))
                        cn.CDRPath = reader.GetString(5);
                    if (!reader.IsDBNull(3))
                    cn.cat = reader.GetInt32(3);
                    if (!reader.IsDBNull(1))
                    cn.name = reader.GetString(1);
                    if (!reader.IsDBNull(2))
                    cn.number = reader.GetInt32(2);
                    cn.id = reader.GetInt32(0);
                    if (!reader.IsDBNull(6))
                    cn.date=reader.GetDateTime(6);
                    PicBox pb = new PicBox(cn,ItemSizeX, ItemSizeY);
                    pb.Click += new System.EventHandler(pictureBox1_Click);
                    All.Add(pb);
                }
            }
            finally
            {
                sql.EndQuery();
                SaveJPG();
            }
        }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (isLoginOk())
            {
                int catid = GetCatID(CoinCat.Text);
                SQL sql   = new SQL();
                if (CoinNumberTxt.Text == "")
                {
                    CoinNumberTxt.Text = "0";
                }
                Random rnd = new Random();
                int    sec = rnd.Next(1000000);
                coin   cn  = new coin();
                if (bm != null)
                {
                    bm       = ResizeBitmap(bm);
                    cn.image = bm;
                }
                cn.name   = CoinNameTxt.Text;
                cn.cat    = catid;
                cn.number = int.Parse(CoinNumberTxt.Text);
                cn.date   = Calendar.Value;
                cn.sec    = sec;
                cn.tag    = Info_tags.Text;
                //cn.date.AddDays(Calendar.SelectionStart.Day);
                //cn.date.AddMonths(Calendar.SelectionStart.Month);
                // cn.date.AddYears(Calendar.SelectionStart.Year);

                String date = Calendar.Value.Month + "/" + Calendar.Value.Day + "/" + Calendar.Value.Year;

                WebClient wc           = new WebClient();
                String    new_jpg_path = JPGName;
                String    new_cdr_path = CDRName;
                if (JPGPath != null)
                {
                    bm.Save(Application.StartupPath + "\\" + new_jpg_path);
                    wc.UploadFile(Program.JPGserver + new_jpg_path + sec, "STOR", Application.StartupPath + "\\" + new_jpg_path);
                    System.IO.File.Delete(Application.StartupPath + "\\" + new_jpg_path);
                    new_jpg_path += "" + sec;
                    cn.JPGPath    = new_jpg_path;
                }
                else
                {
                    new_jpg_path = "";
                    cn.JPGPath   = new_jpg_path;
                }
                if (CDRPath != null)
                {
                    wc.UploadFile(Program.CDRserver + new_cdr_path + sec, "STOR", CDRPath);
                    new_cdr_path += "" + sec;
                    cn.CDRPath    = new_cdr_path;
                }
                else
                {
                    new_cdr_path = "";
                    cn.CDRPath   = new_cdr_path;
                }



                PicBox pb = new PicBox(cn, Program.mainform.ItemSizeX, Program.mainform.ItemSizeY);
                pb.Click += new System.EventHandler(Program.mainform.pictureBox1_Click);



                sql.ExecuteNonQuery("INSERT INTO COINS (NAME,NUMBER,CAT,IMAGE_JPG,IMAGE_CDR,\"DATE\",SECURE,TAG) VALUES('" + CoinNameTxt.Text + "'," + int.Parse(CoinNumberTxt.Text) + "," + catid + ",'" + new_jpg_path + "','" + new_cdr_path + "','" + date + "'," + sec + ",'" + Info_tags.Text + "')");
                Program.mainform.All.Add(pb);
                Program.mainform.refreshIdToName();
                Program.mainform.refreshCoinIdtoName();
                Program.mainform.refreshCatList();
                Program.mainform.sort();
                //INSERT INTO COINS (ID, NAME, NUMBER, CAT, IMAGE_JPG, IMAGE_CDR, "DATE") VALUES (14, 'le;flsd', 34234, 4, 'C:\Users\Public\Pictures\Sample Pictures\Desert.jpg', 'None', '2-MAR-2012');
            }
        }