private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                using (EntrepotBDDataContext bd = new EntrepotBDDataContext())
                {
                    Production_Daily pDaily = new Production_Daily();
                    pDaily.product  = (int)comboProduct.SelectedValue;
                    pDaily.personal = (int)comboPersonal.SelectedValue;

                    if (radioBonchero.Checked)
                    {
                        decimal cost = 0;
                        if (decimal.TryParse(txtCosto.Text, out cost))
                        {
                            pDaily.cost_Bonchero = cost;
                        }
                    }

                    if (radioRolero.Checked)
                    {
                        decimal cost = 0;
                        if (decimal.TryParse(txtCosto.Text, out cost))
                        {
                            pDaily.cost_Rolero = cost;
                        }
                    }

                    pDaily.Date = dateTimePicker1.Value;
                    int quantity;

                    if (int.TryParse(txtQuantity.Text, out quantity))
                    {
                        pDaily.quantity = quantity;
                    }

                    bd.Production_Dailies.InsertOnSubmit(pDaily);
                    bd.SubmitChanges();

                    Stock stockObj = new Stock();
                    stockObj.product    = pDaily.product;
                    stockObj.stock1     = pDaily.quantity;
                    stockObj.dateE      = pDaily.Date;
                    stockObj.referDaily = pDaily.id_Prod_Daily;

                    bd.Stocks.InsertOnSubmit(stockObj);
                    bd.SubmitChanges();

                    txtCosto.Clear();
                    txtQuantity.Clear();
                    ChargeDataGridview();
                    MessageBox.Show("success", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                //
                DataGridViewSelectedRowCollection rows = gridView_ListTabaco.SelectedRows;

                foreach (DataGridViewRow row in rows)
                {
                    string nameTobacco = row.Cells["name"].Value.ToString();

                    using (EntrepotBDDataContext db = new EntrepotBDDataContext())
                    {
                        Tobacco tobacco = (from t in db.Tobaccos
                                           where String.Equals(t.name, nameTobacco)
                                           select t).FirstOrDefault();

                        db.Tobaccos.DeleteOnSubmit(tobacco);
                        db.SubmitChanges();
                    }
                }

                ChargeDataGridview();
                MessageBox.Show("success", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (EntrepotBDDataContext bd = new EntrepotBDDataContext())
            {
                try
                {
                    Tobacco tobaco  = new Tobacco();
                    string  name    = txtNameTobacco.Text;
                    int     size    = int.Parse(comboSize.SelectedValue.ToString());
                    int     blend   = int.Parse(comboBlend.SelectedValue.ToString());
                    int     wrapper = int.Parse(comboWrapper.SelectedValue.ToString());

                    tobaco.size    = size;
                    tobaco.blend   = blend;
                    tobaco.wrapper = wrapper;
                    tobaco.name    = txtNameTobacco.Text;

                    bd.Tobaccos.InsertOnSubmit(tobaco);
                    bd.SubmitChanges();
                    MessageBox.Show("success", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtNameTobacco.Clear();
                    txtNameTobacco.Focus();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Esempio n. 4
0
        private void deleteWrapper(DataGridViewSelectedRowCollection listSelectWrapper)
        {
            try
            {
                foreach (DataGridViewRow k in listSelectWrapper)
                {
                    using (EntrepotBDDataContext db = new EntrepotBDDataContext())
                    {
                        string  name    = k.Cells["name"].Value.ToString();
                        tb_capa wrapper = (from b in db.tb_capas
                                           where b.capa == name
                                           select b).FirstOrDefault();

                        db.tb_capas.DeleteOnSubmit(wrapper);
                        db.SubmitChanges();
                    }
                }

                MessageBox.Show("success", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                chargeGridView();
                chargeCombo();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                DataGridViewSelectedRowCollection rows = gridView_ListPersonal.SelectedRows;

                foreach (DataGridViewRow row in rows)
                {
                    string name = row.Cells["name"].Value.ToString();

                    using (EntrepotBDDataContext db = new EntrepotBDDataContext())
                    {
                        Personal personal = (from p in db.Personals
                                             where p.name == name
                                             select p).FirstOrDefault();

                        db.Personals.DeleteOnSubmit(personal);
                        db.SubmitChanges();
                    }
                }
                ChargeDataGridview();
                MessageBox.Show("success", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection rows = dataGridProduct.SelectedRows;

            foreach (DataGridViewRow row in rows)
            {
                try
                {
                    string   productS  = row.Cells["Product"].Value.ToString();
                    string   personalS = row.Cells["Personal"].Value.ToString();
                    DateTime dateS     = (DateTime)row.Cells["Date"].Value;

                    using (EntrepotBDDataContext bd = new EntrepotBDDataContext())
                    {
                        int product = (from p in bd.Tobaccos
                                       where p.name == productS
                                       select p.id_Tobacco).FirstOrDefault();
                        int personal = (from p in bd.Personals
                                        where p.name == personalS
                                        select p.id_Personal).FirstOrDefault();

                        Production_Daily pDaily = (from p in bd.Production_Dailies
                                                   where p.product == product &&
                                                   p.personal == personal &&
                                                   p.Date == dateS
                                                   select p).FirstOrDefault();

                        Stock objStock = (from s in bd.Stocks
                                          where s.referDaily == pDaily.id_Prod_Daily
                                          select s).FirstOrDefault();


                        bd.Production_Dailies.DeleteOnSubmit(pDaily);
                        bd.Stocks.DeleteOnSubmit(objStock);
                        bd.SubmitChanges();
                        //   MessageBox.Show(" delete success", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                finally
                {
                }
            }
            ChargeDataGridview();
        }
Esempio n. 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                using (EntrepotBDDataContext db = new EntrepotBDDataContext())
                {
                    Personal personal = new Personal();
                    personal.name     = textBox2.Text;
                    personal.position = comboBox1.SelectedItem.ToString();

                    db.Personals.InsertOnSubmit(personal);
                    db.SubmitChanges();
                    MessageBox.Show("success", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    button2.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 8
0
        private void button14_Click(object sender, EventArgs e)
        {
            try
            {
                using (EntrepotBDDataContext db = new EntrepotBDDataContext())
                {
                    tb_capa wrapper = new tb_capa();

                    wrapper.capa = textBox3.Text;
                    db.tb_capas.InsertOnSubmit(wrapper);
                    db.SubmitChanges();
                    chargeCombo();
                    MessageBox.Show("success", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox3.Clear();
                    chargeGridView();
                    textBox3.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 9
0
        private void button3_Click_1(object sender, EventArgs e)
        {
            try
            {
                using (EntrepotBDDataContext db = new EntrepotBDDataContext())
                {
                    tb_liga blend = new tb_liga();

                    blend.liga = textBox1.Text;
                    db.tb_ligas.InsertOnSubmit(blend);
                    db.SubmitChanges();
                    chargeCombo();
                    MessageBox.Show("success", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox1.Clear();
                    chargeGridView();
                    textBox1.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }