Exemple #1
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 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);
            }
        }
        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);
                }
            }
        }
        private void chargeGridView()
        {
            using (bd = new EntrepotBDDataContext())
            {
                //////Size


                var listSize = from s in bd.tb_vitolas
                               orderby s.vitola ascending
                               select new { name = s.vitola };
                dataGridView2.DataSource = listSize.ToList();
                ///
                //////Wrapper

                var listWrapper = from w in bd.tb_capas
                                  orderby w.capa ascending
                                  select new { name = w.capa };
                dataGridView3.DataSource = listWrapper.ToList();


                //////Blend

                var listBlend = from b in bd.tb_ligas
                                select new { name = b.liga }
                into bX
                orderby bX.name
                select bX;

                dataGridView1.DataSource = listBlend.ToList();
            }
        }
Exemple #5
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);
            }
        }
        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);
            }
        }
        private void chargeCombo()
        {
            using (bd = new EntrepotBDDataContext())
            {
                //////Size

                var listSize = from s in bd.tb_vitolas
                               orderby s.vitola
                               select s;

                Dictionary <int, string> sourceSize = new Dictionary <int, string>();

                foreach (tb_vitola s in listSize)
                {
                    sourceSize.Add(s.id_vitola, s.vitola);
                }

                comboSize.DataSource    = new BindingSource(sourceSize, null);
                comboSize.DisplayMember = "Value";
                comboSize.ValueMember   = "Key";

                ///
                //////Wrapper

                var listWrapper = from w in bd.tb_capas
                                  orderby w.capa
                                  select w;

                Dictionary <int, string> sourceWrapper = new Dictionary <int, string>();

                foreach (tb_capa w in listWrapper)
                {
                    sourceWrapper.Add(w.id_capa, w.capa);
                }

                comboWrapper.DataSource    = new BindingSource(sourceWrapper, null);
                comboWrapper.DisplayMember = "Value";
                comboWrapper.ValueMember   = "Key";


                //////Blend

                var listBlend = from b in bd.tb_ligas
                                orderby b.liga
                                select b;

                Dictionary <int, string> sourceBlend = new Dictionary <int, string>();

                foreach (tb_liga b in listBlend)
                {
                    sourceBlend.Add(b.id_liga, b.liga);
                }

                comboBlend.DataSource    = new BindingSource(sourceBlend, null);
                comboBlend.DisplayMember = "Value";
                comboBlend.ValueMember   = "Key";
            }
        }
        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();
        }
 private void updateWrapper()
 {
     try
     {
         using (EntrepotBDDataContext db = new EntrepotBDDataContext())
         {
             db.ExecuteCommand("update tb_capa set capa={0} where capa={1}", textBox1.Text, this.name);
             MessageBox.Show("success", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.Source);
     }
 }
        private void chargeCombo()
        {
            try
            {
                using (EntrepotBDDataContext bd = new EntrepotBDDataContext())
                {
                    //////Product

                    var listTobacco = from t in bd.Tobaccos
                                      select t;

                    Dictionary <int, string> sourceTobaco = new Dictionary <int, string>();

                    foreach (Tobacco t in listTobacco)
                    {
                        sourceTobaco.Add(t.id_Tobacco, t.name);
                    }

                    comboProduct.DataSource    = new BindingSource(sourceTobaco, null);
                    comboProduct.DisplayMember = "Value";
                    comboProduct.ValueMember   = "Key";


                    /////Personal



                    var listPersonal = from p in bd.Personals
                                       select p;

                    Dictionary <int, string> sourcePersonal = new Dictionary <int, string>();

                    foreach (Personal p in listPersonal)
                    {
                        sourcePersonal.Add(p.id_Personal, p.name);
                    }

                    comboPersonal.DataSource    = new BindingSource(sourcePersonal, null);
                    comboPersonal.DisplayMember = "Value";
                    comboPersonal.ValueMember   = "Key";
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #11
0
 public void ChargeDataGridview()
 {
     try
     {
         using (EntrepotBDDataContext bd = new EntrepotBDDataContext())
         {
             var listPersonal = from p in bd.View_Personals
                                select p;
             gridView_ListPersonal.DataSource = listPersonal.ToList();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + " " + ex.StackTrace);
     }
 }
Exemple #12
0
        private void ChargeGridView()
        {
            try {
                using (EntrepotBDDataContext bd = new EntrepotBDDataContext())
                {
                    var list = from prod in bd.View_Stocks
                               select prod;

                    GridViewStock.DataSource = list;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #13
0
        public void ChargeDataGridview()
        {
            try
            {
                using (EntrepotBDDataContext bd = new EntrepotBDDataContext())
                {
                    var listTobaco = from t in bd.View_TobaccoCatalogs
                                     select t;

                    gridView_ListTabaco.DataSource = listTobaco.ToList();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " " + ex.StackTrace);
            }
        }
Exemple #14
0
        private void updateBlend()
        {
            try
            {
                using (EntrepotBDDataContext db = new EntrepotBDDataContext())
                {
                    db.ExecuteCommand("update tb_liga set liga={0} where liga={1}", textBox1.Text, this.name);
                }

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

            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public void ChargeDataGridview()
 {
     try
     {
         using (EntrepotBDDataContext bd = new EntrepotBDDataContext())
         {
             var listProduct = from p in bd.View_Production_Dailies
                               orderby p.Date descending
                               select p;
             dataGridProduct.DataSource = listProduct.ToList();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + " " + ex.StackTrace);
     }
 }
        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);
            }
        }
Exemple #17
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                using (EntrepotBDDataContext bd = new EntrepotBDDataContext())
                {
                    DataGridViewRow row         = GridViewStock.SelectedRows[0];
                    string          productName = row.Cells["Product"].Value.ToString();



                    var list = from stock in bd.View_Stock_Details
                               where stock.Product.Equals(productName)
                               select stock;

                    GridView_Details.DataSource = list;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        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);
            }
        }
        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);
            }
        }