GetInt16() public méthode

public GetInt16 ( int i ) : Int16
i int
Résultat System.Int16
Exemple #1
0
 public void LoadFromDB(MySqlDataReader reader)
 {
     if (reader.Read())
     {
         Nickname = (reader.IsDBNull(0) ? null : reader.GetString(0));
         Level = reader.GetInt16(1);
         Exp = reader.GetInt16(2);
     }
 }
Exemple #2
0
        public void LoadFromDB(MySqlDataReader reader)
        {
            Items.Clear();
            while (reader.Read())
            {
                Int32 characterNo = reader.GetInt32(0);
                Int32 characterId = reader.GetInt32(1);
                Character ch = new Character(_user, characterId, characterNo);
                ch.Level = reader.GetInt16(2);
                ch.Exp = reader.GetInt32(3);
                ch.GradeId = reader.GetInt16(4);
                ch.PromotionId = reader.GetInt16(5);

                Items.Add(ch);
            }
        }
        void Ekle(string kID)
        {
            int makaleID = 1;

            String connStr = System.Configuration.ConfigurationManager.ConnectionStrings["WebConnString"].ToString();

            conn = new MySql.Data.MySqlClient.MySqlConnection(connStr);
            conn.Open();

            queryStr = "SELECT * FROM tasarimdersi.yazarmakale WHERE ID= " + kID + " AND MakaleID = (SELECT MAX(MakaleID) FROM tasarimdersi.yazarmakale WHERE ID= " + kID + ")";


            cmd    = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
            reader = cmd.ExecuteReader();

            while (reader.HasRows && reader.Read())
            {
                makaleID = reader.GetInt16(reader.GetOrdinal("MakaleID")) + 1;
            }

            conn.Close();


            if (FileUpload1.HasFile)
            {
                if (FileUpload1.PostedFile.ContentType == "application/pdf")
                {
                    if (FileUpload1.PostedFile.ContentLength < 10240000)
                    {
                        isim       = Session["IDSes"].ToString() + "-" + makaleID;
                        makaleIsim = isim + ".pdf";
                        makalePath = (Server.MapPath("//resimler//") + makaleIsim);
                        FileUpload1.SaveAs(makalePath);
                    }
                    else
                    {
                        lblMesaj.InnerText = "Dosya boyutu maximum 10MB olmalıdır.";
                    }
                }
                else
                {
                    lblMesaj.InnerText = "Sadece pdf uzantılı dosyalar yüklenebilir.";
                }
            }
            else
            {
                lblMesaj.InnerText = "Lütfen bir dosya seçiniz.";
            }


            conn.Open();
            queryStr = "INSERT INTO tasarimdersi.yazarmakale (ID,MakaleID,alan,baslik,aciklama,makalepdf,onay)" +
                       "Values('" + kID + "','" + makaleID + "','" + Alan.Text + "','" +
                       Baslik.Text + "','" + Aciklama.Text + "','" + makaleIsim + "','" + "Editör İncelemesinde" + "')";

            cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
            cmd.ExecuteReader();
            conn.Close();
            Response.Redirect(Request.RawUrl);
        }
Exemple #4
0
        public GuildMember(Guild Guild, MySqlDataReader reader)
        {
            this.Guild = Guild;

            CharacterID = reader.GetInt32(1);
            Rank = (GuildRank)reader.GetByte(2);
            Corp = (ushort)reader.GetInt16(3);
        }
Exemple #5
0
    private void LoginWithPasswordHashFunction()
    {
        String saltHash = null;

        try
        {
            connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();

            conn = new MySql.Data.MySqlClient.MySqlConnection(connectionString);
            conn.Open();
            String query = "SELECT userID, slowHashSalt, firstname, middlename, lastname, isPT FROM webAppPersonalFit.userregistration WHERE username=?uname";

            cmd = new MySql.Data.MySqlClient.MySqlCommand(query, conn);
            cmd.Parameters.AddWithValue("?uname", usernameTextBox.Value);

            reader = cmd.ExecuteReader();

            if (reader.HasRows && reader.Read())
            {
                String saltHashes = reader.GetString(reader.GetOrdinal("slowHashSalt"));
                //Console.WriteLine(saltHashes);
                saltHash = saltHashes;

                userID = "" + reader.GetInt16(reader.GetOrdinal("userID"));
                isPT   = Convert.ToInt32(reader.GetByte(reader.GetOrdinal("isPT")));
            }
            else
            {
                ValidationTextBoxLabel.Text = "Invalid Username or Password.";
            }
            if (saltHash != null)
            {
                bool validUser = PasswordStorage.VerifyPassword(passwordTextBox.Value, saltHash);

                if (validUser == true)
                {
                    Session[userID]       = userID;
                    Response.BufferOutput = true;
                    Server.Transfer("TrainerCatalog.aspx", true);
                }
                else
                {
                    ValidationTextBoxLabel.Text = "Invalid Username or Password.";
                }
            }
            ValidationTextBoxLabel.Text = "Invalid Username or Password.";
            reader.Close();
            conn.Close();
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }
    }
 // Changement du mot de passe
 private void btnValider_Click(object sender, EventArgs e) {
     // Si tout les champs renseignés
     if (txtAncMdp.Text != "" && txtCnfNouvMdp.Text != "" && txtNouvMdp.Text != "") {
         // ---------- Vérification des informations rentrées ---------------           
         // Vérification que nouveau mot de passe + confirmation soient identiques
         if (txtNouvMdp.Text == txtCnfNouvMdp.Text) {
             // Vérification de la longueur du nouveau mot de passe
             if (txtNouvMdp.TextLength >= Global._MIN_CARAC_PWD) {
                 // Vérification du mot de passe actuel
                 try {
                     cmd = new MySqlCommand("SELECT count(*) FROM utilisateur WHERE idUtilisateur = '" + Global.userId + "' and password = PASSWORD(@pwd)", Global.Connection);
                     MySqlParameter pMdp = new MySqlParameter("@pwd", MySqlDbType.Text);
                     pMdp.Value = txtAncMdp.Text;
                     cmd.Parameters.Add(pMdp);
                     cmd.Prepare();
                     rd = cmd.ExecuteReader();
                     rd.Read();
                     // Si ancien mot de passe OK
                     if (rd.GetInt16(0) == 1) {
                         rd.Close();
                         // MAJ du mot de passe
                         cmd = new MySqlCommand("UPDATE utilisateur SET password = PASSWORD(@pwd) WHERE idUtilisateur = '" + Global.userId + "'", Global.Connection);
                         MySqlParameter pNouvMdp = new MySqlParameter("@pwd", MySqlDbType.Text);
                         pNouvMdp.Value = txtNouvMdp.Text;
                         cmd.Parameters.Add(pNouvMdp);
                         cmd.Prepare();
                         cmd.ExecuteNonQuery();
                         MessageBox.Show("Votre mot de passe a bien été modifié ! ", "Succès", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         rd.Close();
                         // Retour à l'écran principal
                         this.Close();
                     } else {
                         MessageBox.Show("Votre mot de passe actuel est incorrect. Veuillez recommencer.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         txtAncMdp.Text = "";
                         rd.Close();
                     }
                 } catch (MySqlException) {
                     MessageBox.Show("Une erreur est survenue. Le mot de passe n'a pas été changé.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     rd.Close();
                 }
             } else {
                 MessageBox.Show("Le nouveau mot de passe est trop petit : minimum " + Global._MIN_CARAC_PWD + " caractères.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtNouvMdp.Text = "";
                 txtCnfNouvMdp.Text = "";
             }
         } else {
             MessageBox.Show("Le nouveau mot de passe et sa confirmation ne correspondent pas.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
             txtNouvMdp.Text = "";
             txtCnfNouvMdp.Text = "";
         }
     } else {
         MessageBox.Show("Veuillez renseigner tous les champs.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #7
0
        public void LoadFromDB(MySqlDataReader reader)
        {
            Decks.ForEach(v => v.Clear());

            while (reader.Read())
            {
                DeckType deckType = (DeckType)reader.GetInt32(0);
                Int32 slotNo = reader.GetInt16(1);
                Int32 characterNo = reader.GetInt32(2);

                this[deckType].Characters[slotNo] = _user.InvenCharacter.Find(characterNo);
            }
        }
Exemple #8
0
        public void LoadFromDB(MySqlDataReader reader)
        {
            Items.Clear();
            while (reader.Read())
            {
                Int32 itemNo = reader.GetInt32(0);
                Int32 itemId = reader.GetInt32(1);
                Item ch = new Item(_user, itemId, itemNo);
                ch.PromotionId = reader.GetInt16(2);
                ch.Quantity = reader.GetInt32(3);

                Items.Add(ch);
            }
        }
Exemple #9
0
        private User createUserFromDataReader(MySqlDataReader dataReader)
        {
            if (!dataReader.HasRows) return null;

            dataReader.Read();
            User user = new User(dataReader["login"].ToString(), dataReader["password"].ToString(),
                        dataReader["name"].ToString());

            EvaluetionMethod em;
            int evaluetionMethod = dataReader.GetInt16("evaluetionMethod");

            if(evaluetionMethod == 0)
                em = EvaluetionMethod.Grade;
            else
                em = EvaluetionMethod.Stars;

            user.setEvaluetionMethodInfo(em, (float) dataReader.GetInt16("lowerLimit"),
                                             (float) dataReader.GetInt16("higherLimit"),
                                              float.Parse(dataReader["step"].ToString()));
            return user;
        }
Exemple #10
0
 public static int GetIntFromRdr(MySql.Data.MySqlClient.MySqlDataReader rdr, string column)
 {
     try
     {
         int ord = rdr.GetOrdinal(column);
         if (rdr[ord] == DBNull.Value)
         {
             return(0);
         }
         string typeName = rdr.GetDataTypeName(ord);
         if (typeName == "TINYINT")
         {
             return(rdr.GetInt16(ord));
         }
         return(rdr.GetInt32(ord));
     }
     catch (Exception exc)
     {
         log.Error("GetIntFromRdr", exc);
         return(0);
     }
 }
Exemple #11
0
        public void LoadFromDB(MySqlDataReader reader)
        {
            Items.Clear();
            while (reader.Read())
            {
                Int32 energyId = reader.GetInt16(0);
                Int32 point = reader.GetInt32(1);
                DateTime lastUpdateTime = reader.GetDateTime(2);

                Items.Add(new Data(_user, energyId, point, lastUpdateTime));
            }
        }
        public ContentResult OnPostGetUserPreferencesAsync()
        {
            var autoscreen    = "";
            var tahajjud      = "";
            int?establishid   = null;
            int?events        = null;
            int?viewmode      = null;
            var establishname = "";
            var tweetid       = "";
            var audiourl      = "";
            var videocdn      = "";
            var videourl      = "";
            var cameradesc    = "";
            int?micstatus     = null;



            IConfigurationRoot configuration = new ConfigurationBuilder()
                                               .SetBasePath(Directory.GetCurrentDirectory())
                                               .AddJsonFile("appsettings.json")
                                               .Build();
            var connectionString = configuration.GetConnectionString("dbAirMasjid");


            try
            {
                using (MySqlConnection conn = new MySqlConnection(connectionString))
                {
                    using (MySqlCommand cmd = new MySqlCommand("getuserpreferences", conn))
                    {
                        //  cmd.CommandText = "updateestablishment";

                        cmd.CommandType = System.Data.CommandType.StoredProcedure;
                        conn.Open();

                        var serialno = serial;
                        cmd.Parameters.AddWithValue("@serialno", serial);


                        MySql.Data.MySqlClient.MySqlDataReader myReader = default(MySql.Data.MySqlClient.MySqlDataReader);

                        myReader = cmd.ExecuteReader();

                        while (myReader.Read())
                        {
                            autoscreen    = myReader.GetString(0);
                            tahajjud      = myReader.GetString(1);
                            establishid   = myReader.GetInt16(2);
                            events        = myReader.GetInt16(3);
                            viewmode      = myReader.GetInt16(4);
                            establishname = myReader.GetString(5);
                            tweetid       = myReader.GetString(6);
                            audiourl      = myReader.GetString(7);
                            videocdn      = myReader.GetString(8);
                            videourl      = myReader.GetString(9);
                            cameradesc    = myReader.GetString(10);
                            micstatus     = myReader.GetInt16(11);

                            //  establishid = myReader.GetString(2);
                            //  tblCameraLookup.Description,
                        }

                        // cmd.ExecuteNonQuery();
                        conn.Close();

                        //  return Content(autoscreen,tahajjud);

                        return(Content("{ " +
                                       "\"autoscreen\":" + "\"" + autoscreen + "\"" +
                                       ",\"tahajjud\":" + "\"" + tahajjud + "\"" +
                                       ",\"establishid\":" + establishid +
                                       ",\"events\":" + events +
                                       ",\"viewmode\":" + viewmode +
                                       ",\"establishname\":" + "\"" + establishname + "\"" +
                                       ",\"tweetid\":" + "\"" + tweetid + "\"" +
                                       ",\"audiourl\":" + "\"" + audiourl + "\"" +
                                       ",\"videocdn\":" + "\"" + videocdn + "\"" +
                                       ",\"videourl\":" + "\"" + videourl + "\"" +
                                       ",\"cameradesc\":" + "\"" + cameradesc + "\"" +
                                       ",\"micstatus\":" + micstatus +
                                       "}", "application/json"));

                        //  return Content("{ \"name\":\"John\", \"age\":31, \"city\":\"New York\" }", "application/json");
                    }
                }
            }
            catch (Exception ex)
            {
                var Message = $"Failed to get user preferences " + ex.Message;
                _logger.LogWarning(Message);

                return(Content("failed"));
            }
        }
 private MedicalInformation constructMedical(MySqlDataReader medicalReader)
 {
     MedicalInformation newMedical = new MedicalInformation();
     newMedical.MedicalID = medicalReader.GetInt16("Medical_ID");
     newMedical.Allergies = SafeGetString(medicalReader, "Allergies");
     newMedical.Medication = SafeGetString(medicalReader, "Medication");
     newMedical.Other = SafeGetString(medicalReader, "Other");
     newMedical.Doctor = medicalReader.GetString("Doctor");
     newMedical.DoctorAddress = constructAddress(medicalReader);
     return newMedical;
 }
 private Employee constructEmployee(MySqlDataReader staffReader)
 {
     Employee newEmployee = new Employee();
     newEmployee.NINo = staffReader.GetString("National_Insurance_Number");
     newEmployee.FirstName = staffReader.GetString("First_Name");
     newEmployee.LastName = staffReader.GetString("Last_Name");
     newEmployee.Position = staffReader.GetString("Position");
     newEmployee.Gender = staffReader.GetChar("Gender");
     newEmployee.DateStarted = staffReader.GetDateTime("Date_Started");
     newEmployee.DateFinished = SafeGetDateTime(staffReader, "Date_Finished");
     newEmployee.PVGDate = staffReader.GetDateTime("PVG_Date");
     newEmployee.HolidaysEntitled = staffReader.GetInt16("Holidays_Entitled");
     newEmployee.HolidaysTaken = staffReader.GetInt16("Holidays_Taken");
     newEmployee.WeeksHours = staffReader.GetInt16("Hours");
     newEmployee.Address = constructAddress(staffReader);
     newEmployee.DOB = staffReader.GetDateTime("DOB");
     newEmployee.Salary = staffReader.GetDecimal("Salary");
     newEmployee.HomePhone = staffReader.GetString("Home_Phone");
     newEmployee.MobilePhone = staffReader.GetString("Mobile_Phone");
     newEmployee.Email = staffReader.GetString("Email");
     newEmployee.Training = SafeGetString(staffReader, "Training");
     newEmployee.Medical = constructMedical(staffReader);
     //EC...
     return newEmployee;
 }
        private Child constructChild(MySqlDataReader childrenReader)
        {
            Child newChild = new Child();
            newChild.ChildID = childrenReader.GetInt32("Child_Id");
            newChild.FirstName = childrenReader.GetString("First_Name");
            newChild.LastName = childrenReader.GetString("Last_Name");
            newChild.Gender = childrenReader.GetChar("Gender");
            newChild.DOB = childrenReader.GetDateTime("DOB");

            newChild.FirstLanguage = childrenReader.GetString("First_Language");
            newChild.RoomAttending = childrenReader.GetString("Room_Attending");
            //newChild.Sibling = SafeGetInt(childrenReader, "Sibling");
            newChild.DateApplied = childrenReader.GetDateTime("Date_Applied");
            newChild.DateLeft = SafeGetDateTime(childrenReader, "Date_Left");
            newChild.Attendance = constructAttendance(childrenReader);
            newChild.ExtraDays = childrenReader.GetInt16("Extra_Days");
            newChild.Teas = childrenReader.GetInt16("Teas");
            newChild.MedicalInfo = constructMedical(childrenReader);

            //newChild.ParentsIDs.Add(childrenReader.GetInt16(16));
            //newChild.EmergencyContactsIDs.Add(childrenReader.GetInt16(16));
            //Get parents
            //foreach (int parentID in selectChildsParentIDs(newChild.ChildID))
            //    newChild.Parents.Add(constructParent(childrenReader, 16));

            ////Get Emergency Contacts
            //foreach (int contactID in selectChildsContactIDs(newChild.ChildID))
            //    newChild.EmergencyContacts.Add(selectEmergencyContact(contactID), 30);
            return newChild;
        }
Exemple #16
0
        private Video createVideoFromDataReader(MySqlDataReader dataReader)
        {
            if (!dataReader.HasRows)
                return null;
            dataReader.Read();

            int code = dataReader.GetInt16("code");

            String category;
            if (!dataReader["categoryCode"].Equals(DBNull.Value))
                category = getCategory(dataReader.GetInt16("categoryCode"));
            else
                category = "";

            String originalTitle;
            if(!dataReader["originalTitle"].Equals(DBNull.Value))
                originalTitle = dataReader["originalTitle"].ToString();
            else
                originalTitle = "";

            String nationalTitle;
            if (!dataReader["nationalTitle"].Equals(DBNull.Value))
                nationalTitle = dataReader["nationalTitle"].ToString();
            else
                nationalTitle = "";

            String director;
            if (!dataReader["director"].Equals(DBNull.Value))
                director = dataReader["director"].ToString();
            else
                director = "";

            int year;
            if (!dataReader["year"].Equals(DBNull.Value))
                year = dataReader.GetInt16("year");
            else
                year = 0;

            int duration;
            if (!dataReader["duration"].Equals(DBNull.Value))
                duration = dataReader.GetInt16("duration");
            else
                duration = 0;

            List<String> tagsList = populateTags(code);
            String[] tags;
            if(tagsList.Count > 0)
                tags = tagsList.ToArray();
            else
                tags = new String[0];
            Video video = new Video(code, originalTitle, nationalTitle, director, year, duration, category, tags);

            return video;
        }
        /// <summary>
        /// Reads a relation member from the MySqlDataReader
        /// </summary>
        /// <param name="reader">The MySqlDataReader to attempt reading the relation member from</param>
        /// <returns>The relation member read from the MySqlReader</returns>
        private RelationMember ReadRelationMember(MySqlDataReader reader)
        {
            var relation_member = new RelationMember();

            relation_member.MemberType = ConvertMemberType(reader.GetInt16(0));
            relation_member.MemberId = reader.GetInt64(1);
            relation_member.MemberRole = reader.GetString(2);

            return relation_member;
        }
Exemple #18
0
        public void LoadFromDB(MySqlDataReader reader)
        {
            Items.Clear();
            while (reader.Read())
            {
                Int32 resourceId = reader.GetInt16(0);
                Int32 point = reader.GetInt32(1);

                Items.Add(new Data(resourceId, point));
            }
        }
 public void SetProperty(object obj, SelectQueryFieldStore item,MySqlDataReader rdr)
 {
     var pinfo = obj.GetType().GetProperty(item.Property);
     if (pinfo != null)
     {
         switch (item.Type)
         {
             case SelectQueryFieldStore.DataTypes.Int:
                 pinfo.SetValue(obj, rdr.GetInt32(item.Column), null);
                 break;
             case SelectQueryFieldStore.DataTypes.Bool:
                 pinfo.SetValue(obj, Convert.ToBoolean(rdr.GetInt32(item.Column)), null);
                 break;
             case SelectQueryFieldStore.DataTypes.Float:
                 pinfo.SetValue(obj, rdr.GetFloat(item.Column), null);
                 break;
             case SelectQueryFieldStore.DataTypes.String:
                 pinfo.SetValue(obj, rdr.GetString(item.Column), null);
                 break;
             case SelectQueryFieldStore.DataTypes.Long:
                 pinfo.SetValue(obj, rdr.GetInt64(item.Column), null);
                 break;
             case SelectQueryFieldStore.DataTypes.Short:
                 pinfo.SetValue(obj, rdr.GetInt16(item.Column), null);
                 break;
             default:
                 pinfo.SetValue(obj, rdr.GetString(item.Column), null);
                 break;
         }
     }
 }
Exemple #20
0
 // 取 dr 中某字段的数据并返回
 public static object GetValue( DbColumn col, MySqlDataReader r, int idx )
 {
     switch( col.dataType )
     {
     case DbDataTypes.Boolean:
         return r.GetBoolean( idx );
     case DbDataTypes.Int8:
         return r.GetSByte( idx );
     case DbDataTypes.Int16:
         return r.GetInt16( idx );
     case DbDataTypes.Int32:
         return r.GetInt32( idx );
     case DbDataTypes.Int64:
         return r.GetInt64( idx );
     case DbDataTypes.UInt8:
         return r.GetByte( idx );
     case DbDataTypes.UInt16:
         return r.GetUInt16( idx );
     case DbDataTypes.UInt32:
         return r.GetUInt32( idx );
     case DbDataTypes.UInt64:
         return r.GetUInt64( idx );
     case DbDataTypes.Float:
         return r.GetFloat( idx );
     case DbDataTypes.Double:
         return r.GetDouble( idx );
     case DbDataTypes.DateTime:
         return r.GetDateTime( idx );
     case DbDataTypes.String:
         return r.GetString( idx );
     case DbDataTypes.Bytes:
         var len = (int)r.GetBytes( idx, 0, null, 0, 0 );
         var buf = new byte[ len ];
         r.GetBytes( idx, 0, buf, 0, len );
         return buf;
     default:
         throw new Exception( "unsupported DbType" );
     }
 }
Exemple #21
0
 // 往 dr 填充 r 于 i 索引的值
 public static void FillValue( DbRow dr, MySqlDataReader r, int i )
 {
     switch( dr.parent.columns[ i ].dataType )
     {
     case DbDataTypes.Boolean:
         dr[ i ].Assign( r.GetBoolean( i ) ); break;
     case DbDataTypes.Int8:
         dr[ i ].Assign( r.GetSByte( i ) ); break;
     case DbDataTypes.Int16:
         dr[ i ].Assign( r.GetInt16( i ) ); break;
     case DbDataTypes.Int32:
         dr[ i ].Assign( r.GetInt32( i ) ); break;
     case DbDataTypes.Int64:
         dr[ i ].Assign( r.GetInt64( i ) ); break;
     case DbDataTypes.UInt8:
         dr[ i ].Assign( r.GetByte( i ) ); break;
     case DbDataTypes.UInt16:
         dr[ i ].Assign( r.GetUInt16( i ) ); break;
     case DbDataTypes.UInt32:
         dr[ i ].Assign( r.GetUInt32( i ) ); break;
     case DbDataTypes.UInt64:
         dr[ i ].Assign( r.GetUInt64( i ) ); break;
     case DbDataTypes.Float:
         dr[ i ].Assign( r.GetFloat( i ) ); break;
     case DbDataTypes.Double:
         dr[ i ].Assign( r.GetDouble( i ) ); break;
     case DbDataTypes.DateTime:
         dr[ i ].Assign( r.GetDateTime( i ) ); break;
     case DbDataTypes.String:
         dr[ i ].Assign( r.GetString( i ) ); break;
     case DbDataTypes.Bytes:
         var len = (int)r.GetBytes( i, 0, null, 0, 0 );
         var buf = new byte[ len ];
         r.GetBytes( i, 0, buf, 0, len );
         dr[ i ].Assign( buf );
         break;
     default:
         break;
     }
 }
Exemple #22
0
        private void form1_Load(object sender, EventArgs e)
        {
            res = 0;

            this.ControlBox = false;
            hh = RulesForm.temp / 60;
            mm = RulesForm.temp % 60;
            ss = 0;
            timer1.Enabled = true;
            timer1.Interval = 1000;
            label1.Text = "Time :" +hh + ":" + mm + ":" + ss;
               try
            {
                con.Open();
                //to get the number of questions for the subject
                cmd=new MySqlCommand("select tot_quest from exam where eid='"+SelectExam.exam_code+"'",con);
                dr1 = cmd.ExecuteReader();
                dr1.Read();
                noq = dr1.GetInt32("tot_quest");
                ticked = new bool[noq];
                status = new bool[noq];
                ans = new  char[noq];
                ans_status = new RadioButton[noq];
                drawcontrols(sender,e,noq);
                dr1.Close();
                label2.Text = "1 Out Of " + noq;

               //Initialize form with 1st question with respect to the subject selected
                cmd = new MySqlCommand("select * from test where qno=1 and ecode='"+SelectExam.exam_code+"'", con);
               dr1 = cmd.ExecuteReader();
                dr1.Read();
                qno.Text = "Q.No. " + dr1["qno"];
               textBox1.Text = dr1["quest"].ToString();

                opt1.Text = dr1["opt1"].ToString();
                opt2.Text = dr1["opt2"].ToString();
                opt3.Text = dr1["opt3"].ToString();
                opt4.Text = dr1["opt4"].ToString();
                answer = dr1.GetInt16("ans");
                mark = dr1.GetInt16("mark");
                dr1.Close();
                con.Close();
               }
            catch (Exception ex)
            {
                MessageBox.Show("Invalid Exam Code...!","Exam Code Error");
                label1.Visible = false;
                this.Hide();
                new SelectExam().Show();
            }
        }
        /// <summary>
        /// Reads a relation id and relation member from the MySqlDataReader
        /// </summary>
        /// <param name="reader">The MySqlDataReader to attempt reading the relation id and member from</param>
        /// <returns>The relation member and relation id read from the MySqlReader</returns>
        private Tuple<long, RelationMember> ReadRelationIdAndMember(MySqlDataReader reader)
        {
            var relation_member = new RelationMember();

            relation_member.MemberType = ConvertMemberType(reader.GetInt16(1));
            relation_member.MemberId = reader.GetInt64(2);
            relation_member.MemberRole = reader.GetString(3);

            return new Tuple<long,RelationMember>(reader.GetInt64(0), relation_member);
        }