GetDouble() public method

public GetDouble ( int i ) : double
i int
return double
Beispiel #1
0
 public static Champion Mapper(MySqlDataReader r)
 {
     var c = new Champion();
     c.Id = r.GetInt32("Id");
     c.Name = r.GetString("Name");
     c.Title = r.GetString("Title");
     c.Stat = new Stat();
     c.Stat.Mana = r.GetDouble("Mana");
     c.Stat.ManaPerLv = r.GetDouble("ManaPerLevel");
     c.Stat.MagicResist = r.GetDouble("MagicResist");
     c.Stat.MagicResistPerLv = r.GetDouble("MagicResistPerLevel");
     return c;
 }
Beispiel #2
0
        public static PyObject DBColumnToPyObject(int index, ref MySqlDataReader reader)
        {
            Type type = reader.GetFieldType(index);

            switch (type.Name)
            {
                case "String":
                    return new PyString(reader.GetString(index));
                case "UInt32":
                case "Int32":
                case "UInt16":
                case "Int16":
                case "SByte":
                case "Byte":
                    return new PyInt(reader.GetInt32(index));
                case "UInt64":
                case "Int64":
                    return new PyLongLong(reader.GetInt64(index));
                case "Byte[]":
                    return new PyBuffer((byte[])reader.GetValue(index));
                case "Double":
                    return new PyFloat(reader.GetDouble(index));
                case "Decimal":
                    return new PyFloat((double)reader.GetDecimal(index));
                case "Boolean":
                    return new PyBool(reader.GetBoolean(index));
                default:
                    Log.Error("Database", "Unhandled MySQL type " + type.Name);
                    break;
            }

            return null;
        }
Beispiel #3
0
    public void ChangeReviewSummary()
    {
        Transform starPanel  = reviewSummaryPanel.GetChild(1);
        Transform scorePanel = reviewSummaryPanel.GetChild(2);

        //string sql = "SELECT COUNT(*), AVG(CAST(score as FLOAT)) FROM review GROUP BY productID HAVING productID = " + product.id + ";";
        string sql = "SELECT COUNT(*), AVG(score) FROM review GROUP BY productID HAVING productID = " + product.id + ";";

        MySql.Data.MySqlClient.MySqlDataReader reader = DbConnecter.instance.Reader(sql);
        int   reviewer = 0;
        float score    = 0;

        if (reader.Read())
        {
            reviewer = reader.GetInt32(0);
            score    = (float)reader.GetDouble(1);
        }
        reader.Close();
        DbConnecter.instance.CloseConnection();
        for (int i = 0; i < 5; i++)
        {
            float fillAmount = Mathf.Clamp(score - i, 0, 1);
            Image yellowStar = starPanel.GetChild(i).GetChild(0).GetComponent <Image>();
            yellowStar.fillAmount = fillAmount;
        }
        Text scoreText = scorePanel.GetChild(0).GetComponent <Text>();

        scoreText.text = score.ToString("0.00") + " (" + reviewer + ")";
    }
        public void checkApprovalNeeded()
        {
            conn = new MySql.Data.MySqlClient.MySqlConnection(ConnString);
            conn.Open();
            double count = 0;
            double item_price;
            double qty;
            double policy_amount;

            //try
            //{
            cmd             = conn.CreateCommand();
            cmd.CommandText = "SELECT * FROM item where reqid='" + tb_reqid.Text + "' ";
            reader          = cmd.ExecuteReader();
            while (reader.Read())
            {
                item_price = reader.GetDouble("item_price");
                qty        = reader.GetDouble("quantity");
                count      = count + (item_price * qty);
            }

            conn.Close();

            conn.Open();
            cmdd             = conn.CreateCommand();
            cmdd.CommandText = "SELECT * FROM policy where policy_name='Requisition Approval'";

            reader1 = cmdd.ExecuteReader();
            if (reader1.Read())
            {
                policy_amount = reader1.GetDouble("amount");

                if (count < policy_amount)
                {
                    imgbtn_assignedto.Enabled = false;
                    System.Diagnostics.Debug.WriteLine(count);
                    System.Diagnostics.Debug.WriteLine("Hellooo");
                }
            }
            conn.Close();
            //}

            //catch (Exception ex)
            //{
            //    Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Fisrt add the items');</script>");
            //}
        }
 public static ProjekcijaDTO readerToProjekcijaDTO(MySqlDataReader reader,FilmDTO film)
 {
     ProjekcijaDTO projekcija = new ProjekcijaDTO();
     projekcija.Id = reader.GetInt32("idProjekcija");
     projekcija.Vrijeme = reader.GetDateTime("vrijemeProjekcija");
     projekcija.Cijena = reader.GetDouble("cijenaProjekcija");
     projekcija.Film =film;
     projekcija.Sala = MySqlSalaDAO.readerToSalaDTO(reader);
     return projekcija;
 }
 public static ProjekcijaDTO readerToProjekcijaDTO(MySqlDataReader reader, SalaDTO sala)
 {
     ProjekcijaDTO projekcija = new ProjekcijaDTO();
     projekcija.Id = reader.GetInt32("idProjekcija");
     projekcija.Vrijeme = reader.GetDateTime("vrijemeProjekcija");
     projekcija.Cijena = reader.GetDouble("cijenaProjekcija");
     projekcija.Film = new MySqlFilmDAO().getById(reader.GetInt32("idFilm"));
     projekcija.Sala = sala;
     return projekcija;
 }
 public FinanceiroType execReader(MySqlDataReader dr)
 {
     FinanceiroType type = new FinanceiroType();
     type.IdFinanceiro = Convert.ToInt32(dr["id_financeiro"].ToString());
     type.IdAssociacao = Convert.ToInt32(dr["id_associacao"].ToString());
     type.Titulo = dr["titulo"].ToString();
     type.Valor = dr.GetDouble("valor");
     type.Data = dr["data"].ToString();
     type.Tipo = dr["tipo"].ToString();
     return type;
 }
 public static StavkaOtpremniceDTO readerToStavkaOtpremniceDTO(MySqlDataReader reader)
 {
     StavkaOtpremniceDTO stavka = new StavkaOtpremniceDTO();
     stavka.Kolicina = reader.GetDouble("Kolicina");
     stavka.VeleprodajnaCijena = reader.GetDouble("VeleprodajnaCijena");
     stavka.Rabat = reader.GetDouble("Rabat");
     stavka.CijenaSaRabatom = reader.GetDouble("CijenaSaRabatom");
     stavka.IznosSaRabatom = reader.GetDouble("IznosSaRabatom");
     stavka.VeleprodajniIznos = reader.GetDouble("VeleprodajniIznos");
     return stavka;
 }
        protected void update(object sender, GridViewUpdateEventArgs e)
        {
            int    id   = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
            string name = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("salIncrease")).Text;

            int empid = Convert.ToInt32(((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtempid")).Text);

            conn = new MySql.Data.MySqlClient.MySqlConnection(constr);
            conn.Open();
            data   = "select Salary from hr.hire_emp where EmployeeID = '" + empid + "'";
            cmd    = new MySql.Data.MySqlClient.MySqlCommand(data, conn);
            reader = cmd.ExecuteReader();
            reader.Read();
            double s   = Convert.ToDouble(name);
            double sal = reader.GetDouble(0);

            //double x = Convert.ToDouble(sal);

            conn.Close();
            conn.Open();
            double sum = sal + s;

            data = "update hr.hire_emp set salary = '" + sum + "' where EmployeeID = '" + empid + "'";
            cmd  = new MySql.Data.MySqlClient.MySqlCommand(data, conn);
            cmd.ExecuteNonQuery();
            conn.Close();
            //TextBox1.Text = name;

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


            //data = "update training set training_name = '" + name + "' ,start_date = '" + stdate + "' ,end_date = '" + enddate + "' ,train_time = '" + tr_time + "' where training_id = '" + id + "';";
            //cmd = new MySql.Data.MySqlClient.MySqlCommand(data, conn);
            //cmd.ExecuteNonQuery();

            //conn.Close();

            GridView1.EditIndex = -1;// no row in edit mode

            GetData();
        }
Beispiel #10
0
    public void WriteReview(int amount)
    {
        int productID = 1;

        for (int i = 0; i < amount; i++)
        {
            string email  = "changyeong" + i;
            int    score  = UnityEngine.Random.Range(1, 6);
            int    first  = UnityEngine.Random.Range(0, 5);
            int    second = UnityEngine.Random.Range(0, 6);
            int    third  = UnityEngine.Random.Range(0, 3);
            int    fourth = UnityEngine.Random.Range(0, 6);
            int    fifth  = UnityEngine.Random.Range(0, 5);
            string sql    = "SELECT productReviews FROM member WHERE email = '" + email + "';";
            MySql.Data.MySqlClient.MySqlDataReader reader = DbConnecter.instance.Reader(sql);
            reader.Read();
            string productReviews = "";
            if (reader.IsDBNull(0) == false)
            {
                productReviews = reader.GetString(0);
            }
            reader.Close();
            productReviews = productReviews + productID + ';';

            sql = "INSERT INTO review VALUES(" + "'" + email + "', " + productID + ", " + score + ", " + first + ", " + second + ", " + third + ", " + fourth + ", " + fifth + ");";
            DbConnecter.instance.ExecuteSQL(sql, false);
            sql = "UPDATE member SET productReviews = '" + productReviews + "' WHERE email = '" + email + "';";
            DbConnecter.instance.ExecuteSQL(sql, false);
            sql    = "SELECT COUNT(*), AVG(CAST(score as FLOAT)) FROM review GROUP BY productID HAVING productID = " + productID + ";";
            reader = DbConnecter.instance.Reader(sql);
            reader.Read();
            int   reviewer = reader.GetInt32(0);
            float grade    = (float)reader.GetDouble(1);
            reader.Close();
            sql = "UPDATE product SET grade = " + grade + ", reviewer = " + reviewer + " WHERE id = " + productID + ";";
            DbConnecter.instance.ExecuteSQL(sql, true);
            DbConnecter.instance.CloseConnection();
            Debug.Log(i);
        }
    }
        public List<string> Unique_GetListOfIds(string table)
        {
            List<string> idList = new List<string>();

            cmd = new MySqlCommand("SELECT distinct(id) FROM " + Database + "." + table, connection);
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                idList.Add(reader.GetDouble(0).ToString());
            }
            reader.Close();

            return idList;
        }
        protected ProductDetail getProductDetailFromDataReader(MySqlDataReader datareader)
        {

            ProductDetail productDetail = new ProductDetail
            {
                detailId = datareader.GetInt32("detailID"),
                verkoopprijs = datareader.GetDouble("verkoopprijs"),
                inkoopprijs = datareader.GetDouble("inkoopprijs"),
                maatId = datareader.GetInt32("maatId"),
                voorraad = datareader.GetInt32("voorraad"),
            };
            return productDetail;
        }
Beispiel #13
0
 public static Rune Mapper(MySqlDataReader reader)
 {
     var r = new Rune();
     r.Id = reader.GetInt32("Id");
     r.Name = reader.GetString("Name");
     r.Ap = reader.GetDouble("Ap");
     r.ApPerLevel = reader.GetDouble("ApPerLevel");
     r.Mana = reader.GetDouble("Mana");
     r.ManaPerLevel = reader.GetDouble("ManaPerLevel");
     r.MagicResist = reader.GetDouble("MagicResist");
     r.MagicResistPerLevel = reader.GetDouble("MagicResistPerLevel");
     r.MagicPenetrationFlat = reader.GetDouble("MagicPenetrationFlat");
     return r;
 }
Beispiel #14
0
        protected void btn_Assign_Click(object sender, EventArgs e)
        {
            conn = new MySql.Data.MySqlClient.MySqlConnection(ConnString);
            try
            {
                //check whether all the fields are not null
                bool fieldsReq = RequiredFieldValidate();
                if (fieldsReq)
                {
                    String listOfItemsnqty = (tb_items_withqty.Text).Trim();
                    if (listOfItemsnqty.EndsWith(","))
                    {
                        listOfItemsnqty = listOfItemsnqty.Substring(0, listOfItemsnqty.Length - 1);
                    }
                    String[] arrayOfItemsnqty = listOfItemsnqty.Split(',');
                    //Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('"+ arrayOfAssignedManagers[2]  + "');</script>");
                    String Item_name;
                    String Item_qty;
                    double count = 0;
                    for (int i = 0; i < arrayOfItemsnqty.Length; i++)
                    {
                        conn.Open();
                        try
                        {
                            Item_name = arrayOfItemsnqty[i].Split('-')[0].Trim();
                            Item_qty  = arrayOfItemsnqty[i].Split('-')[1].Trim();
                            System.Diagnostics.Debug.WriteLine(Item_name);
                            System.Diagnostics.Debug.WriteLine(Item_qty);
                            cmd             = conn.CreateCommand();
                            cmd.CommandText = "SELECT * FROM all_items where item_name='" + Item_name + "' ";

                            reader = cmd.ExecuteReader();
                            if (reader.Read())
                            {
                                hiiden_description.Text = reader.GetString("description");
                                hidden_itemprice.Text   = reader.GetString("item_price");
                                hidden_uom.Text         = reader.GetString("uom");
                                hidden_supplier.Text    = reader.GetString("supplier");
                                hidden_sup_email.Text   = reader.GetString("supplier_email");
                            }
                            conn.Close();

                            //Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('"+ hiiden_designation.Text + "');</script>");
                            conn.Open();
                            queryStr = "insert into item (item_name,description,uom,item_price,quantity,supplier,supplier_email,reqid) values ('" + Item_name.Trim() + "','" + hiiden_description.Text + "','" + hidden_uom.Text + "','" + Convert.ToDouble(hidden_itemprice.Text) + "','" + Convert.ToDouble(Item_qty) + "','" + hidden_supplier.Text + "','" + hidden_sup_email.Text + "','" + Convert.ToInt32(tb_reqid.Text) + "')";
                            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
                            cmd.ExecuteNonQuery();
                            conn.Close();
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Succesfully Inserted.!  ');</script>");
                            conn.Close();

                            count = count + (Convert.ToDouble(hidden_itemprice.Text) * Convert.ToDouble(Item_qty));
                        }
                        catch
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('failed');</script>");
                        }
                    }


                    //queryStr = "insert into assigned_employee (name,designation,email,reqid) values ('" + tb_expenseid.Text + "','" + tb_expensedate.Text + "','" + Convert.ToString(list_expensetype.SelectedValue) + "','" + tb_expensedescription.Text + "','" + tb_expenseamount.Text + "')";
                    //cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
                    //cmd.ExecuteNonQuery();
                    //Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Succesfully Inserted.!  ');</script>");
                    tb_itemPrice.Text = count.ToString();

                    conn = new MySql.Data.MySqlClient.MySqlConnection(ConnString);
                    conn.Open();
                    double policy_amount;
                    try
                    {
                        cmd             = conn.CreateCommand();
                        cmd.CommandText = "SELECT * FROM policy where policy_name='Requisition Approval'";

                        reader = cmd.ExecuteReader();

                        if (reader.Read())
                        {
                            policy_amount = reader.GetDouble("amount");

                            //if (count > policy_amount)
                            //{
                            //    //Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('ALERT..!!! \n Item cost exceeds the policy amount. Need supervisor approval for this.!!!');</script>");
                            //    lbl_warning.Visible = true;
                            //    lbl_done.Visible = false;
                            //}

                            if (checkPlicyAmount(count, policy_amount))
                            {
                                lbl_warning.Visible = true;
                                lbl_done.Visible    = false;
                            }
                            else
                            {
                                //Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('ALERT..!!! \n Item cost exceeds the policy amount. Need supervisor approval for this.!!!');</script>");
                                lbl_done.Visible    = true;
                                lbl_warning.Visible = false;
                            }
                        }
                    }



                    catch { }
                    conn.Close();
                }

                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Please add items to create requisition..!!');</script>");
                }
            }

            catch (Exception ex)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Data insertion failed');</script>");
            }
        }
Beispiel #15
0
        private void cb_Agregar_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (rb_Materiales.Checked == true)
            {

                query = "SELECT Codigo, Descripcion, Unidad, Costo, Rendimiento, Importe FROM listapu.materiales WHERE Codigo = '" + cb_Agregar.Text + "';";
                con = new MySqlConnection(constring);
                cmd = new MySqlCommand(query, con);
                con.Open();
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    string Codigo = reader.GetString("Codigo");
                    string Descripcion = reader.GetString("Descripcion");
                    string Unidad = reader.GetString("Unidad");
                    double Costo = reader.GetDouble("Costo");
                    double Rendimiento = reader.GetDouble("Rendimiento");
                    double Importe = reader.GetDouble("Importe");

                    txtCodigo.Text = Codigo;
                    txtDesc.Text = Descripcion;
                    txtUnidad.Text = Unidad;
                    txtCosto.Text = Costo.ToString("0.##");

                    lbl_Ocupacion.Visible = false;
                    lbl_Descripcion.Visible = true;
                    lbl_Sueldo.Visible = false;
                    lbl_Costo.Visible = true;
                    lbl_Salario.Visible = false;
                    lbl_CostoHr.Visible = false;
                }
                con.Close();
            }
            else
                if (rB_ManodeObra.Checked == true)
                {
                    query = "SELECT Codigo, Ocupacion, SueldoSemanalVigente, SalarioTotal, Rendimiento, Importe FROM listapu.manodeobra WHERE Codigo = '" + cb_Agregar.Text + "';";
                    con = new MySqlConnection(constring);
                    cmd = new MySqlCommand(query, con);
                    con.Open();
                    reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        string Codigo = reader.GetString("Codigo");
                        string ocupacion = reader.GetString("Ocupacion");
                        double Sueldo = reader.GetDouble("SueldoSemanalVigente");
                        double Salario = reader.GetDouble("SalarioTotal");
                        double Rendimiento = reader.GetDouble("Rendimiento");
                        double Importe = reader.GetDouble("Importe");

                        txtCodigo.Text = Codigo;
                        txtDesc.Text = ocupacion;
                        txtUnidad.Text = Sueldo.ToString("0.##");
                        txtCosto.Text = Salario.ToString("0.##");
                    }
                    con.Close();
                    lbl_Ocupacion.Visible = true;
                    lbl_Descripcion.Visible = false;
                    lbl_Sueldo.Visible = true;
                    lbl_Costo.Visible = false;
                    lbl_Salario.Visible = true;
                    lbl_CostoHr.Visible = false;
                }
                else
                    if (rB_EqMaq.Checked == true)
                    {
                        query = "SELECT Codigo, Descripcion, Unidad, CostoHr, Rendimiento, Importe FROM listapu.equipo WHERE Codigo = '" + cb_Agregar.Text + "';";
                        con = new MySqlConnection(constring);
                        cmd = new MySqlCommand(query, con);
                        con.Open();
                        reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            string Codigo = reader.GetString("Codigo");
                            string Descripcion = reader.GetString("Descripcion");
                            string Unidad = reader.GetString("Unidad");
                            double Costo = reader.GetDouble("CostoHr");
                            double Rendimiento = reader.GetDouble("Rendimiento");
                            double Importe = reader.GetDouble("Importe");

                            txtCodigo.Text = Codigo;
                            txtDesc.Text = Descripcion;
                            txtUnidad.Text = Unidad;
                            txtCosto.Text = Costo.ToString("0.##");
                        }
                        con.Close();
                        lbl_Ocupacion.Visible = false;
                        lbl_Descripcion.Visible = true;
                        lbl_Sueldo.Visible = false;
                        lbl_Costo.Visible = false;
                        lbl_Salario.Visible = false;
                        lbl_CostoHr.Visible = true;
                    }
        }
 public static double? getDouble(MySqlDataReader dr, string column)
 {
     int ordinal = dr.GetOrdinal(column);
     if (dr.IsDBNull(ordinal))
     {
         return null;
     }
     else
     {
         return dr.GetDouble(ordinal);
     }
 }
