Exemple #1
0
        public void left(ComboBox cmb1, TextBox tb2, string par, string table)
        {
            string base_par = SQL_Class.ReadValueString("select " + par + " from " + table + " where xls" + par + " like '%" + tb2.Text.ToString() +
                                                        "%'");

            cmb1.SelectedItem = base_par;
        }
        public void Update_One_Item(string name, string table, string fr, string addition)
        {
            int    id  = SQL_Class.ReadValueInt32("select ID from " + table + "  where " + name + "='" + fr + "'");
            string old = SQL_Class.ReadValueString("select xls" + name + " from " + table + " where ID=" + id);

            old += "|" + addition + "|";
            SQL_Class.Execute("Update " + table + " set xls" + name + "='" + old + "' where ID=" + id);
        }
Exemple #3
0
        public static void add_upload_log(int itemId, string param, string table_name, int from, string to)
        {
            string fr = SQL_Class.ReadValueString("select " + param + " from " + table_name + " where ID=" + from);

            string zap = "insert into logs (ItemID,Log,Date,Who) values (" + itemId + ",'Изменение параметра " + param +
                         " c " + fr + " на " + to + "',NOW(),'" + Environment.UserName + "')";

            SQL_Class.Execute(zap);
        }
Exemple #4
0
 public static void open_document(int id)
 {
     try
     {
         Process.Start(SQL_Class.ReadValueString("select Path from documents where ID=" + id));
     }
     catch (Exception)
     {
     }
 }
Exemple #5
0
        public static bool add_document(int itemID, Image img)
        {
            try
            {
                string dir      = SQL_Class.ReadValueString("select Serial2 from itemtable where ID=" + itemID);
                string dest_dir = Path + "\\" + dir;
                if (!Directory.Exists(dest_dir))
                {
                    Directory.CreateDirectory(dest_dir);
                }

                SaveFileDialog sfd = new SaveFileDialog();
                sfd.InitialDirectory = dest_dir;
                sfd.AddExtension     = true;
                sfd.Filter           = ".jpeg";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    string dest_path = sfd.FileName;
                    if (!File.Exists(dest_path))
                    {
                        img.Save(dest_path);
                        string zap = "insert into documents (ItemID,Name,Path) values (" + itemID + ",'" +
                                     System.IO.Path.GetFileName(sfd.FileName) + "','" + dest_path.Replace("\\", "\\\\") +
                                     "')";
                        SQL_Class.Execute(zap);
                    }
                    else
                    {
                        if (MessageBox.Show("Заменить файл?", "Заменить файл?", MessageBoxButtons.YesNo) ==
                            DialogResult.Yes)
                        {
                            File.Delete(dest_path);
                            img.Save(dest_path);
                            string zap = "insert into documents (ItemID,Name,Path) values (" + itemID + ",'" +
                                         System.IO.Path.GetFileName(sfd.FileName) + "','" +
                                         dest_path.Replace("\\", "\\\\") +
                                         "')";
                            SQL_Class.Execute(zap);
                        }
                    }
                    return(true);
                }
            }
            catch
            (Exception)
            {
                return(false);
            }
            return(false);
        }
Exemple #6
0
        //public static void edit_document(int id)
        //{
        //    string path=SQL_Class.ReadValueString("select Path from documents where ID=" + id)
        //    OpenFileDialog ofd = new OpenFileDialog();
        //    ofd.FileName = path;
        //    if (ofd.ShowDialog()==DialogResult.Yes)
        //    {
        //        path=
        //    }

        //}

        public static void delete_document(int id)
        {
            string path = (SQL_Class.ReadValueString("select Path from documents where ID=" + id));

            try
            {
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
            }
            catch (Exception)
            {
            }
            SQL_Class.Execute("delete * from documents where ID=" + id);
        }
Exemple #7
0
        public static void add_document(int itemID)
        {
            string         path;
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    path = ofd.FileName;
                    string dir      = SQL_Class.ReadValueString("select Serial2 from itemtable where ID=" + itemID);
                    string dest_dir = Path + "\\" + dir;
                    if (!Directory.Exists(dest_dir))
                    {
                        Directory.CreateDirectory(dest_dir);
                    }
                    string dest_path = dest_dir + "\\" + System.IO.Path.GetFileName(path);
                    if (!File.Exists(dest_path))
                    {
                        File.Copy(path, dest_path);
                        string zap = "insert into documents (ItemID,Name,Path) values (" + itemID + ",'" +
                                     System.IO.Path.GetFileName(path) + "','" + dest_path.Replace("\\", "\\\\") + "')";
                        SQL_Class.Execute(zap);
                    }
                    else
                    {
                        if (MessageBox.Show("Заменить файл?", "Заменить файл?", MessageBoxButtons.YesNo) ==
                            DialogResult.Yes)
                        {
                            File.Delete(dest_path);
                            File.Copy(path, dest_path);
                            string zap = "insert into documents (ItemID,Name,Path) values (" + itemID + ",'" +
                                         System.IO.Path.GetFileName(path) + "','" + dest_path.Replace("\\", "\\\\") + "')";
                            SQL_Class.Execute(zap);
                        }
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }