Example #1
0
 public override void Run()
 {
     if (Running)
     {
         if (q.Execute(clearBrLogDet))
         {
             Loging.Loging.WriteLog("OK: " + clearBrLogDet, false, false);
         }
         else
         {
             Loging.Loging.WriteLog("Error: " + clearBrLogDet, true, true);
         }
         if (q.Execute(clearBrLog))
         {
             Loging.Loging.WriteLog("OK: " + clearBrLog, false, false);
         }
         else
         {
             Loging.Loging.WriteLog("Error: " + clearBrLog, true, true);
         }
     }
     Coordinator.ExecuteDelegateArgs args = new Coordinator.ExecuteDelegateArgs();
     args.Maximum       = 1;
     args.Pos           = 1;
     args.runningAction = this;
     args.Name          = Name();
     OnExecute(this, args);
 }
Example #2
0
        private void button10_Click(object sender, EventArgs e)
        {
            QuerySelectPDA q      = new QuerySelectPDA();
            QueryExecPDA   qe     = new QueryExecPDA();
            string         seltyp =
                "select DATA_TYPE from information_schema.columns where TABLE_NAME='{0}' AND COLUMN_NAME='{1}'";

            for (int i = 0; i < PDATables.Items.Count; i++)
            {
                PDATables.SelectedIndex = i;
                for (int j = 0; j < PDAFields.Items.Count; j++)
                {
                    PDAFields.SelectedIndex = j;
                    q.Select(string.Format(seltyp, PDATables.SelectedItem, PDAFields.SelectedItem));
                    List <DataRows> rowtype = q.GetRows();
                    string          type    = rowtype[0].FieldByName("DATA_TYPE");
                    string          instype =
                        "update  TransferFields set DataType={0} where fieldName='{1}' and idTransferTable={2}";
                    string value = "";
                    switch (type)
                    {
                    case "numeric": value = "1";
                        break;

                    case "nvarchar": value = "2";
                        break;

                    case "datetime": value = "3";
                        break;
                    }
                    qe.Execute(String.Format(instype, value, PDAFields.SelectedItem, textBox1.Text));
                }
            }
        }
Example #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     // make select
     listView2.Items.Clear();
     listView2.Columns.Clear();
     if ((textBox1.Text.TrimStart(' ').Length > 6) && (textBox1.Text.TrimStart(' ').Substring(0, 6).ToUpper() == "SELECT"))
     {
         QuerySelectPDA query = new QuerySelectPDA();
         if (!query.Select(textBox1.Text))
         {
             listView2.Columns.Add("Результат", 300);
             listView2.Items.Add(query.ErrorMsg);
         }
         else
         {
             List <DataRows> rows = query.GetRows();
             // make colums
             if (rows.Count > 0)
             {
                 foreach (DataField field in rows[0].fields)
                 {
                     listView2.Columns.Add(field.Field, 100);
                 }
             }
             // rows
             foreach (DataRows row in rows)
             {
                 bool         first = true;
                 ListViewItem item  = new ListViewItem();
                 foreach (DataField field in row.fields)
                 {
                     if (first)
                     {
                         first = false;
                         item  = new ListViewItem(field.Value);
                     }
                     else
                     {
                         item.SubItems.Add(field.Value);
                     }
                 }
                 listView2.Items.Add(item);
             }
         }
     }
     else
     {
         // просто скрипт
         listView2.Columns.Add("Результат", 300);
         QueryExecPDA query = new QueryExecPDA();
         if (query.Execute(textBox1.Text))
         {
             listView2.Items.Add("Выполнен");
         }
         else
         {
             listView2.Items.Add(query.ErrorMsg);
         }
     }
 }
Example #4
0
        public static void SetParam(ParamName paramName, string ParamVal)
        {
            QueryExecPDA q    = new QueryExecPDA();
            string       sql  = "update MainParams set {0}='{1}'";
            string       name = "*";

            switch (paramName)
            {
            case ParamName.idGu: name = "idGU";
                break;

            case ParamName.expDate: name = "expDate";
                break;

            case ParamName.impDate: name = "impDate";
                break;

            case ParamName.impState: name = "impState";
                break;

            case ParamName.expState: name = "expState";
                break;

            case ParamName.isLight: name = "isLight";
                break;
            }
            q.Execute(string.Format(sql, name, ParamVal));
        }
Example #5
0
        private void button8_Click(object sender, EventArgs e)
        {
            QueryExecPDA qry = new QueryExecPDA();
            string       SQL = "delete from TransferFields where idTransferTable='{0}'";

            qry.Execute(String.Format(SQL, textBox1.Text));
            PDATables_SelectedIndexChanged(sender, e);
        }
Example #6
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (PDATables.SelectedItem != null)
            {
                string         SQL   = "select * from Transfer2PDA where tableName='{0}'";
                QuerySelectPDA query = new QuerySelectPDA();
                query.Select(String.Format(SQL, PDATables.SelectedItem));
                List <DataRows> rows = query.GetRows();
                QueryExecPDA    qry  = new QueryExecPDA();

                SQL = "delete from QrySelect where idQrySelect={1}";
                qry.Execute(string.Format(SQL, SelectText.Text, rows[0].FieldByName("idQrySelectBM")));

                SQL = "delete from QrySelect where idQrySelect={1}";
                qry.Execute(string.Format(SQL, SelectPDAText.Text, rows[0].FieldByName("idQrySelectPDA")));

                SQL = "delete from QryDelete  where idQryDelete={1}";
                qry.Execute(string.Format(SQL, DeleteText.Text, rows[0].FieldByName("idQryDelete")));

                SQL = "delete from QryClear where idQryClear={1}";
                qry.Execute(string.Format(SQL, ClearText.Text, rows[0].FieldByName("idQryClear")));

                SQL = "delete from  QryInsert  where idQryinsert={1}";
                qry.Execute(string.Format(SQL, ClearText.Text, rows[0].FieldByName("idQryInsert")));


                SQL = "delete from Transfer2PDA where idTransferTable={0}";
                qry.Execute(String.Format(SQL, textBox1.Text));
                SQL = "delete from TransferFields where idTransferTable={0}";
                qry.Execute(String.Format(SQL, textBox1.Text));
                button1_Click(sender, e);
            }
        }
Example #7
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (PDAFields.SelectedItem != null)
     {
         QueryExecPDA qry = new QueryExecPDA();
         string       SQL = "delete from TransferFields where fieldName='{0}' and idTransferTable={1}";
         qry.Execute(String.Format(SQL, PDAFields.SelectedItem, textBox1.Text));
         PDATables_SelectedIndexChanged(sender, e);
     }
 }
Example #8
0
 public void Exec()
 {
     count = 1;
     foreach (TableInfo info in lst)
     {
         if (Running)
         {
             QueryExecOracle q  = new QueryExecOracle();
             QueryExecPDA    qu = new QueryExecPDA();
             if (!q.Execute("delete from BMEXPORT." + info.tableName))
             {
                 Loging.Loging.WriteLog("Error:delete from BMEXPORT." + info.tableName, true, true);
             }
             else
             {
                 Loging.Loging.WriteLog("OK:delete from BMEXPORT." + info.tableName, false, false);
             }
             if (!qu.Execute("delete from " + info.tableName))
             {
                 Loging.Loging.WriteLog("Error:delete from " + info.tableName, true, true);
             }
             else
             {
                 Loging.Loging.WriteLog("OK:delete from " + info.tableName, false, false);
             }
             Coordinator.ExecuteDelegateArgs args = new Coordinator.ExecuteDelegateArgs();
             args.Maximum       = lst.Count;//передавать в args кол-во таблиц и номер текущей (дл¤ прогресс бара)
             args.Pos           = count;
             args.runningAction = this;
             args.Name          = Name();
             OnExecute(this, args);
             count++;
         }
         else
         {
             break;
         }
     }
 }
Example #9
0
 private void button5_Click(object sender, EventArgs e)
 {
     if (OraFields.SelectedItem != null)
     {
         string         idquery = "select MAX(idTransferField) as ID from TransferFields";
         QuerySelectPDA query   = new QuerySelectPDA();
         query.Select(idquery);
         List <DataRows> rows = query.GetRows();
         int             id;
         try
         {
             id = Convert.ToInt32(rows[0].FieldByName("ID")) + 1;
         }
         catch (FormatException)
         {
             id = 1;
         }
         QueryExecPDA qry = new QueryExecPDA();
         string       SQL = "insert into TransferFields values ({0},{1},'{2}')";
         qry.Execute(String.Format(SQL, id, textBox1.Text, OraFields.SelectedItem));
         PDATables_SelectedIndexChanged(sender, e);
     }
 }
Example #10
0
        private void button6_Click(object sender, EventArgs e)
        {
            if (PDATables.SelectedItem != null)
            {
                int    isl = 0, nex = 0;
                string SQL = "update Transfer2PDA set isLight={0},  needExport={1} where idTransferTable={2}";
                if (checkBox1.Checked)
                {
                    isl = 1;
                }
                if (checkBox2.Checked)
                {
                    nex = 1;
                }
                QueryExecPDA qry = new QueryExecPDA();
                qry.Execute(String.Format(SQL, isl, nex, textBox1.Text));

                SQL = "select * from Transfer2PDA where tableName='{0}'";
                QuerySelectPDA query = new QuerySelectPDA();
                query.Select(String.Format(SQL, PDATables.SelectedItem));
                List <DataRows> rows = query.GetRows();

                SQL = "update QrySelect set text='{0}' where idQrySelect={1}";
                qry.Execute(string.Format(SQL, SelectText.Text, rows[0].FieldByName("idQrySelectBM")));

                SQL = "update QrySelect set text='{0}' where idQrySelect={1}";
                qry.Execute(string.Format(SQL, SelectPDAText.Text, rows[0].FieldByName("idQrySelectPDA")));

                SQL = "update QryDelete set text='{0}' where idQryDelete={1}";
                qry.Execute(string.Format(SQL, DeleteText.Text, rows[0].FieldByName("idQryDelete")));

                SQL = "update QryClear set text='{0}' where idQryClear={1}";
                qry.Execute(string.Format(SQL, ClearText.Text, rows[0].FieldByName("idQryClear")));

                SQL = "update QryInsert set text='{0}' where idQryInsert={1}";
                qry.Execute(string.Format(SQL, InsertText.Text, rows[0].FieldByName("idQryInsert")));
            }
        }
Example #11
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (OraTables.SelectedItem != null)
            {
                string         idquery = "select MAX(idTransferTable) as ID from Transfer2PDA";
                QuerySelectPDA query   = new QuerySelectPDA();
                query.Select(idquery);
                List <DataRows> rows = query.GetRows();
                int             id;
                try
                {
                    id = Convert.ToInt32(rows[0].FieldByName("ID")) + 1;
                }
                catch (FormatException)
                {
                    id = 1;
                }
                idquery = "select MAX(idQrySelect) as ID from QrySelect";

                query.Select(idquery);
                rows = query.GetRows();
                int idSelectBM;
                try
                {
                    idSelectBM = Convert.ToInt32(rows[0].FieldByName("ID")) + 1;
                }
                catch (FormatException)
                {
                    idSelectBM = 1;
                }
                int idSelectPDA = idSelectBM + 1;

                idquery = "select MAX(idQryDelete) as ID from QryDelete";
                query.Select(idquery);
                rows = query.GetRows();
                int idDelete;
                try
                {
                    idDelete = Convert.ToInt32(rows[0].FieldByName("ID")) + 1;
                }
                catch (FormatException)
                {
                    idDelete = 1;
                }

                idquery = "select MAX(idQryClear) as ID from QryClear";
                query.Select(idquery);
                rows = query.GetRows();
                int idClear;
                try
                {
                    idClear = Convert.ToInt32(rows[0].FieldByName("ID")) + 1;
                }
                catch (FormatException)
                {
                    idClear = 1;
                }

                idquery = "select MAX(idQryInsert) as ID from QryInsert";
                query.Select(idquery);
                rows = query.GetRows();
                int idInsert;
                try
                {
                    idInsert = Convert.ToInt32(rows[0].FieldByName("ID")) + 1;
                }
                catch (FormatException)
                {
                    idInsert = 1;
                }

                QueryExecPDA qry = new QueryExecPDA();
                string       SQL = "insert into Transfer2PDA values ({0},'{1}',{2},{3},{4},{5},{6},null,null,null,null)";
                qry.Execute(String.Format(SQL, id, OraTables.SelectedItem, idSelectBM, idSelectPDA, idDelete, idClear, idInsert));
                SQL = "insert into QrySelect values ({0},null)";
                qry.Execute(String.Format(SQL, idSelectBM));
                SQL = "insert into QrySelect values ({0},null)";
                qry.Execute(String.Format(SQL, idSelectPDA));
                SQL = "insert into QryDelete values ({0},null)";
                qry.Execute(String.Format(SQL, idDelete));
                SQL = "insert into QryClear values ({0},null)";
                qry.Execute(String.Format(SQL, idClear));
                SQL = "insert into QryInsert values ({0},null)";
                qry.Execute(String.Format(SQL, idInsert));
                PDAFields.Items.Clear();
                OraFields.Items.Clear();
                button1_Click(sender, e);
            }
        }
 public void Exec()
 {
     count = 1;
     foreach (TableInfo info in lst)
     {
         string ins = "";
         string temp;
         if (Running)
         {
             QuerySelectOracle q  = new QuerySelectOracle();
             QueryExecPDA      qu = new QueryExecPDA();
             if (!q.Select("select * from BMEXPORT." + info.tableName))
             {
                 Loging.Loging.WriteLog("Error:select * from BMEXPORT." + info.tableName, true, true);
             }
             else
             {
                 Loging.Loging.WriteLog("OK:select * from BMEXPORT." + info.tableName, false, false);
                 List <DataRows> dr = q.GetRows();
                 foreach (DataRows rows in dr)
                 {
                     temp = "";
                     ins  = "insert into " + info.tableName + "(";
                     foreach (FieldInfo field in info.fields)
                     {
                         ins += field.fieldName + ", ";
                         if (rows.FieldByName(field.fieldName) != "")
                         {
                             temp += "'" + rows.FieldByName(field.fieldName).Replace(',', '.').Replace("'", "''").ToString() + "', ";
                         }
                         else
                         {
                             temp += "null, ";
                         }
                     }
                     ins  = ins.Remove(ins.LastIndexOf(','), 1);
                     temp = temp.Remove(temp.LastIndexOf(','), 1);
                     ins += ") values (" + temp + ")";
                     if (!qu.Execute(ins))
                     {
                         Loging.Loging.WriteLog("Error: " + ins, true, true);
                     }
                     else
                     {
                         Loging.Loging.WriteLog("OK: " + ins, false, false);
                     }
                 }
             }
             Coordinator.ExecuteDelegateArgs args = new Coordinator.ExecuteDelegateArgs();
             args.Maximum       = lst.Count;//передавать в args кол-во таблиц и номер текущей (для прогресс бара)
             args.Pos           = count;
             args.runningAction = this;
             args.Name          = Name();
             OnExecute(this, args);
             count++;
         }
         else
         {
             break;
         }
     }
 }