Beispiel #17
0
    IEnumerator QueryDB(float seconds)
    {
        double xDiff, yDiff, xNewPos, yNewPos;

        // My Nexus 5
        //string query = "SELECT x, y from devicelocations where deviceID = '4192fe2d3b7fbf27';";
        //string query = "SELECT i, j, virtual from devicelocations where deviceID = '4192fe2d3b7fbf27';";

        //***
        //string query = "SELECT i, j from devicelocations where deviceID = '4192fe2d3b7fbf27';";
        string query = "SELECT i, j from devicelocations";

        //Group's Nexus 4
        //string query = "SELECT x, y from devicelocations where deviceID = 'c76129348d8acd2e';";
        //string query = "SELECT i, j, virtual from devicelocations where deviceID = 'c76129348d8acd2e';";

        while (true) {

            try {
                if (con.State.CompareTo(ConnectionState.Open) != 0) {
                    con.Open(); //this line causes the windows-1252 encoding error if I18N DLLs are not included, even though it only OPENS the connection & hasn't actually requested any data yet (easy solution - include the I18N DLLs)
                }
                using (con) {
                    using (cmd = new MySqlCommand(query, con)) {
                        read = cmd.ExecuteReader();
                        while (read.Read()) {
                            for (int i = 0; i < read.FieldCount; i++) {

                                //xDiff = Math.Abs(read.GetDouble(0) - anchorAtlasX);
                                xDiff = Math.Abs((read.GetDouble(0) - anchorAtlasI));
                                Double xDiffMeters = xDiff / pixelsPerMeter;

                                //yDiff = Math.Abs(read.GetDouble(1) - anchorAtlasY);
                                yDiff = Math.Abs((read.GetDouble(1) - anchorAtlasJ));
                                Double yDiffMeters = yDiff / pixelsPerMeter;

                                //virt = (read.GetBoolean(2));
                                //Debug.Log("virt flag: " + virt);

                                //if (read.GetDouble(0) > anchorAtlasX)
                                if (read.GetDouble(0) > anchorAtlasI) {
                                    //xNewPos = anchorUnityX + xDiff;
                                    xNewPos = anchorUnityX + xDiffMeters;
                                }
                                else {
                                    //xNewPos = anchorUnityX - xDiff;
                                    xNewPos = anchorUnityX - xDiffMeters;
                                }

                                //if (read.GetDouble(1) > anchorAtlasY)
                                if (read.GetDouble(1) > anchorAtlasJ) {
                                    //yNewPos = anchorUnityY - yDiff;
                                    yNewPos = anchorUnityY - yDiffMeters;
                                }
                                else {
                                    //yNewPos = anchorUnityY + yDiff;
                                    yNewPos = anchorUnityY + yDiffMeters;
                                }

                                // Vector of NewPoint
                                newPos = new Vector3((float)xNewPos, (float)transform.position.y, (float)yNewPos);

                                //Debug.Log("New Vector3: " + newPos.x + ", " + newPos.y + ", " + newPos.z);

                                // Actual transform (movement) code is in update() as that runs every frame whereas this method only runs every x seconds (it's a coroutine with WaitForSeconds at the end)
                            }
                        }
                    }
                }
            }
            catch (Exception e) {
                Debug.Log(e.ToString());
            }
            //Debug.Log("DB query on: " + System.DateTime.Now);
            yield return new WaitForSeconds(seconds);
        }
    }
Beispiel #18
0
        public void Change(string columnas, string bd, int rB)
        {
            query = "SELECT " + columnas + " FROM " + bd + " WHERE Codigo = '" + cb_Agregar.Text + "';";
            try
            {
                if (rB == 1)
                {
                    con = new MySqlConnection(constring);
                    cmd = new MySqlCommand(query, con);
                    con.Open();
                    reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        string Codigo = reader.GetString("Codigo");
                        string Descripcion = reader.GetString("Descripcion");
                        string Unidad = reader.GetString("Unidad");
                        double Costo = reader.GetDouble("Costo");
                        double Rendimiento = reader.GetDouble("Rendimiento");
                        double Importe = reader.GetDouble("Importe");

                        txtCodigo.Text = Codigo;
                        txtDesc.Text = Descripcion;
                        txtUnidad.Text = Unidad;
                        txtCosto.Text = Costo.ToString("0.##");
                    }
                    con.Close();
                    lbl_Ocupacion.Visible = false;
                    lbl_Descripcion.Visible = true;
                    lbl_Sueldo.Visible = false;
                    lbl_Costo.Visible = true;
                    lbl_Salario.Visible = false;
                    lbl_CostoHr.Visible = false;
                }
                else
                    if (rB == 2)
                    {
                        con = new MySqlConnection(constring);
                        cmd = new MySqlCommand(query, con);
                        con.Open();
                        reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            string Codigo = reader.GetString("Codigo");
                            string ocupacion = reader.GetString("Ocupacion");
                            double Sueldo = reader.GetDouble("SueldoSemVig");
                            double Salario = reader.GetDouble("SalarioTotal");
                            double Rendimiento = reader.GetDouble("Rendimiento");
                            double Importe = reader.GetDouble("Importe");

                            txtCodigo.Text = Codigo;
                            txtDesc.Text = ocupacion;
                            txtUnidad.Text = Sueldo.ToString("0.##");
                            txtCosto.Text = Salario.ToString("0.##");
                        }
                        con.Close();
                        lbl_Ocupacion.Visible = true;
                        lbl_Descripcion.Visible = false;
                        lbl_Sueldo.Visible = true;
                        lbl_Costo.Visible = false;
                        lbl_Salario.Visible = true;
                        lbl_CostoHr.Visible = false;
                    }
                    else
                        if (rB == 3)
                        {
                            con = new MySqlConnection(constring);
                            cmd = new MySqlCommand(query, con);
                            con.Open();
                            reader = cmd.ExecuteReader();
                            while (reader.Read())
                            {
                                string Codigo = reader.GetString("Codigo");
                                string Descripcion = reader.GetString("Descripcion");
                                string Unidad = reader.GetString("Unidad");
                                double Costo = reader.GetDouble("CostoHr");
                                double Rendimiento = reader.GetDouble("Rendimiento");
                                double Importe = reader.GetDouble("Importe");

                                txtCodigo.Text = Codigo;
                                txtDesc.Text = Descripcion;
                                txtUnidad.Text = Unidad;
                                txtCosto.Text = Costo.ToString("0.##");
                            }
                            con.Close();
                            lbl_Ocupacion.Visible = false;
                            lbl_Descripcion.Visible = true;
                            lbl_Sueldo.Visible = false;
                            lbl_Costo.Visible = false;
                            lbl_Salario.Visible = false;
                            lbl_CostoHr.Visible = true;
                        }

            }
            catch
            {
                MessageBox.Show("Error en la conexión de la Base de Datos", "Ocurrió un error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #19
0
        /// <summary>
        /// Populate object from database record
        /// </summary>
        /// <param name="reader">
        /// A <see cref="MySqlDataReader"/>
        /// </param>
        public void SetFromSql(MySqlDataReader reader)
        {
            for (int i = 0; i < reader.FieldCount; i++) {
                switch (reader.GetName(i)) {
                    case "id": Id = reader.GetInt64(i); break;
                    case "name": Name = reader.GetString(i); break;
                    case "fullname": FullName = reader.GetString(i); break;
                    case "sha1_hash": sha1Hash = reader.GetString(i); break;
                    case "directory_id": DirectoryId = reader.GetInt64(i); break;
                    case "mimetype": Mimetype = reader.GetString(i); break;
                    case "title":
                        Title = DB.IsNull(reader[i]) ? null : reader.GetString(i);
                        break;
                    case "description":
                        Description = DB.IsNull(reader[i]) ? null : reader.GetString(i);
                        break;
                    case "copyright":
                        Copyright = DB.IsNull(reader[i]) ? null : reader.GetString(i);
                        break;
                    case "width": Width = reader.GetInt32(i); break;
                    case "height": Height = reader.GetInt32(i); break;
                    case "size": Size = reader.GetInt64(i); break;
                    case "resolution": Resolution = reader.GetDouble(i); break;
                    case "exif":
                        Exif = DB.IsNull(reader[i]) ? null : reader.GetString(i);
                        break;
                    case "created": Created = reader.GetDateTime(i); break;
                    case "modified":
                        if (!DB.IsNull(reader[i]))
                            Modified = reader.GetDateTime(i);
                        break;
                    case "keywords":
                        Keywords = DB.IsNull(reader[i]) ? null : reader.GetString(i);
                        break;
                }
            }

            if (Id > 0) {
                using (var db = new DbManager(Manager.DbCon)) {
                    var sql = "SELECT * FROM `preview` WHERE file_id=@id";
                    if (db.QueryReader(sql, DB.Param("id", Id))) {
                        while (db.DataReader.NextResult()) {
                            db.DataReader.Read();
                            Previews.Add(PreviewFile.FromSql(db.DataReader));
                        }
                    }
                }
            }
        }
Beispiel #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();





            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select Competency From competency Limit 1";
            cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                cn1.Text = reader.GetString(reader.GetOrdinal("Competency"));
            }

            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select Competency FROM competency Limit 2";
            cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                cn2.Text = reader.GetString(reader.GetOrdinal("Competency"));
            }

            reader.Close();
            conn.Close();




            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select Competency From competency Limit 3";
            cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                cn3.Text = reader.GetString(reader.GetOrdinal("Competency"));
            }

            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select Competency From competency Limit 4";
            cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                cn4.Text = reader.GetString(reader.GetOrdinal("Competency"));
            }

            reader.Close();
            conn.Close();






            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select Competency From competency Limit 5";
            cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                cn5.Text = reader.GetString(reader.GetOrdinal("Competency"));
            }

            reader.Close();
            conn.Close();












            svr.Text = Session["username"].ToString();









            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select QuestionText From self_questions WHERE Competency LIKE '"+ cn1.Text +"' ";
            cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();
            maxscore1 = 0;

            while (reader.Read())
            {
                maxscore1++;
            }


            max = maxscore1*5;
            max1.Text = max.ToString();

            reader.Close();
            conn.Close();







            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select QuestionText From self_questions WHERE Competency LIKE '" + cn2.Text + "' ";
            cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();
            maxscore2 = 0;

            while (reader.Read())
            {
                maxscore2++;
            }


            max = maxscore2 * 5;
            max2.Text = max.ToString();

            reader.Close();
            conn.Close();






            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select QuestionText From self_questions WHERE Competency LIKE '" + cn3.Text + "' ";
            cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();
            maxscore3 = 0;

            while (reader.Read())
            {
                maxscore3++;
            }


            max = maxscore3 * 5;
            max3.Text = max.ToString();

            reader.Close();
            conn.Close();





            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select QuestionText From self_questions WHERE Competency LIKE '" + cn4.Text + "' ";
            cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();
            maxscore4 = 0;

            while (reader.Read())
            {
                maxscore4++;
            }


            max = maxscore4 * 5;
            max4.Text = max.ToString();

            reader.Close();
            conn.Close();





            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select QuestionText From self_questions WHERE Competency LIKE '" + cn5.Text + "' ";
            cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();
            maxscore1 = 0;

            while (reader.Read())
            {
                maxscore5++;
            }


            max = maxscore5 * 5;
            max5.Text = max.ToString();

            reader.Close();
            conn.Close();











            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "SELECT 1c FROM selfevascore WHERE StudentName LIKE 'A'";
            cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                sum1c.Text = reader.GetString(reader.GetOrdinal("1c"));
                scr1 = reader.GetDouble(reader.GetOrdinal("1c"));
            }
            if (scr1 <= 0.6 * maxscore1*5)
            {
                comm1.Text = "You need to improve on " + cn1.Text + ". Don't give up!";
            }
            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "SELECT 2c FROM selfevascore WHERE StudentName LIKE 'A'";
            cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                sum2c.Text = reader.GetString(reader.GetOrdinal("2c"));
                scr2 = reader.GetDouble(reader.GetOrdinal("2c"));
            }

            if (scr2 <= 0.6 * maxscore2 * 5)
            {
                comm2.Text = "You need to improve on " + cn2.Text + ". Try harder!";
            }

            reader.Close();
            conn.Close();


            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "SELECT 3c FROM selfevascore WHERE StudentName LIKE 'A'";
            cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                sum3c.Text = reader.GetString(reader.GetOrdinal("3c"));
                scr3 = reader.GetDouble(reader.GetOrdinal("3c"));
            }
            if (scr3 <= 0.6 * maxscore3 * 5)
            {
                comm3.Text = "You need to improve on " + cn3.Text + ".";
            }

            reader.Close();
            conn.Close();







            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "SELECT 4c FROM selfevascore WHERE StudentName LIKE 'A'";
            cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                sum4c.Text = reader.GetString(reader.GetOrdinal("4c"));
                scr4 = reader.GetDouble(reader.GetOrdinal("4c"));
            }
            if (scr4 <= 0.6 * maxscore4 * 5)
            {
                comm4.Text = "You need to improve on " + cn4.Text + ". Try harder!";
            }

            reader.Close();
            conn.Close();





            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "SELECT 5c FROM selfevascore WHERE StudentName LIKE 'A'";
            cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                sum5c.Text = reader.GetString(reader.GetOrdinal("5c"));
                scr5 = reader.GetDouble(reader.GetOrdinal("5c"));
            }
            if (scr5 <= 0.6 * maxscore5 * 5)
            {
                comm5.Text = "You need to improve on " + cn5.Text + ". Don't give up!";
            }

            reader.Close();
            conn.Close();


        }
