コード例 #1
0
ファイル: op_proveedores.cs プロジェクト: hmoscote/smacop2
        private static cant_material Loadmaterialescantera(IDataReader reader)
        {
            cant_material item = new cant_material();

            item.cnt   = Convert.ToString(reader["cantera"]);
            item.mat   = Convert.ToString(reader["nom"]);
            item.costo = Convert.ToDecimal(reader["costo"]);
            item.cod   = Convert.ToString(reader["material"]);
            return(item);
        }
コード例 #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex >= 0)
                {
                    DataGridViewRow row = dataGridView1.CurrentRow as DataGridViewRow;
                    if (this.dataGridView1.Columns[e.ColumnIndex].Name == "eli")
                    {
                        int a = Convert.ToInt32(MessageBox.Show("Está seguro que desea eliminar el registro", Application.ProductName.ToString(), MessageBoxButtons.YesNo, MessageBoxIcon.Information));
                        if (a == 6)
                        {
                            cant_material c = new cant_material();
                            c.cnt = row.Cells[0].Value.ToString();
                            c.mat = row.Cells[2].Value.ToString();

                            using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["default"].ToString()))
                            {
                                con.Open();
                                MySqlCommand cmd = new MySqlCommand("delete from materiales_canteras where cantera=@cant and material =@mat", con);
                                cmd.Parameters.AddWithValue("@cant", c.cnt);
                                cmd.Parameters.AddWithValue("@mat", c.mat);
                                int i = cmd.ExecuteNonQuery();
                                if (i > 0)
                                {
                                    MessageBox.Show("Registro Elimanado", "SMACOP", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                                else
                                {
                                    MessageBox.Show("No se puedo Eliminar", "SMACOP", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                }
                            }

                            dataGridView1.AutoGenerateColumns = false;
                            dataGridView1.DataSource          = op_proveedores.GellIdcanteraxproducto(this.textBox1.Text);
                        }
                    }
                }
            }
            catch (MySqlException ex)
            {
                if (ex.Number == 1451)
                {
                    MessageBox.Show("El dato está siendo utilizado, por lo tanto es imposible de eliminar", Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    MessageBox.Show(ex.Message, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #3
0
ファイル: op_proveedores.cs プロジェクト: hmoscote/smacop2
        public static cant_material GellIdcanteraxproducto1(string c, string m)
        {
            cant_material list = null;

            using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["default"].ToString()))
            {
                conn.Open();
                MySqlCommand cmd;

                cmd = new MySqlCommand("SELECT cantera, nom, material, costo FROM materiales_canteras mc join materiales m on m.cod=mc.material  WHERE cantera = @cod and material=@mat", conn);
                cmd.Parameters.AddWithValue("@cod", c);
                cmd.Parameters.AddWithValue("@mat", m);
                MySqlDataReader reader = cmd.ExecuteReader();
                if (reader.HasRows == true)
                {
                    while (reader.Read())
                    {
                        list = Loadmaterialescantera(reader);
                    }
                }
            }

            return(list);
        }
コード例 #4
0
        private void frmcostomaterial_Load(object sender, EventArgs e)
        {
            IntPtr hmenu = GetSystemMenu(this.Handle, 0);
            int    cnt   = GetMenuItemCount(hmenu);

            // remove 'close' action
            RemoveMenu(hmenu, cnt - 1, MF_DISABLED | MF_BYPOSITION);
            // remove extra menu line
            RemoveMenu(hmenu, cnt - 2, MF_DISABLED | MF_BYPOSITION);
            DrawMenuBar(this.Handle);

            comboBox2.DataSource    = op_combos.FillCombo("select cod, nom from materiales where tip='EXT'");
            comboBox2.DisplayMember = "nom";
            comboBox2.ValueMember   = "cod";
            comboBox2.Text          = null;

            if (!(string.IsNullOrEmpty(a) && string.IsNullOrEmpty(b)))
            {
                cant_material c = op_proveedores.GellIdcanteraxproducto1(a, b);

                if (c != null)
                {
                    this.comboBox2.SelectedValue = c.cod;
                    this.textBox1.Text           = c.costo.ToString();
                    //operacion();
                    comboBox2.Enabled = false;
                    //button1.Enabled = true;
                    //button2.Enabled = true;
                }
                u = 2;
            }
            else
            {
                u = 1;
            }
        }