public static List <string> check(XLS_Class xls, int start, int stop, int col, string table, string name, bool xls_marker)
        {
            List <string> rett = new List <string>();

            string element;

            if (xls_marker)
            {
                if (name != "Owner")
                {
                    element = "xls" + name;
                }
                else
                {
                    element = name;
                }
            }
            else
            {
                element = name;
            }
            for (int i = start; i < stop; i++)
            {
                if (
                    SQL_Class.ReadValueInt32("select count(*) from " + table + "  where " + element + " like '%" +
                                             xls.read_val(i, col).ToString() + "%'") <= 0)
                {
                    if (!rett.Contains(xls.read_val(i, col).ToString()))
                    {
                        rett.Add(xls.read_val(i, col).ToString());
                    }
                }
            }
            return(rett);
        }
Example #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();
                        }
                    }
                }
            }
        }
        public List <string> check(XLS_Class xls, int start, int stop, int col, string table, string name)
        {
            List <string> rett = new List <string>();

            string element;

            if (XLS_Rbut.Checked)
            {
                element = "xls" + name;
            }
            else
            {
                element = name;
            }
            for (int i = start; i < stop; i++)
            {
                if (
                    SQL_Class.ReadValueInt32("select count(*) from " + table + "  where " + element + " like '%" +
                                             xls.read_val(i, col).ToString() + "%'") <= 0)
                {
                    if (xls.read_val(i, col).ToString() == "СКЛАД")
                    {
                        MessageBox.Show(i.ToString());
                    }
                    if (!rett.Contains(xls.read_val(i, col).ToString()))
                    {
                        rett.Add(xls.read_val(i, col).ToString());
                    }
                }
            }
            return(rett);
        }
Example #4
0
 private void Acept_but_Click(object sender, EventArgs e)
 {
     Acept = true;
     id    =
         SQL_Class.ReadValueInt32("select ID from " + el.addtable + " where " + el.name + " ='" +
                                  cmb.SelectedItem.ToString() + "'");
     Close();
 }
        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);
        }
 private void Owner_CmBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (Owner_CmBox.DataSource != null)
     {
         if (SQL_Class.get_data_Source("select Owner from ownertable").Contains(Owner_CmBox.SelectedItem.ToString()))
         {
             mas = Compare_Pare_Mas.get_base_elements(SQL_Class.ReadValueInt32("select ID from ownertable where Owner='" + Owner_CmBox.SelectedItem.ToString() + "'"));
         }
     }
 }
Example #7
0
        public string get_one_Typethized_part(ComboBox cmb, CheckBox options, string field, string table)
        {
            string rett = " ";

            if (options.Checked)
            {
                return(" AND itemtable." + field + "=" +
                       SQL_Class.ReadValueInt32("select ID from " + table + " where " + field + "='" + cmb.SelectedItem +
                                                "'") + " ");
            }
            else
            {
                return("");
            }
        }
Example #8
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();
                }
            }
        }
Example #9
0
        void load_data()
        {
            string zap = "select ID, ItemID, Log, Date, Who from logs where ItemID=" + ID;

            log_dgv.DataSource = FuncClass.get_dataTable(zap);
            doc_dgv.RowCount   = SQL_Class.ReadValueInt32("select count(*) from Documents where ItemID=" + ID);
            SQL_Class cl = new SQL_Class();

            cl.ReadValues("select ID, Name from documents where ItemID=" + ID);

            int i = 0;

            while (cl.SQL_DataReader.Read())
            {
                doc_dgv.Rows[i].Cells[0].Value = cl.get_int(0);
                doc_dgv.Rows[i].Cells[1].Value = cl.get_string(1);
                i++;
            }
        }