Beispiel #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;
     }
 }
Beispiel #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();



            svr.Text = Session["username"].ToString();

            projectid = Session["project"].ToString();


            count = 0;

            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "SELECT 1c FROM webappdemo.peer_ans WHERE StudentName LIKE '" + svr.Text + "'";//!!!!!!! need login start
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                score1 += reader.GetDouble(reader.GetOrdinal("1c"));
                count++;
            }
            score1     = score1 / count;
            sum1c.Text = score1.ToString();
            count      = 0;
            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "SELECT 2c FROM webappdemo.peer_ans WHERE StudentName LIKE '" + svr.Text + "'";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                score2 += reader.GetDouble(reader.GetOrdinal("2c"));
                count++;
            }
            score2     = score2 / count;
            sum2c.Text = score2.ToString();
            count      = 0;
            reader.Close();
            conn.Close();


            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "SELECT 3c FROM webappdemo.peer_ans WHERE StudentName LIKE '" + svr.Text + "'";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                score3 += reader.GetDouble(reader.GetOrdinal("3c"));
                count++;
            }
            score3     = score3 / count;
            sum3c.Text = score3.ToString();
            count      = 0;
            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "SELECT 4c FROM webappdemo.peer_ans WHERE StudentName LIKE '" + svr.Text + "'";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                score4 += reader.GetDouble(reader.GetOrdinal("4c"));
                count++;
            }
            score4     = score4 / count;
            sum4c.Text = score4.ToString();
            count      = 0;
            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "SELECT 5c FROM webappdemo.peer_ans WHERE StudentName LIKE '" + svr.Text + "'";//!!!!!! end
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                score5 += reader.GetDouble(reader.GetOrdinal("5c"));
                count++;
            }
            score5     = score5 / count;
            sum5c.Text = score5.ToString();
            count      = 0;
            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select Competency From competency Limit 1";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                cn1.Text = reader.GetString(reader.GetOrdinal("Competency"));
            }

            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select Competency From competency Limit 2";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                cn2.Text = reader.GetString(reader.GetOrdinal("Competency"));
            }

            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select Competency From competency Limit 3";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                cn3.Text = reader.GetString(reader.GetOrdinal("Competency"));
            }

            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select Competency From competency Limit 4";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                cn4.Text = reader.GetString(reader.GetOrdinal("Competency"));
            }

            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select Competency From competency Limit 5";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                cn5.Text = reader.GetString(reader.GetOrdinal("Competency"));
            }

            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select QuestionText From peer_questions WHERE Competency LIKE '" + cn1.Text + "'AND ProjectID LIKE '" + projectid + "' ";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader    = cmd.ExecuteReader();
            maxscore1 = 0;

            while (reader.Read())
            {
                maxscore1++;
            }


            max       = maxscore1 * 5;
            max1.Text = max.ToString();

            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select QuestionText From peer_questions WHERE Competency LIKE '" + cn2.Text + "'AND ProjectID LIKE '" + projectid + "' ";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader    = cmd.ExecuteReader();
            maxscore2 = 0;

            while (reader.Read())
            {
                maxscore2++;
            }


            max       = maxscore2 * 5;
            max2.Text = max.ToString();

            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select QuestionText From peer_questions WHERE Competency LIKE '" + cn3.Text + "'AND ProjectID LIKE '" + projectid + "' ";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader    = cmd.ExecuteReader();
            maxscore3 = 0;

            while (reader.Read())
            {
                maxscore3++;
            }


            max       = maxscore3 * 5;
            max3.Text = max.ToString();

            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select QuestionText From peer_questions WHERE Competency LIKE '" + cn4.Text + "'AND ProjectID LIKE '" + projectid + "' ";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader    = cmd.ExecuteReader();
            maxscore4 = 0;

            while (reader.Read())
            {
                maxscore4++;
            }


            max       = maxscore4 * 5;
            max4.Text = max.ToString();

            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = " ";

            queryStr = "Select QuestionText From peer_questions WHERE Competency LIKE '" + cn5.Text + "'AND ProjectID LIKE '" + projectid + "' ";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader    = cmd.ExecuteReader();
            maxscore1 = 0;

            while (reader.Read())
            {
                maxscore5++;
            }


            max       = maxscore5 * 5;
            max5.Text = max.ToString();

            reader.Close();
            conn.Close();



            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = "";

            queryStr = "SELECT Comments FROM peer_ans WHERE StudentName LIKE '" + svr.Text + "' LIMIT 1";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();
            c1     = "";

            while (reader.Read())
            {
                c1 = reader.GetString(reader.GetOrdinal("Comments"));
                Session["uname11"] = c1;
            }
            reader.Close();
            conn.Close();

            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = "";

            queryStr = "SELECT Comments FROM peer_ans WHERE StudentName LIKE '" + svr.Text + "' LIMIT 2";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();
            c2     = "";

            while (reader.Read())
            {
                c2 = reader.GetString(reader.GetOrdinal("Comments"));
                Session["uname12"] = c2;
            }
            reader.Close();
            conn.Close();

            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = "";

            queryStr = "SELECT Comments FROM peer_ans WHERE StudentName LIKE '" + svr.Text + "' LIMIT 3";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();
            c3     = "";

            while (reader.Read())
            {
                c3 = reader.GetString(reader.GetOrdinal("Comments"));
                Session["uname13"] = c3;
            }
            reader.Close();
            conn.Close();

            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = "";

            queryStr = "SELECT Comments FROM peer_ans WHERE StudentName LIKE '" + svr.Text + "' LIMIT 4";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();
            c4     = "";

            while (reader.Read())
            {
                c4 = reader.GetString(reader.GetOrdinal("Comments"));
                Session["uname14"] = c4;
            }
            reader.Close();
            conn.Close();

            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
            conn.Open();
            queryStr = "";

            queryStr = "SELECT Comments FROM peer_ans WHERE StudentName LIKE '" + svr.Text + "' LIMIT 5";
            cmd      = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);

            reader = cmd.ExecuteReader();
            c5     = "";

            while (reader.Read())
            {
                c5 = reader.GetString(reader.GetOrdinal("Comments"));
                Session["uname15"] = c5;
            }
            reader.Close();
            conn.Close();



            if (c1 != null)
            {
                c1           = (String)Session["uname11"];
                c1label.Text = c1;
            }
            else
            {
                c1label.Text = "N.A.";
            }

            if (c5 != c1)
            {
                c2           = (String)Session["uname12"];
                c2label.Text = c2;
            }
            else
            {
                c2label.Text = "N.A.";
            }

            if (c3 != c2)
            {
                c3           = (String)Session["uname13"];
                c3label.Text = c3;
            }
            else
            {
                c3label.Text = "N.A.";
            }

            if (c4 != c3)
            {
                c4           = (String)Session["uname14"];
                c4label.Text = c4;
            }
            else
            {
                c4label.Text = "N.A.";
            }

            if (c5 != c4)
            {
                c5           = (String)Session["uname15"];
                c5label.Text = c5;
            }
            else
            {
                c5label.Text = "N.A.";
            }
        }
