Ejemplo n.º 1
0
        /// <summary>
        /// Opens articles (roba) selection menu
        /// </summary>
        private void SelectRoba()
        {
            frmRobaTrazi roba_trazi = new frmRobaTrazi();

            if (Convert.ToInt32(cbSkladiste.SelectedValue) != 0)
            {
                roba_trazi.idSkladiste = Convert.ToInt32(cbSkladiste.SelectedValue);
            }
            roba_trazi.ShowDialog();
            string roba_sifra = Properties.Settings.Default.id_roba.Trim();

            if (roba_sifra != "")
            {
                for (int y = 0; y < dgw.Rows.Count; y++)
                {
                    if (roba_sifra == dgw.Rows[y].Cells["sifra"].FormattedValue.ToString())
                    {
                        MessageBox.Show("Artikl ili usluga već postoje!", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                string sql = "SELECT * FROM roba WHERE sifra='" + roba_sifra + "'";

                DataTable DTRoba = classSQL.select(sql, "roba").Tables[0];
                if (DTRoba.Rows.Count > 0)
                {
                    SetRoba(DTRoba);
                }
                else
                {
                    MessageBox.Show("Za ovu šifru ne postoji artikl ili usluga.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 2
0
        private void btnOpenRoba_Click(object sender, EventArgs e)
        {
            frmRobaTrazi roba_trazi = new frmRobaTrazi();

            roba_trazi.ShowDialog();
            string propertis_sifra = Properties.Settings.Default.id_roba.Trim();

            if (propertis_sifra != "")
            {
                for (int y = 0; y < dgw.Rows.Count; y++)
                {
                    if (propertis_sifra == dgw.Rows[y].Cells["sifra"].FormattedValue.ToString())
                    {
                        MessageBox.Show("Artikl ili usluga već postoje!", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                string sql = "SELECT * FROM roba WHERE sifra='" + propertis_sifra + "'  AND oduzmi='DA'";

                DTRoba = classSQL.select(sql, "roba").Tables[0];
                if (DTRoba.Rows.Count > 0)
                {
                    txtSifra_robe.BackColor = Color.White;
                    SetRoba();
                }
                else
                {
                    MessageBox.Show("Za ovu šifru ne postoji artikl ili usluga.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void btnOpenRoba_Click_1(object sender, EventArgs e)
        {
            frmRobaTrazi roba_trazi = new frmRobaTrazi();

            roba_trazi.ShowDialog();
            string propertis_sifra = Properties.Settings.Default.id_roba.Replace(" ", "");

            if (propertis_sifra != "")
            {
                for (int y = 0; y < dgw.Rows.Count; y++)
                {
                    if (propertis_sifra == dgw.Rows[y].Cells["sifra"].FormattedValue.ToString())
                    {
                        MessageBox.Show("Artikl ili usluga već postoje u ovoj kalkulaciji.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                string sql = "SELECT roba.*, roba_prodaja.kolicina FROM roba " +
                             "LEFT JOIN roba_prodaja on roba_prodaja.sifra = roba.sifra and roba_prodaja.id_skladiste = '" + cbSkladiste.SelectedValue + "'" +
                             " WHERE roba.sifra='" + propertis_sifra + "'";

                DTRoba = classSQL.select(sql, "roba").Tables[0];
                if (DTRoba.Rows.Count > 0)
                {
                    txtSifra_robe.BackColor = Color.White;
                    SetRoba();
                }
                else
                {
                    MessageBox.Show("Za ovu šifru ne postoj artikl ili usluga.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 4
0
        private void btnOpenRoba_Click(object sender, EventArgs e)
        {
            frmRobaTrazi roba_trazi = new frmRobaTrazi();

            roba_trazi.ShowDialog();
            string propertis_sifra = Properties.Settings.Default.id_roba.Trim();

            for (int y = 0; y < dgw.Rows.Count; y++)
            {
                if (propertis_sifra == dgw.Rows[y].Cells["sifra"].FormattedValue.ToString().Trim())
                {
                    MessageBox.Show("Artikl ili usluga već postoje!", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            string sql = string.Format(@"SELECT roba.jm, roba.naziv, roba.oduzmi, roba_prodaja.id_skladiste, roba_prodaja.kolicina, roba_prodaja.vpc, roba_prodaja.porez, roba_prodaja.sifra
FROM roba_prodaja
INNER JOIN roba ON roba_prodaja.sifra = roba.sifra
WHERE roba_prodaja.sifra = '{0}' AND roba_prodaja.id_skladiste = '{1}';", propertis_sifra, cbSkladiste.SelectedValue);

            DTRoba = classSQL.select(sql, "roba_prodaja").Tables[0];
            if (DTRoba.Rows.Count > 0)
            {
                txtSifra_robe.BackColor = Color.White;
                SetRoba();
                dgw.Select();
                dgw.CurrentCell = dgw.Rows[dgw.Rows.Count - 1].Cells[4];
                dgw.BeginEdit(true);
                txtBrojInventure.ReadOnly  = true;
                nmGodinaInventure.ReadOnly = true;
            }
            else
            {
                sql = string.Format(@"SELECT jm, naziv, oduzmi, '0' as kolicina, vpc, porez, sifra
FROM roba
WHERE sifra = '{0}';",
                                    propertis_sifra);

                DTRoba = classSQL.select(sql, "roba").Tables[0];
                if (DTRoba.Rows.Count > 0)
                {
                    txtSifra_robe.BackColor = Color.White;
                    SetRoba();
                    dgw.Select();
                    dgw.CurrentCell = dgw.Rows[dgw.Rows.Count - 1].Cells[4];
                    dgw.BeginEdit(true);
                    txtBrojInventure.ReadOnly  = true;
                    nmGodinaInventure.ReadOnly = true;
                }
                else
                {
                    MessageBox.Show("Za ovu šifru ne postoji artikl ili usluga u odabranom skladištu.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 5
0
        private void EnterDGW(DataGridView d)
        {
            if (d.CurrentCell.ColumnIndex == 0)
            {
                if (d.CurrentCell.FormattedValue.ToString() == "")
                {
                    frmRobaTrazi roba = new frmRobaTrazi();
                    roba.ShowDialog();

                    if (Properties.Settings.Default.id_roba != "")
                    {
                        d.CurrentCell.Value = Properties.Settings.Default.id_roba;
                    }
                    else
                    {
                        return;
                    }
                }

                d.EndEdit();
                DataTable DTart = classSQL.select("SELECT * FROM roba WHERE sifra='" + dgw.Rows[dgw.CurrentRow.Index].Cells[0].FormattedValue.ToString() + "'", "roba").Tables[0];

                if (DTart.Rows.Count > 0)
                {
                    dgw.Rows[dgw.CurrentRow.Index].Cells["naziv"].Value    = DTart.Rows[0]["naziv"].ToString();
                    dgw.Rows[dgw.CurrentRow.Index].Cells["kolicina"].Value = "1";
                    dgw.Rows[dgw.CurrentRow.Index].Cells["mpc"].Value      = DTart.Rows[0]["mpc"].ToString();

                    dgw.CurrentCell = dgw.Rows[dgw.CurrentRow.Index].Cells[2];
                    dgw.BeginEdit(true);
                }
            }
            else if (d.CurrentCell.ColumnIndex == 2)
            {
                int curent = d.CurrentRow.Index;
                if (curent == d.RowCount - 1 && d.Rows[curent].Cells["naziv"].FormattedValue.ToString() != "")
                {
                    d.Rows.Add();
                    d.CurrentCell = dgw.Rows[d.RowCount - 1].Cells[0];
                    d.BeginEdit(true);
                }
                else if (curent == d.RowCount - 1)
                {
                    d.CurrentCell = dgw.Rows[d.RowCount - 1].Cells[0];
                    d.BeginEdit(true);
                }
                else
                {
                    d.CurrentCell = dgw.Rows[curent + 1].Cells[0];
                    d.BeginEdit(true);
                }
            }
        }
Ejemplo n.º 6
0
        private void txtSifra_robe_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                e.SuppressKeyPress = true;

                if (txtSifra_robe.Text == "")
                {
                    frmRobaTrazi roba = new frmRobaTrazi();
                    roba.ShowDialog();

                    if (Properties.Settings.Default.id_roba != "")
                    {
                        txtSifra_robe.Text = Properties.Settings.Default.id_roba;
                    }
                    else
                    {
                        return;
                    }
                }

                string sql = "SELECT * FROM roba WHERE sifra='" + txtSifra_robe.Text + "'";
                DTRoba = classSQL.select(sql, "roba").Tables[0];
                if (DTRoba.Rows.Count > 0)
                {
                    sifra_dobivena   = DTRoba.Rows[0]["sifra"].ToString();
                    lblOartiklu.Text = DTRoba.Rows[0]["naziv"].ToString() + "\r\nCijena:" + Convert.ToDouble(DTRoba.Rows[0]["mpc"].ToString()).ToString("#0.00") + " kn";

                    string sql_normativ = "SELECT " +
                                          " caffe_normativ.sifra_normativ," +
                                          " roba.naziv," +
                                          " roba.mpc," +
                                          " caffe_normativ.kolicina," +
                                          " caffe_normativ.id_stavka" +
                                          " FROM caffe_normativ" +
                                          " LEFT JOIN roba ON roba.sifra=caffe_normativ.sifra_normativ WHERE caffe_normativ.sifra='" + sifra_dobivena + "'";
                    DTRobaNormativi = classSQL.select(sql_normativ, "caffe_normativ").Tables[0];
                    dgw.Rows.Clear();

                    for (int i = 0; i < DTRobaNormativi.Rows.Count; i++)
                    {
                        dgw.Rows.Add(DTRobaNormativi.Rows[i]["sifra_normativ"].ToString(), DTRobaNormativi.Rows[i]["naziv"].ToString(), DTRobaNormativi.Rows[i]["kolicina"].ToString(), DTRobaNormativi.Rows[i]["mpc"].ToString(), DTRobaNormativi.Rows[i]["id_stavka"].ToString());
                    }
                    dgw.Rows.Add();
                }
                else
                {
                    MessageBox.Show("Za ovu šifru ne postoj artikl ili usluga.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 7
0
        private bool SetNormativ(DataGridViewCellEventArgs e)
        {
            if (dgw.Rows[e.RowIndex].Cells[0].FormattedValue.ToString() == "")
            {
                frmRobaTrazi roba = new frmRobaTrazi();
                roba.ShowDialog();

                if (Properties.Settings.Default.id_roba != "")
                {
                    dgw.Rows[e.RowIndex].Cells[0].Value = Properties.Settings.Default.id_roba;
                    DataTable DTart = classSQL.select("SELECT * FROM roba WHERE sifra='" + Properties.Settings.Default.id_roba + "'", "roba").Tables[0];

                    dgw.Rows[e.RowIndex].Cells["naziv"].Value    = DTart.Rows[0]["naziv"].ToString();
                    dgw.Rows[e.RowIndex].Cells["kolicina"].Value = "1";
                    dgw.Rows[e.RowIndex].Cells["mpc"].Value      = DTart.Rows[0]["mpc"].ToString();

                    dgw.CurrentCell = dgw.Rows[dgw.CurrentRow.Index].Cells[2];
                    dgw.BeginEdit(true);
                    return(false);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                DataTable DTart = classSQL.select("SELECT * FROM roba WHERE sifra='" + dgw.Rows[e.RowIndex].Cells[0].FormattedValue.ToString() + "'", "roba").Tables[0];

                if (DTart.Rows.Count > 0)
                {
                    dgw.Rows[e.RowIndex].Cells["naziv"].Value    = DTart.Rows[0]["naziv"].ToString();
                    dgw.Rows[e.RowIndex].Cells["kolicina"].Value = "1";
                    dgw.Rows[e.RowIndex].Cells["mpc"].Value      = DTart.Rows[0]["mpc"].ToString();

                    dgw.CurrentCell = dgw.Rows[dgw.CurrentRow.Index].Cells[2];
                    dgw.BeginEdit(true);
                    return(true);
                }
                else
                {
                    MessageBox.Show("Kriva šifra.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    dgw.CurrentCell       = dgw.Rows[dgw.CurrentRow.Index].Cells[0];
                    dgw.CurrentCell.Value = "";
                    dgw.BeginEdit(true);
                    return(false);
                }
            }
        }
Ejemplo n.º 8
0
        private void btnEnter_Click(object sender, EventArgs e)
        {
            frmRobaTrazi roba_trazi = new frmRobaTrazi();

            roba_trazi.ShowDialog();
            string propertis_sifra = Properties.Settings.Default.id_roba.Replace(" ", "");

            if (propertis_sifra != "")
            {
                string sql = "SELECT * FROM roba WHERE sifra='" + propertis_sifra + "'";

                DTRoba = classSQL.select(sql, "roba").Tables[0];
                if (DTRoba.Rows.Count > 0)
                {
                    txtSifra_robe.Text = DTRoba.Rows[0]["sifra"].ToString();
                    lblOartiklu.Text   = DTRoba.Rows[0]["naziv"].ToString() + ", \r\nCijena:" + Convert.ToDouble(DTRoba.Rows[0]["mpc"].ToString()).ToString("#0.00") + " kn";

                    string sql_normativ = "SELECT " +
                                          " caffe_normativ.sifra_normativ," +
                                          " roba.naziv," +
                                          " roba.mpc," +
                                          " caffe_normativ.kolicina," +
                                          " caffe_normativ.id_stavka" +
                                          " FROM caffe_normativ" +
                                          " LEFT JOIN roba ON roba.sifra=caffe_normativ.sifra_normativ WHERE caffe_normativ.sifra='" + propertis_sifra + "'";
                    DTRobaNormativi = classSQL.select(sql_normativ, "caffe_normativ").Tables[0];
                    dgw.Rows.Clear();

                    for (int i = 0; i < DTRobaNormativi.Rows.Count; i++)
                    {
                        dgw.Rows.Add(DTRobaNormativi.Rows[i]["sifra_normativ"].ToString(), DTRobaNormativi.Rows[i]["naziv"].ToString(), DTRobaNormativi.Rows[i]["kolicina"].ToString(), DTRobaNormativi.Rows[i]["mpc"].ToString(), DTRobaNormativi.Rows[i]["id_stavka"].ToString());
                    }
                    dgw.Rows.Add();
                }
                else
                {
                    MessageBox.Show("Za ovu šifru ne postoj artikl ili usluga.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 9
0
        private void btnPartner_Click(object sender, EventArgs e)
        {
            frmRobaTrazi roba_trazi = new frmRobaTrazi();

            roba_trazi.ShowDialog();
            string propertis_sifra = Properties.Settings.Default.id_roba.Trim();

            if (propertis_sifra != "")
            {
                string sql = "SELECT * FROM roba WHERE sifra='" + propertis_sifra + "'";

                DataTable DTRoba = classSQL.select(sql, "roba").Tables[0];
                if (DTRoba.Rows.Count > 0)
                {
                    txtSifra.Text  = DTRoba.Rows[0]["sifra"].ToString();
                    txtNaslov.Text = DTRoba.Rows[0]["naziv"].ToString();
                }
                else
                {
                    MessageBox.Show("Za ovu šifru ne postoji artikl ili usluga.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 10
0
        private void txtSifra_robe_KeyDown(object sender, KeyEventArgs e)
        {
            spremljeno = false;
            if (e.KeyCode == Keys.Enter)
            {
                e.SuppressKeyPress = true;

                if (txtSifra_robe.Text == "")
                {
                    frmRobaTrazi roba = new frmRobaTrazi();
                    roba.ShowDialog();

                    if (Properties.Settings.Default.id_roba != "")
                    {
                        txtSifra_robe.Text = Properties.Settings.Default.id_roba;
                        txtSifra_robe.Select();
                    }
                    else
                    {
                        return;
                    }
                }

                for (int y = 0; y < dgw.Rows.Count; y++)
                {
                    if (txtSifra_robe.Text == dgw.Rows[y].Cells["sifra"].FormattedValue.ToString().Trim())
                    {
                        MessageBox.Show("Artikl ili usluga već postoje u ovoj inventuri.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        dgw.CurrentCell = dgw.Rows[y].Cells[4];
                        dgw.BeginEdit(true);
                        return;
                    }
                }

                string sql = string.Format(@"SELECT roba.jm, roba.naziv, roba.oduzmi, roba_prodaja.id_skladiste, roba_prodaja.kolicina, roba_prodaja.vpc, roba_prodaja.porez, roba_prodaja.sifra
                                            FROM roba_prodaja
                                            INNER JOIN roba ON roba_prodaja.sifra=roba.sifra
                                            WHERE (roba_prodaja.sifra = '{0}' OR roba.ean = '{0}') AND roba_prodaja.id_skladiste = '{1}';",
                                           txtSifra_robe.Text,
                                           cbSkladiste.SelectedValue);

                DTRoba = classSQL.select(sql, "roba_prodaja").Tables[0];
                if (DTRoba.Rows.Count > 0)
                {
                    for (int y = 0; y < dgw.Rows.Count; y++)
                    {
                        if (DTRoba.Rows[0]["sifra"].ToString() == dgw.Rows[y].Cells["sifra"].FormattedValue.ToString().Trim())
                        {
                            MessageBox.Show("Artikl ili usluga već postoje u ovoj inventuri.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }

                    txtSifra_robe.BackColor = Color.White;
                    SetRoba();
                    dgw.Select();
                    dgw.CurrentCell = dgw.Rows[dgw.Rows.Count - 1].Cells[4];
                    dgw.BeginEdit(true);
                    txtBrojInventure.ReadOnly  = true;
                    nmGodinaInventure.ReadOnly = true;
                }
                else
                {
                    sql = string.Format(@"SELECT jm, naziv, oduzmi, '0' as kolicina, vpc, porez,sifra
FROM roba
WHERE sifra = '{0}' OR ean = '{0}';", txtSifra_robe.Text);

                    DTRoba = classSQL.select(sql, "roba").Tables[0];
                    if (DTRoba.Rows.Count > 0)
                    {
                        txtSifra_robe.BackColor = Color.White;
                        SetRoba();
                        dgw.Select();
                        dgw.CurrentCell = dgw.Rows[dgw.Rows.Count - 1].Cells[4];
                        dgw.BeginEdit(true);
                        txtBrojInventure.ReadOnly  = true;
                        nmGodinaInventure.ReadOnly = true;
                    }
                    else
                    {
                        MessageBox.Show("Za ovu šifru ne postoji artikl ili usluga u odabranom skladištu.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }