public static bool add_Element(Compare_Element el)
        {
            string zap = "insert into itemtable (itemtable.Serial,itemtable.Serial2," +
                         "itemtable.Mark,itemtable.Type,itemtable.Status,itemtable.Place," +
                         "itemtable.Text,itemtable.Text2,itemtable.Text3,itemtable.Text4,itemtable.Text5,itemtable.Text6 " +
                         ",itemtable.Place2, itemtable.Prise, itemtable.OS, itemtable.Date,itemtable.Owner,itemtable.Status2)";

            zap += " values(" +
                   "'" + el.Serial + "'," +
                   "'" + el.Serial2 + "'," +
                   el.Markid + "," +
                   el.Typeid + "," +
                   el.Statusid + "," +
                   el.Placeid + "," +
                   "'" + el.Text + "'," +
                   "'" + el.Text2 + "'," +
                   "'" + el.Text3 + "'," +
                   "'" + el.Text4 + "'," +
                   "'" + el.Text5 + "'," +
                   "'" + el.Text6 + "'," +
                   el.Place2id + "," +
                   "'" + el.Prise + "'," +
                   el.OSID + "," +
                   "'" + el.date + "'," + el.OwnerID + "," + el.Status2id + ")";

            try
            {
                return(SQL_Class.Execute(zap));
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#2
0
        private void dgv_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex == -1 && e.Button == MouseButtons.Middle)
            {
                string name = dgv.Columns[e.ColumnIndex].Name;
                for (int i = 0; i < tbl.el_list.Count; i++)
                {
                    if (name == tbl.el_list[i].name && tbl.el_list[i].cmbox)
                    {
                        Element         el  = tbl.el_list[i];
                        GroupChangeForm frm = new GroupChangeForm(el);
                        frm.ShowDialog();
                        Application.DoEvents();
                        if (frm.Acept)
                        {
                            int        new_index = frm.id;
                            List <int> ids       = new List <int>();
                            for (int j = 0; j < dgv.RowCount; j++)
                            {
                                ids.Add((int)dgv.Rows[j].Cells[0].Value);
                            }

                            foreach (var VARIABLE in ids)
                            {
                                string req = "update itemtable set " + el.name + " = " + new_index + "  where ID=" +
                                             VARIABLE;
                                SQL_Class.Execute(req);
                                Logs.add_upload_log(VARIABLE, el.name, el.addtable, SQL_Class.ReadValueInt32("select " + el.name + " from itemtable where ID=" + VARIABLE), new_index);
                            }
                            Load_Data_With_Filters();
                        }
                    }
                }
            }
        }
示例#3
0
        public static void add_upload_log(int itemId, string param, string from, string to)
        {
            string zap = "insert into logs (ItemID,Log,Date,Who) values (" + itemId + ",'Изменение параметра " + param +
                         " c " + from + " на " + to + "',NOW(),'" + Environment.UserName + "')";

            SQL_Class.Execute(zap);
        }
        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);
        }
示例#5
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);
        }
示例#6
0
 private void button1_Click(object sender, EventArgs e)
 {
     MessageBox.Show(dgv.RowCount.ToString());
     SQL_Class.Execute("truncate " + TableName);
     for (int i = 0; i < dgv.RowCount - 1; i++)
     {
         string str = "insert into " + TableName + " (ID," + FName + ") Values (" +
                      dgv.Rows[i].Cells[0].Value.ToString() + ",'" + dgv.Rows[i].Cells[1].Value.ToString() + "')";
         SQL_Class.Execute(str);
     }
     load_info();
 }
示例#7
0
        } // for number

        public void upload(string inter_str, string param, string par_name)
        {
            if (inter_str != param)
            {
                if (MessageBox.Show("Сохранить?", "Сохранить?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    param = inter_str;
                    SQL_Class.Execute("update itemtable set " + par_name + "='" + param + "' where ID=" + pr.base_el.ID);
                    reload_base_el();
                }
            }
        } // for string
示例#8
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);
        }
