Example #1
0
 protected override void InternalInsert(string[] names, object[] values)
 {
     _recordset.AddNew(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
     for (int index = 0; index < names.Length; index++)
     {
         _recordset.Fields[names[index]].Value = values[index];
     }
     _recordset.Update(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
 }
Example #2
0
        public static UsuariosBO UpdateUsuario(UsuariosBO Usuario, ADODB.Connection cn)
        {
            var RsUsuarios = new ADODB.Recordset();
            var LibORGM    = new SQL();
            var Serializer = new SerializerFO();

            try
            {
                RsUsuarios.Open(String.Format("SELECT * FROM dbo.Usuarios WHERE Usuario = '{0}'", Usuario.Usuario), cn, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic);
                if (RsUsuarios.EOF)
                {
                    RsUsuarios.AddNew();
                    RsUsuarios.Fields["Usuario"].Value     = Usuario.Usuario;
                    RsUsuarios.Fields["SenhaAcesso"].Value = Usuario.SenhaAcesso;
                    RsUsuarios.Fields["TokenAcesso"].Value = CriptografiaFO.EncriptarMD5(Usuario.TokenAcesso);
                }
                RsUsuarios.Fields["Inativo"].Value = Usuario.Inativo;


                RsUsuarios.Update();
                RsUsuarios.Close();

                Usuario = UsuariosDA.GetUsuarios(Usuario.Usuario, cn);
            }
            catch (Exception)
            {
                throw;
            }

            return(Usuario);
        }
Example #3
0
        private void save_form()
        {
            try
            {
                //ADOconn.BeginTrans();
                ADODB.Recordset cus = new ADODB.Recordset();
                //ADOconn.BeginTrans();

                if (cmbgrp.Text == "")
                {
                    MessageBox.Show("Invalid User Group", "Invalid Entry");
                    return;
                }
                dgv1.EndEdit();
                ADODB.Connection ADOconn = new ADODB.Connection();
                ADOconn.Open("Provider=SQLOLEDB;Initial Catalog= " + decoder.InitialCatalog + ";Data Source=" + decoder.DataSource + ";", decoder.UserID, decoder.Password, 0);

                for (int i = 1; i < dgv1.RowCount; i++)
                {
                    if (dgv1["id", i].Value == null)
                    {
                        continue;
                    }
                    cus = new ADODB.Recordset();
                    sql = "SELECT * FROM userpriv where GROUP_NAME ='" + cmbgrp.Text + "' and form_id=" + dgv1["id", i].Value;
                    cus.Open(sql, ADOconn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, -1);
                    if (cus.RecordCount == 0)
                    {
                        cus.AddNew();
                    }
                    cus.Fields["GROUP_NAME"].Value = cmbgrp.Text;
                    cus.Fields["form_id"].Value    = dgv1["id", i].Value;
                    cus.Fields["ins"].Value        = dgv1["ins", i].Value;
                    cus.Fields["upd"].Value        = dgv1["upd", i].Value;
                    //cus.Fields["qry"].Value = dgv1["qry",i].Value;
                    cus.Fields["del"].Value       = dgv1["del", i].Value;
                    cus.Fields["dsp"].Value       = dgv1["dsp", i].Value;
                    cus.Fields["Menu_Name"].Value = dgv1["Menu_Name", i].Value;
                    cus.Update();
                }

                string grp = cmbgrp.Text;
                sql = "SELECT   distinct group_name  FROM UserPriv ";
                SqlDataAdapter adagrp = new SqlDataAdapter(sql, Conn);
                ///ada.TableMappings.Add("Table", "Leaders");
                DataSet grpds = new DataSet();

                adagrp.Fill(grpds, "UserPriv");
                cmbgrp.DisplayMember = "group_name";
                cmbgrp.DataSource    = grpds.Tables[0];
                cmbgrp.Text          = grp;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #4
0
        public void InsertAdo()
        {
            var con = new Connection();

            con.Open("Provider='sqloledb';Data Source='(local)';Initial Catalog='Proba';Integrated Security='SSPI';");

            var rec = new Recordset();

            rec.Open("SELECT s1, s2 FROM Tabl1", con, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockOptimistic, 0);
            rec.MoveFirst();
            rec.Fields["s1"].Value = "s";
            rec.Fields["s2"].Value = "s";
            rec.Update("s1", rec.Fields["s1"].Value);
            rec.Close();
            con.Close();
        }
Example #5
0
        public void MegaInsertAdo()
        {
            var con = new Connection();

            con.Open("Provider='sqloledb';Data Source='(local)';Initial Catalog='Proba';Integrated Security='SSPI';");

            var rec = new Recordset();

            rec.Open("SELECT s1,s2 FROM Tabl2", con, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockOptimistic, 0);
            for (int i = 1; i <= 10000; ++i)
            {
                //string [] f={"s1","s2"};
                int[]     f = { 0, 1 };
                string [] v = { "s1", "s2" };
                rec.AddNew(f, v);
                //rec.Fields["s2"].Value = i.ToString();
                //rec.Fields["s2"].Value = "new";
                rec.Update(f, v);
            }
            rec.Close();
            con.Close();
        }
Example #6
0
    } // end sub;

    void set_utlimit(float x1)
    {
        //on error GoTo err_setlimit;

        ADODB.Recordset reccust = null;

        //Set Database variable;
        DbUse.open_ado_rec(globaldb, ref reccust, "tblgeneral");

        reccust.MoveFirst();
        //'reccust.edit;
        reccust.Fields["utlimit"].Value = x1;
        reccust.Update();


        //exit_setlimit:
        DbUse.CloseAdoRec(reccust);
        reccust = null;
        return; //exit  Sub;
        //err_setlimit:
        // msgbox(ErrorToString(), 0, appl_name);
        //RESUME NEXT
    } // end sub;
Example #7
0
    } // end sub;

    void set_modified_date()
    {
        //on error GoTo err_setdate;

        ADODB.Recordset reccust = null;

        //Set Database variable;
        DbUse.open_ado_rec(globaldb, ref reccust, "tblgeneral");

        reccust.MoveFirst();
        //'reccust.edit;
        reccust.Fields["DateM"].Value = System.DateTime.Now;
        reccust.Update();



        //exit_setdate:
        DbUse.CloseAdoRec(reccust);
        reccust = null;
        return; //exit  Sub;
        //err_setdate:
        // msgbox(ErrorToString(), 0, appl_name);
        //RESUME NEXT
    } // end sub;
Example #8
0
    } // end function;

    public void match_delay_equip(short useval)
    {
        //on error GoTo err_match;

        ADODB.Recordset rec1 = null;
        string          str1;
        int             delay_id;
        int             stand_id;

        //useval = 2 force the match and only in basecase ...;
        if (glngwid != 0)
        {
            return;               //exit  Sub;
        }
        //Open();
        str1 = "SELECT tblequip.* FROM tblequip;";
        DbUse.open_ado_rec(globaldb, ref rec1, str1);

        delay_id = find_nameItem("Delay", 0, Eq_type, 0);
        stand_id = find_nameItem("standard", 0, Eq_type, 0);

        while (!rec1.EOF)
        {
            if ((useval == 0))
            {
                //'  using type to set grpsize;
                if (((int)rec1.Fields["EQUIPTYPE"].Value) == delay_id) // gerg - I'm not sure if this will work, if not try int.Parse(rec1.Fields["EQUIPTYPE"].Value.ToString()) == delay_id
                {
                    rec1.Fields["grpsiz"].Value = -1;
                }
                else if (((short)rec1.Fields["grpsiz"].Value) == -1)
                {
                    //' standard type but grpsiz = -1;
                    rec1.Fields["grpsiz"].Value = 1;
                }
                ;
            }
            else if ((useval == 1))
            {
                if (((short)rec1.Fields["grpsiz"].Value) == -1)
                {
                    rec1.Fields["EQUIPTYPE"].Value = delay_id;
                }
                else if ((int)rec1.Fields["EQUIPTYPE"].Value != delay_id)
                {
                    //' grpsiz = 2, type = delay ??;
                    rec1.Fields["EQUIPTYPE"].Value = stand_id;
                }
                ;
            }
            else if ((useval == 2))
            {
                //'' force to -1 / delay if either is set.;
                if (short.Parse(rec1.Fields["grpsiz"].Value.ToString()) == -1)
                {
                    rec1.Fields["EQUIPTYPE"].Value = delay_id;
                }
                else if ((int)rec1.Fields["EQUIPTYPE"].Value == delay_id)
                {
                    rec1.Fields["grpsiz"].Value = -1;
                }
                ;
            }
            ;

            rec1.Update();
            rec1.MoveNext();
        }
        ;  // end of while ...

        //exit_match:
        DbUse.CloseAdoRec(rec1);
        rec1 = null;
        return; //exit  Sub;
        //err_match: ;
        // msgbox(ErrorToString(), 0, appl_name);
        // resume  exit_match;
    } // end sub;
Example #9
0
    public int Count;  //  counts # times run then erases database --  nothing in it... a.mdb !!

    public float RunSql2(string str1, short level1)
    {
        //on error GoTo err_RunSql2;

        ADODB.Recordset reccust = null;

        short  ret;
        int    i;
        float  retval;
        string str2;

        retval = -1;

        if (globaldb_a == null)
        {
            try {
                if (!File.Exists("a.xxx"))
                {
                    File.Copy(DbUse.GetMainDirectory() + "App_Data\\" + "a.xxx", varlocal + "a.xxx");
                }
                if (!File.Exists("b.xxx"))
                {
                    File.Copy(DbUse.GetMainDirectory() + "App_Data\\" + "b.xxx", varlocal + "b.xxx");
                }
            } catch (Exception) { }
            globaldb_a = new ADODB.Connection();
            Count      = 0;
        }
        else
        {
            Count++;
            DbUse.CloseAdo(globaldb_a);
        }
        if (Count > 2000)
        {
            try {
                File.Copy("b.xxx", "a.xxx", true);
                Count = 0;
            } catch (Exception) {
            }
        }
        DbUse.open_ado(ref globaldb_a, "a.xxx");

        //  DOES A CONVERSION OF AN EXPRESSION (6+7*4) TO A NUMBER...

        if ((str1.Trim() == "'") | (str1.Trim() == ".") | (str1.Trim() == ","))
        {
            retval = (float)0.0;
            return(retval);
        }

        str2 = "SELECT tbldummy.GeneralID, " + str1 + " AS a1 FROM tbldummy;";
        DbUse.open_ado_rec(globaldb_a, ref reccust, str2);


        try
        {
            // xxx  tomorrow  on run times  += <> /()*.,   no  '"?:;[]{}|&!@#$%^&    NO: [0-31]  33-39  42 58,59 63 64 91-96  123-127
            retval = (float)(double.Parse(reccust.Fields["a1"].Value.ToString()));
        }
        catch (Exception e)
        {    // ERRORMSG tomorrow
             //MyUtilities.MsgBox("Error in solving Operation Time/Data Equation:  " + conn.ConnectionString + " (" + e.Message + ")");


            string str3;
            str3 = e.Message;
            //retval = (float) -777.0;
            retval = float.NaN;
        } finally {
            DbUse.CloseAdoRec(reccust);
            DbUse.CloseAdo(globaldb_a);

            //gwwdd  adding error here !!!
            if (float.IsNaN(retval) || retval < -100)
            {
                try {
                    DbUse.open_ado_rec(globaldb, ref reccust, "zstblerrors");
                    reccust.AddNew();

                    if (Oper_err_id > 0)
                    {
                        reccust.Fields["Level"].Value = 0; // Error;
                        calc_return |= ERR_FLAG;
                        reccust.Fields["Table"].Value = "Operations";
                        string errorMsg = " Product " + Part_err_name + " Operation " + Oper_err_name + " has an operation time which is not a number. ";
                        if (!inOperRoutingPages)
                        {
                            errorMsg += "Go to Product Operations/Routing Page, hit the [Show Real Times] button and look for field value NaN.";
                        }
                        else
                        {
                            errorMsg += "Look for field value NaN.";
                        }
                        reccust.Fields["Text"].Value    = errorMsg;
                        reccust.Fields["mpxFlag"].Value = -1;
                        reccust.Fields["partid"].Value  = Part_err_id;
                        reccust.Fields["operid"].Value  = Oper_err_id;
                        reccust.Fields["Wid"].Value     = glngwid;
                        reccust.Update();
                    }
                    else
                    {                                      //  ROUTING DATA ERROR.
                        reccust.Fields["Level"].Value = 0; // Error;
                        calc_return |= ERR_FLAG;
                        reccust.Fields["Table"].Value = "Routing";
                        string errorMsg = " Product " + Part_err_name + " FROM Operation " + Oper_err_name + " has an % routing value that is not a number. ";
                        if (!inOperRoutingPages)
                        {
                            errorMsg += "Go to Product Operations/Routing Page, Scroll down to the ROUTING AREA hit the [Show Real Percentage] button and Look for field value NaN. ";
                        }
                        else
                        {
                            errorMsg += "Look for field value NaN.";
                        }
                        reccust.Fields["Text"].Value    = errorMsg;
                        reccust.Fields["mpxFlag"].Value = -1;
                        reccust.Fields["partid"].Value  = Part_err_id;
                        reccust.Fields["operid"].Value  = -1 * Oper_err_id;
                        reccust.Fields["Wid"].Value     = glngwid;
                        reccust.Update();
                    }
                } catch (Exception exp) {
                    LogFiles logFiles = new LogFiles(this.username);
                    logFiles.ErrorLog(exp);
                } finally {
                    DbUse.CloseAdoRec(reccust);
                }
            }
        }

        return(retval);

        //err_RunSql2:

        /*if (level1 == 1)
         * {
         *  retval = -999;
         *  return retval; //exit  Function;
         * };*/
        /*   if ((Err.Number == 3075))
         * {
         *     //parathesis problem;
         *     // msgbox("Error in evaluating string " + str1 + " Parathesis Problem? " + ErrorToString() + " Using -999 as the value", 0, appl_name);
         *
         *     //unsolved parameter;
         *     // msgbox("Error in evaluating string " + str1 + " Unresolved Parameter? " + ErrorToString() + " Using -999 as the value", 0, appl_name);
         *
         *     //divide by zero error;
         *     // msgbox("Error in evaluating string " + str1 + " Divide by zero error? " + ErrorToString() + " Using -999 as the value", 0, appl_name);
         *
         *     //a parameter has a null value. Check 'switch' and 'iif';
         *     // msgbox("Error in evaluating string " + str1 + " Null value! iif or Switch Problem? " + ErrorToString() + " Using -999 as the value", 0, appl_name);
         *
         *     // msgbox("Error in evaluating string " + str1 + " Unknown Problem? " + ErrorToString() + " Using -999 as the value", 0, appl_name);
         *     retval = -999;
         *     return retval; //exit  Function;
         * };
         */
        //retval = -999;
        //return retval;
        //RESUME NEXT
    } // end function;
Example #10
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            ADODB.Recordset  rsMail         = null;
            ADODB.Recordset  rsContract     = null;
            ADODB.Recordset  rsMailSettings = null;
            ADODB.Connection connDb         = null;
            bool             solde          = false;
            string           destinataire   = "";
            bool             contratEchu    = false;
            string           CONN_DB        = "";

            //   if (args==null)
            //      Application.Exit();
            if (args == null)
            {
                CONN_DB = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\lementor\StudiosUnis\LeMentorÉlèveTables.mdb;";
            }
            else
            {
                CONN_DB = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + args;
            }


            try
            {
                connDb         = new ADODB.Connection();
                rsMail         = new ADODB.Recordset();
                rsMailSettings = new ADODB.Recordset();
                rsContract     = new ADODB.Recordset();
                System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
                client.UseDefaultCredentials = false;
                client.EnableSsl             = true;
                client.DeliveryMethod        = System.Net.Mail.SmtpDeliveryMethod.Network;

                System.Net.Mail.MailMessage msg = null;
                connDb.Open(CONN_DB);
                rsMail.Open("select * from emailmessage", connDb, CursorTypeEnum.adOpenKeyset, LockTypeEnum.adLockOptimistic);
                rsMailSettings.Open("select * from cie", connDb, CursorTypeEnum.adOpenKeyset, LockTypeEnum.adLockOptimistic);
                if (!rsMail.EOF)
                {
                    rsMail.MoveFirst();
                }
                if (!rsMailSettings.EOF)
                {
                    rsMailSettings.MoveFirst();
                    client.Port        = rsMailSettings.Fields["PortSmtp"].Value; // rsMailSettings.Fields["PortSmtp"].Value;
                    client.Host        = rsMailSettings.Fields["ServerSmtp"].Value.ToString();
                    client.Credentials = new System.Net.NetworkCredential(rsMailSettings.Fields["E-mail"].Value.ToString(), rsMailSettings.Fields["MotdePasseE-mail"].Value);
                }

                while (!rsMail.EOF)
                {
                    solde       = rsMail.Fields["solde"].Value;
                    contratEchu = rsMail.Fields["contratechu"].Value;

                    //destinataire = rsMail.Fields["destinataire"].Value.ToString();

                    // destinataire = "dquirion78@@gmail.com";
                    msg            = new System.Net.Mail.MailMessage();
                    msg.From       = new MailAddress(rsMailSettings.Fields["e-mail"].Value.ToString());
                    msg.Subject    = rsMail.Fields["sujet"].Value.ToString();
                    msg.Body       = rsMail.Fields["texte"].Value.ToString();
                    msg.IsBodyHtml = false;

                    if (string.IsNullOrEmpty(rsMail.Fields["destinataire"].Value.ToString()))
                    {
                        throw new Exception("Destinataire Manquant!");
                    }
                    else
                    {
                        msg.To.Add(destinataire);
                    }
                    if (!string.IsNullOrEmpty(rsMail.Fields["cc"].Value.ToString()))
                    {
                        msg.CC.Add(rsMail.Fields["cc"].Value.ToString());
                    }

                    if (!string.IsNullOrEmpty(rsMail.Fields["cci"].Value.ToString()))
                    {
                        msg.Bcc.Add(rsMail.Fields["cci"].Value.ToString());
                    }
                    if (rsMail.Fields["fichier"].Value.ToString().Length > 3)
                    {
                        System.Net.Mail.Attachment attachment;
                        attachment = new System.Net.Mail.Attachment(rsMail.Fields["fichier"].Value.ToString());
                        msg.Attachments.Add(attachment);
                    }
                    client.Send(msg);
                    // if (rsMail.Fields["fichier"].Value.ToString().Length > 3)
                    //   File.Delete(rsMail.Fields["fichier"].Value.ToString());
                    msg = null;
                    rsContract.Open("select * from GA_Eleve_Cours where [noidcours] =" + rsMail.Fields["noidcours"].Value.ToString(), connDb, CursorTypeEnum.adOpenKeyset, LockTypeEnum.adLockOptimistic);
                    if (!rsContract.EOF)
                    {
                        rsContract.MoveFirst();
                        if (rsMail.Fields["ContratEchu"].Value == true)
                        {
                            rsContract.Fields["NotficationContratEchu"].Value = true;
                        }
                        if (rsMail.Fields["solde"].Value == true)
                        {
                            rsContract.Fields["DernDateNotificationsolde"].Value = rsMail.Fields["DernDateNotificationsolde"].Value;
                            rsContract.Fields["NbreNotificationsolde"].Value     = rsMail.Fields["NbreNotificationsolde"].Value;
                        }
                        rsContract.Update();
                    }
                    rsContract.Close();
                    rsMail.Delete();
                    rsMail.MoveNext();
                    if (!rsMail.EOF)
                    {
                        System.Threading.Thread.Sleep(5000);//limite les chances d'être taggé comme spam par le fournisseur d'envoi en envoyant pas trop vite les emails.
                    }
                    //msg.CC.Add(Email);
                }


                /*
                 *      if (Attachments.Count() > 0)
                 *      {
                 *        foreach (var item in Attachments)
                 *        {
                 *          if (!string.IsNullOrEmpty(item))
                 *          {
                 *            System.Net.Mail.Attachment attachment;
                 *            attachment = new System.Net.Mail.Attachment(item);
                 *            msg.Attachments.Add(attachment);
                 *          }
                 *        }
                 *      }
                 */
                if (((solde == false && contratEchu == false) || (rsMail.RecordCount == 1)) && destinataire.Length > 0)
                {
                    MessageBox.Show("Message Envoyé : à " + destinataire);
                    Application.Exit();
                }

                else
                {
                    //  MessageBox.Show("Message Envoyé : à " + rsMail.RecordCount.ToString() + " clients.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                MessageBox.Show("ÉCHEC d'envoi de courier !");
                Application.Exit();
            }

            try
            {
                if (rsMail.State != 0)
                {
                    rsMail.Close();
                }

                rsMail = null;
                if (rsMailSettings.State != 0)
                {
                    rsMailSettings.Close();
                }
                rsMailSettings = null;
                if (rsContract.State != 0)
                {
                    rsContract.Close();
                }
                rsContract = null;
                Application.Exit();
            }
            catch
            {
                Application.Exit();
            }
        }