Example #10
0
        public void load_info()
        {
            int count = SQL_Class.ReadValueInt32("Select Count(*) from " + TableName);

            dgv.RowCount = count + 1;
            string    zap = "Select ID," + FName + " from " + TableName;
            SQL_Class cl  = new SQL_Class();

            cl.ReadValues(zap);

            int i = 0;

            while (cl.SQL_DataReader.Read())
            {
                dgv.Rows[i].Cells[0].Value = cl.get_int(0);
                dgv.Rows[i].Cells[1].Value = cl.SQL_DataReader.GetValue(1);
                i++;
            }
            cl.Manualy_Close_Connection2();
        }
Example #11
0
        private void Add_But_Click(object sender, EventArgs e)
        {
            Compare_Element el = new Compare_Element();

            el.Serial  = ser1.Text;
            el.Serial2 = ser21.Text;

            el.Text  = t1.Text;
            el.Text2 = t2.Text;
            el.Text3 = t3.Text;
            el.Text4 = t4.Text;
            el.Text5 = t5.Text;
            el.Text6 = t6.Text;

            el.Prise     = prise1.Text;
            el.date      = date1.Value;
            el.Status2id = SQL_Class.ReadValueInt32("select ID from status2table where Status2 ='" + status21.SelectedItem + "'");
            el.Typeid    = SQL_Class.ReadValueInt32("select ID from typetable where Type ='" + type1.SelectedItem + "'");
            el.Markid    = SQL_Class.ReadValueInt32("select ID from marktable where Mark ='" + mark1.SelectedItem + "'");
            el.Statusid  =
                SQL_Class.ReadValueInt32("select ID from statustable where  Status ='" + status1.SelectedItem + "'");
            el.Placeid  = SQL_Class.ReadValueInt32("select ID from placetable where Place ='" + place1.SelectedItem + "'");
            el.Place2id =
                SQL_Class.ReadValueInt32("select ID from place2table where PLace2  ='" + place21.SelectedItem + "'");
            el.OSID    = SQL_Class.ReadValueInt32("select ID from ostable where  OS ='" + os1.SelectedItem + "'");
            el.OwnerID = SQL_Class.ReadValueInt32("select ID from ownertable where Owner ='" + owner1.SelectedItem + "'");

            if (FuncClass.add_Element(el))
            {
                Close();
            }
            else
            {
                MessageBox.Show("Элемент не добавлен");
            }
        }
 public void request_mas_of_base_elements()
 {
     mas = Compare_Pare_Mas.get_base_elements(SQL_Class.ReadValueInt32("select ID from ownertable where Owner='" + Owner_CmBox.SelectedItem.ToString() + "'"), SQL_Class.ReadValueInt32("select ID from ostable where OS='" + OS_CmBox.SelectedItem.ToString() + "'"));
 }
 public static int get_set(string name)
 {
     return(SQL_Class.ReadValueInt32("select settingstable.Index from settingstable where settingstable.Setting like '%" + name + "%'"));
 }
