private void InsertArticle_Load(object sender, EventArgs e)
        {
            List <TypeArticle> types = new TypeArticle().getAll();

            foreach (TypeArticle type in types)
            {
                this.cbxTypeArticle.Items.Add(type.typeArticle);
            }
        }
Exemple #2
0
        public InsertArticleType(string _id)
        {
            InitializeComponent();
            this.mainID = _id;
            TypeArticle type = new TypeArticle();

            type.get(_id);
            tbxArticleType.Text = type.typeArticle;
        }
        public InsertArticle(string _id)
        {
            InitializeComponent();
            this.mainID = _id;
            Article art = new Article();

            art.get(_id);
            tbxArticle.Text = art.article;
            TypeArticle type = new TypeArticle();

            type.get(art.typeArticle);
            cbxTypeArticle.SelectedItem = type.typeArticle;
        }
Exemple #4
0
        public List <TypeArticle> getAll()
        {
            List <TypeArticle> data = new List <TypeArticle>();

            con.Open();
            SqlCommand    Command = new SqlCommand("SELECT * FROM dbo.tblTypeArticle;", con);
            SqlDataReader Reader  = Command.ExecuteReader();

            if (Reader.HasRows)
            {
                while (Reader.Read())
                {
                    TypeArticle ta = new TypeArticle();
                    ta.id          = Reader.GetValue(0).ToString();
                    ta.typeArticle = Reader.GetValue(1).ToString();
                    data.Add(ta);
                }
                con.Close();
            }
            return(data);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (tbxArticle.Text == "")
            {
                MessageBox.Show("The Article is required!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!this.validateAlpha(tbxArticle.Text))
            {
                MessageBox.Show("The Article field is invalid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (cbxTypeArticle.SelectedItem == null)
            {
                MessageBox.Show("The Article type is required!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            TypeArticle t = new TypeArticle();

            t.loadByUnique(cbxTypeArticle.SelectedItem.ToString());

            Article type = new Article();

            type.id          = this.mainID;
            type.typeArticle = t.id;
            type.article     = tbxArticle.Text.Trim();
            type.save();
            if (this.mainID == null)
            {
                MessageBox.Show("Type Article successfully inserted!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Type Article successfully updated!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            this.Close();
        }
Exemple #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (tbxArticleType.Text == "")
            {
                MessageBox.Show("The Type Article is required!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            TypeArticle type = new TypeArticle();

            type.id          = this.mainID;
            type.typeArticle = tbxArticleType.Text.Trim();
            type.save();
            if (this.mainID == null)
            {
                MessageBox.Show("Type Article successfully inserted!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Type Article successfully updated!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            this.Close();
        }
Exemple #7
0
        private void datagridviews_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dgv = (DataGridView)sender;
            string       id  = dgv.SelectedRows[0].Cells[0].Value.ToString();

            if (dgv.Name == "dgvArticleType")
            {
                if (e.ColumnIndex == 2)
                {
                    InsertArticleType form = new InsertArticleType(id);
                    form.ShowDialog();
                    form.BringToFront();
                    this.refreshDGV("type_article");
                }
                else if (e.ColumnIndex == 3)
                {
                    TypeArticle type = new TypeArticle();
                    type.get(id);
                    type.delete();
                    this.refreshDGV("type_article");
                }
            }
            else if (dgv.Name == "dgvArticle")
            {
                if (e.ColumnIndex == 3)
                {
                    InsertArticle form = new InsertArticle(id);
                    form.ShowDialog();
                    form.BringToFront();
                    this.refreshDGV("article");
                }
                else if (e.ColumnIndex == 4)
                {
                    Article article = new Article();
                    article.get(id);
                    article.delete();
                    this.refreshDGV("article");
                }
            }
            else if (dgv.Name == "dgvLoans")
            {
                if (e.ColumnIndex == 7)
                {
                    InsertLoan form = new InsertLoan(id);
                    form.ShowDialog();
                    form.BringToFront();
                    this.refreshDGV("loans");
                }
                else if (e.ColumnIndex == 8)
                {
                    Loan loan = new Loan();
                    loan.get(id);
                    loan.delete();
                    this.refreshDGV("loans");
                }
            }
            else if (dgv.Name == "dgvClients")
            {
                if (e.ColumnIndex == 6)
                {
                    InsertClient form = new InsertClient(id);
                    form.ShowDialog();
                    form.BringToFront();
                    this.refreshDGV("client");
                }
                else if (e.ColumnIndex == 7)
                {
                    Client client = new Client();
                    client.get(id);
                    client.delete();
                    this.refreshDGV("client");
                }
            }
        }