示例#9
0
        } // for number

        public void upload(DateTime inter_str, DateTime param, string par_name)
        {
            if (Convert.ToDateTime(inter_str) != param)
            {
                if (MessageBox.Show("Сохранить?", "Сохранить?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    param = Convert.ToDateTime(inter_str);


                    SQL_Class.Execute("update itemtable set " + par_name + "=" + param + " where ID=" + pr.base_el.ID);
                    reload_base_el();
                }
            }
        } // for number
示例#10
0
        //public void upload(string inter_str, ref string param, string par_name, string table,bool cmb)
        //{
        //    if (inter_str != param)
        //    {
        //        if (MessageBox.Show("Сохранить?", "Сохранить?", MessageBoxButtons.YesNo) == DialogResult.Yes)
        //        {
        //            param = inter_str;
        //            if (cmb)
        //            {
        //                int id =
        //                    SQL_Class.ReadValueInt32("select ID from " + table + " where " + par_name + "= '" + param +
        //                                             "'");
        //                SQL_Class.Execute("update itemtable set " + par_name + "=" + id + " where ID=" + pr.base_el.ID);
        //            }
        //            else
        //            {
        //                SQL_Class.Execute("update itemtable set " + par_name + "='" + param + "' where ID=" + pr.base_el.ID);
        //            }
        //            reload_base_el();
        //        }
        //    }
        //}
        public void upload(string inter_str, int param, string par_name, string table)  // for cmbox
        {
            int new_param_id =
                SQL_Class.ReadValueInt32("select ID from " + table + " where " + par_name + " ='" + inter_str + "'");

            if (new_param_id != param)
            {
                if (MessageBox.Show("Сохранить?", "Сохранить?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    param = new_param_id;
                    SQL_Class.Execute("update itemtable set " + par_name + "=" + new_param_id + " where ID=" + pr.base_el.ID);
                    reload_base_el();
                }
            }
        }
示例#11
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);
        }
        private void FillBase_Click(object sender, EventArgs e) //--------
        {
            int start = Convert.ToInt32(start_Tbox.Text);
            int stop  = Convert.ToInt32(stop_Tbox.Text);

            for (int i = start; i < stop; i++)
            {
                Compare_Element el = Compare_Element.get_el_as_base_el(mcl, i);


                string zap = "insert into itemtable (itemtable.Serial,itemtable.Serial2, itemtable.Mark, itemtable.Type, itemtable.Status,itemtable.Place,             itemtable.Text,itemtable.Text2,itemtable.Text3,itemtable.Text4,itemtable.Text5,itemtable.Text6,itemtable.Owner," +
                             "itemtable.Place2,itemtable.OS,itemtable.Date,itemtable.Prise,itemtable.Status2" +
                             ") Values ('" + el.Serial + "','" + el.Serial2 + "'," + el.Markid +
                             "," + el.Typeid + "," + el.Statusid + "," + el.Placeid +
                             ",'" + el.Text + "','" + el.Text2 + "','" + el.Text3 + "','" + el.Text4 + "','" + el.Text5 + "',''," + el.OwnerID + "," + el.Place2id + "," + el.OSID + ",'" + el.date.ToString("yyyy-MM-dd") + "','" + el.Prise + "'," + el.Status2id + ")";
                SQL_Class.Execute(zap);
            }
        }
示例#13
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;
                }
            }
        }
 public void Delete_To_Base()
 {
     SQL_Class.Execute(tbl.make_Delete_Queue(frm.ID));
     frm.Close();
 }
 public void Save_To_Base()
 {
     SQL_Class.Execute(tbl.make_Update_Queue(agregate_parameters(), frm.ID));
     frm.Close();
 }
 public void Add_To_Base()
 {
     SQL_Class.Execute(tbl.make_Insert_Queue(agregate_parameters()));
     frm.Close();
 }