Example #14
0
        public DataTable get_Table(List <string> mas_eng, string str)
        {
            string[] or_like = new string[0];
            if (All_Search_chBox.Checked)
            {
                string[] sv = All_Search_TBox.Text.Split('|');
                or_like = new string[sv.Length];
                for (int i = 0; i < sv.Length; i++)
                {
                    string cur = "";
                    for (int j = 1; j < mas_eng.Count; j++)
                    {
                        if (!"Data_StartIngest_StartIngest_EndTime_Of_Registration".Contains(mas_eng[j]))
                        {
                            if (sv[i][0] == '@')
                            {
                                cur += "  or  " + mas_eng[j] + " like '" + sv[i].Replace("#", "").Replace("!", "") + "' ";
                            }
                            else
                            {
                                cur += "  or  " + mas_eng[j] + " like '%" + sv[i].Replace("#", "").Replace("!", "") + "%' ";
                            }
                            //cur += "  or  " + mas_eng[j] + " like "+ sv[i].Replace("#","").Replace("@","") + " ";
                        }
                    }

                    or_like[i] = " and ( false " + cur + " )";
                    if (sv[i][0] == '#')
                    {
                        or_like[i] = or_like[i].Replace(" and (", " and NOT (");
                    }
                }
            }


            string agregate = str;

            string pre_zapros = "";


            if (agregate.Contains("PrID"))
            {
                pre_zapros = "SELECT MDA.ID,PrID,MDA.ID  " + agregate.Replace("PrID", "St.Name") + " FROM     MetaDataArchive as MDA   left join ingestassistantsettingsbase.settings as St  on St.ID=PrID  where( Deleted=0  ";
            }
            else
            {
                pre_zapros = "SELECT MDA.ID,PrID,MDA.ID  " + agregate + " FROM     MetaDataArchive as MDA   where (Deleted=0  ";
            }

            if (ViPlanner_ChBOX.Checked)
            {
                pre_zapros += "AND ViPlanner='" + Viplanner_TBox.Text + "'  ";
            }

            if (Reel_ID_ChBox.Checked)
            {
                pre_zapros += "AND Reel_ID='" + Reel_Id_TBox + "'  ";
            }


            if (Pr_Filter_ChBox.Checked)
            {
                pre_zapros += "AND PrID=" +
                              SQL_Class.ReadValueInt32(
                    "select ID from settings where Name='" + Pr_Filter_CmBox.SelectedItem + "'",
                    Properties.Settings.Default.Setting_Base_Path) + "  ";
            }

            if (D_Date_ChBox.Checked)
            {
                DateTime d1;
                DateTime d2;
                if (D_One_RBut.Checked)
                {
                    d1 = Date_Filter1.Value.Date;
                    d2 = d1.AddDays(1).Date;
                }
                else
                {
                    d1 = Date_Filter1.Value.Date;
                    d2 = Date_Filter2.Value.AddDays(1).Date;
                }
                pre_zapros += "AND (Time_Of_Registration between '" + d1.ToString("yyyy.MM.dd HH:mm:ss") + "' and  '" +
                              d2.ToString("yyyy.MM.dd HH:mm:ss") + "'  )";
            }

            if (All_Search_chBox.Checked)
            {
                string zapr = "";
                pre_zapros += "  ";
                for (int i = 0; i < or_like.Length; i++)
                {
                    zapr += pre_zapros + or_like[i] + ") union ";
                }
                if (or_like.Length != 0)
                {
                    zapr = zapr.Substring(0, zapr.Length - 7);
                }
                else
                {
                    zapr = pre_zapros + " false)";
                }

                pre_zapros = zapr;
            }
            else
            {
                pre_zapros += ")";
            }



            if (pre_zapros.Contains("UserID"))
            {
                pre_zapros = pre_zapros.Replace("UserID", "L.L_FullName");
                pre_zapros = pre_zapros.Replace("where",
                                                "left join ingestassistantsettingsbase.login as L  on L.L_ID=UserID  where");
            }
            if (pre_zapros.Contains("RegisterID"))
            {
                pre_zapros = pre_zapros.Replace("RegisterID", "LL.L_FullName");
                // if (!pre_zapros.Contains("left join ingestassistantsettingsbase.login as L  on L_ID=UserId"))
                { pre_zapros = pre_zapros.Replace("where",
                                                  "left join ingestassistantsettingsbase.login as LL  on LL.L_ID=RegisterID  where"); }
            }



            pre_zapros = pre_zapros.Replace(" ID", "MDA.ID");

            var sqlcon     = SQL_Class.Create_class(Ingest_Assistant.Properties.Settings.Default.MetaBase_Way);
            int rows_count = 0;


            //vk
            MySqlDataAdapter mad = new MySqlDataAdapter(pre_zapros, sqlcon.SQL_Connection);
            //DataSet set = new DataSet();
            DataTable tb = new DataTable();

            mad.Fill(tb);
            return(tb);
        }
 public static int get_id(ComboBox box, string name, string table)
 {
     return(SQL_Class.ReadValueInt32("select ID from " + table + " where " + name + " ='" +
                                     box.SelectedItem.ToString() + "'"));
 }