Beispiel #23
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" );
     }
 }
        private void LoadLine(MySqlDataReader rdr)
        {
            string temp = "";

            if(!rdr.IsDBNull(0)) { line_no = rdr.GetInt32(0); ORDER_ARRAY[rowCount, CONST_LINE_NO] = line_no.ToString(); }
            if (!rdr.IsDBNull(1)) { part_id = rdr.GetString(1); ORDER_ARRAY[rowCount, CONST_PARTID] = part_id; }
            if (!rdr.IsDBNull(2)) { desc = rdr.GetString(2); ORDER_ARRAY[rowCount, CONST_DESC] = desc; }
            if (!rdr.IsDBNull(3)) { ordered_qty = rdr.GetInt32(3); ORDER_ARRAY[rowCount, CONST_ORDERED] = ordered_qty.ToString(); }
            if (!rdr.IsDBNull(4)) { unit_price = rdr.GetFloat(4); ORDER_ARRAY[rowCount, CONST_PRICE] = unit_price.ToString(); }
            if (!rdr.IsDBNull(5)) { mod = rdr.GetChar(5); ORDER_ARRAY[rowCount, CONST_MOD] = mod.ToString(); }
            if (!rdr.IsDBNull(6)) { gst = Math.Round(rdr.GetDouble(6), 2); ORDER_ARRAY[rowCount, CONST_GST] = gst.ToString(); }
            if (!rdr.IsDBNull(7)) { pst = Math.Round(rdr.GetDouble(7), 2); ORDER_ARRAY[rowCount, CONST_PST] = pst.ToString(); }
            if (!rdr.IsDBNull(8)) { notes = rdr.GetString(8); ORDER_ARRAY[rowCount, CONST_NOTES] = notes; }

            bool cust = false;
            if (mod == 'C')
                cust = true;
            DataGridViewCheckBoxColumn checkColumn = new DataGridViewCheckBoxColumn();
            checkColumn.Name = "X";
            checkColumn.HeaderText = "X";
            checkColumn.Width = 50;
            checkColumn.ReadOnly = false;
            checkColumn.FillWeight = 10; //if the datagridview is resized (on form resize) the checkbox won't take up too much; value is relative to the other columns' fill values

            dgOrderForm.Rows.Add(line_no.ToString(), cust, part_id, "", desc, ordered_qty.ToString(), unit_price.ToString(), gst.ToString(), pst.ToString(), notes);

            MAX_LINE = Convert.ToInt32(line_no);
        }
Beispiel #25
0
        public void Tube_Control(TreeViewItem item)
        {
            try
            {
                if (item.Tag.ToString() == "tube0" || item.Tag.ToString() == "tube1")
                {
                    Mouse.OverrideCursor = Cursors.Wait;
                    _mySqlCommand.CommandText = @"
                        SELECT
                        defectsdata.IndexData,
                        defectsdata.NumberPart,
                        defectsdata.NumberTube,
                        defectsdata.NumberSegments,
                        defectsdata.DataSensors,
                        DATE_FORMAT(defectsdata.DatePr, '%Y-%m-%d'),
                        defectsdata.TimePr,
                        worksmens.NameSmen,
                        o1.Surname,
                        o2.Surname
                        FROM
                        defectsdata
                        INNER JOIN indexes ON indexes.IndexData = defectsdata.IndexData
                        INNER JOIN worksmens ON worksmens.Id_WorkSmen = indexes.Id_WorkSmen
                        INNER JOIN operators o1 ON o1.Id_Operator = indexes.Id_Operator1
                        INNER JOIN operators o2 ON o2.Id_Operator = indexes.Id_Operator2
                        WHERE
                        defectsdata.IndexData = @A
                        LIMIT 1
                    ";
                    _mySqlCommand.Parameters.Clear();
                    _mySqlCommand.Parameters.AddWithValue("A", item.Uid);

                    _mySqlCommand.Connection = _connection.MySqlConnection;
                    _mySqlDataReader = _mySqlCommand.ExecuteReader();

                    while (_mySqlDataReader.Read())
                    {
                        ArchiveWindow.label1.Content = "Номер плавки\t" + _mySqlDataReader.GetString(1);
                        ArchiveWindow.label2.Content = "Номер трубы\t" + _mySqlDataReader.GetString(2);
                        ArchiveWindow.label3.Content = "Дата проведения Н.К.\t" + _mySqlDataReader.GetString(5);
                        ArchiveWindow.label4.Content = "Время проведения Н.К.\t" + _mySqlDataReader.GetString(6);
                        ArchiveWindow.label5.Content = "Длина трубы (метры)\t\t " +
                                                       Math.Round((_mySqlDataReader.GetDouble(3)/6), 2);
                        ArchiveWindow.label7.Content = "Рабочая смена\t" + _mySqlDataReader.GetString(7);
                        ArchiveWindow.label8.Content = "Специалист ОКПП\t" + _mySqlDataReader.GetString(9);
                        ArchiveWindow.label9.Content = "Специалист АСК ТЭСЦ-2\t" + _mySqlDataReader.GetString(8);

                        for (var i = 0; i < _countDeffectsLine; i++)
                        {
                            var line = (Line) ArchiveWindow.canvas1.FindName("errorLine" + i);
                            ArchiveWindow.canvas1.Children.Remove(line);
                            try
                            {
                                ArchiveWindow.canvas1.UnregisterName("errorLine" + i);
                            }
                                // ReSharper disable EmptyGeneralCatchClause
                            catch
                                // ReSharper restore EmptyGeneralCatchClause
                            {
                            }
                        }
                        _countDeffectsLine = 0;

                        /*_mySqlDataReaderValue4 = _mySqlDataReader.GetValue(4);
                        _da.Completed += _da_Completed;
                        _da.From = ArchiveWindow.rectangle1.Width;
                        _da.To = _mySqlDataReader.GetDouble(3)*4;
                        _da.Duration = TimeSpan.FromMilliseconds(500);
                        ArchiveWindow.rectangle1.BeginAnimation(FrameworkElement.WidthProperty, _da);*/
                        ArchiveWindow.rectangle1.Width = _mySqlDataReader.GetDouble(3)*4;

                        var j = 0;

                        foreach (var deffect in (byte[]) _mySqlDataReader.GetValue(4))
                        {
                            if (deffect != 0)
                            {
                                var redBrush = new SolidColorBrush
                                {
                                    Color = Colors.Red
                                };

                                var errorLine = new Line();

                                Canvas.SetLeft(errorLine, 40 + (j*4));
                                errorLine.Opacity = 1;
                                errorLine.X1 = 0;
                                errorLine.X2 = 0;
                                errorLine.Y1 = 151;
                                errorLine.Y2 = 151 + 70;
                                errorLine.StrokeThickness = 4;
                                errorLine.Stroke = redBrush;
                                errorLine.Fill = redBrush;
                                ArchiveWindow.canvas1.RegisterName("errorLine" + _countDeffectsLine, errorLine);
                                ArchiveWindow.canvas1.Children.Add(errorLine);
                                /*_da1.From = 0;
                                _da1.To = 1;
                                _da1.Duration = TimeSpan.FromMilliseconds(2000);
                                errorLine.BeginAnimation(UIElement.OpacityProperty, _da1);*/
                                _countDeffectsLine++;
                            }
                            j++;
                        }

                        ArchiveWindow.label6.Content = "Кол-во дефектных сегментов\t " + _countDeffectsLine;
                    }

                    _mySqlDataReader.Close();
                    Mouse.OverrideCursor = Cursors.Arrow;
                }
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch
            // ReSharper restore EmptyGeneralCatchClause
            {
            }
        }
 private StavkaKalkulacijeDTO readerToStavkaKalkulacijeDTO(MySqlDataReader reader)
 {
     StavkaKalkulacijeDTO stavka = new StavkaKalkulacijeDTO();
     stavka.Kolicina = reader.GetDouble("Kolicina");
     stavka.NabavnaCijena = reader.GetDouble("NabavnaCijena");
     stavka.Rabat = reader.GetDouble("Rabat");
     stavka.NetoNabavnaCijena = reader.GetDouble("NetoNabavnaCijena");
     stavka.VeleprodajnaCijena = reader.GetDouble("VeleprodajnaCijena");
     stavka.RazlikaUCijeni = reader.GetDouble("RazlikaUCijeni");
     stavka.NabavnaVrijednost = reader.GetDouble("NabavnaVrijednost");
     stavka.VeleprodajnaVrijednost = reader.GetDouble("VeleprodajnaVrijednost");
     return stavka;
 }