Ejemplo n.º 1
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            Form18 frm18 = new Form18(index, kodzik, nazwik, cenik, ceniksp, vacik, wymagane, zliczono, statusik, opak, jedn, asorcik, this, rownum, 1, ilosc, idf);

            frm18.Show();
        }
Ejemplo n.º 2
0
        private void FindIndexInBase()
        {
            string connectionString;

            connectionString = "DataSource=Baza.sdf; Password=matrix1";
            SqlCeConnection cn = new SqlCeConnection(connectionString);

            cn.Open();
            string kodbuf = kodzik;
            int    rowqty = 0;

            kod_t.Text = "SZUKAM TOWARU";
            kod_t.Refresh();
            SqlCeCommand cmd2 = cn.CreateCommand();

            cmd2.CommandText = "SELECT kod, COUNT(nazwa) FROM dane WHERE kod = ? GROUP BY kod";
            cmd2.Parameters.Add("@k", SqlDbType.NVarChar, 20);
            cmd2.Parameters["@k"].Value = kodbuf;
            cmd2.Prepare();
            SqlCeDataReader dr1 = cmd2.ExecuteReader();

            while (dr1.Read())
            {
                rowqty = dr1.GetInt32(1);
            }
            goodfound = rowqty;
            if (rowqty > 0)
            {
                SqlCeCommand cmd = cn.CreateCommand();
                cmd.CommandText = "SELECT kod, nazwa, stan, cenazk, cenasp, vat FROM dane WHERE kod = ?";
                cmd.Parameters.Add("@k", SqlDbType.NVarChar, 20);
                cmd.Parameters["@k"].Value = kodbuf;
                kodzik = kodbuf;

                cmd.Prepare();
                SqlCeDataReader dr = cmd.ExecuteReader();


                while (dr.Read())
                {
                    nazwik  = dr.GetString(1);
                    cenik   = dr.GetString(3);
                    ceniksp = dr.GetString(4);
                    vacik   = dr.GetString(5);
                }
                wymagane = "0";
                zliczono = "0";
                statusik = "Nowy";

                opak    = "1";
                jedn    = "szt.";
                asorcik = "Default";
                ilosc   = null;

                Form18 frm18 = new Form18(index, kodzik, nazwik, cenik, ceniksp, vacik, wymagane, zliczono, statusik, opak, jedn, asorcik, this, rownum, 0, ilosc, id);
                frm18.Show();
                cn.Close();
            }
            else
            {
                DialogResult dialog = MessageBox.Show("Nie znaleziono kodu towaru czy? doda� mimo to - Tak, Nie dodawa� - Nie", "Brak towaru", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                if (dialog == DialogResult.Yes)
                {
                    goodfound = 1;
                    kodzik    = kodbuf;
                    nazwik    = "Nowy";
                    cenik     = "0";
                    ceniksp   = "0";
                    vacik     = "0";
                    wymagane  = "0";
                    zliczono  = "0";
                    statusik  = "Nowy";

                    opak    = "1";
                    jedn    = "szt.";
                    asorcik = "Default";
                    ilosc   = null;
                    cn.Close();
                    Form18 frm18 = new Form18(index, kodzik, nazwik, cenik, ceniksp, vacik, wymagane, zliczono, statusik, opak, jedn, asorcik, this, rownum, 0, ilosc, id);
                    frm18.Show();
                }
                else if (dialog == DialogResult.No)
                {
                    kod_t.Text = "KOD LUB Z LISTY";
                    kod_t.Focus();
                    cn.Close();
                }
            }
        }
Ejemplo n.º 3
0
        private void OpenIndex(int openflag)
        {
            try
            {
                if (openflag == 1)
                {
                    poznum = dataGrid1.CurrentCell.RowNumber;
                    string connectionString;
                    connectionString = "DataSource=Baza.sdf; Password=matrix1";
                    SqlCeConnection cn = new SqlCeConnection(connectionString);
                    cn.Open();



                    SqlCeDataAdapter db     = new SqlCeDataAdapter("SELECT * FROM edibody", cn);
                    DataTable        table2 = new DataTable();
                    db.SelectCommand = new SqlCeCommand("SELECT kod, Nazwa, IleWOpak, Vat, Jm, Asortyment, Cena, CenaSp, status, Ilosc, id FROM edibody WHERE NrDok =  ? and complete = 0", cn);
                    db.SelectCommand.Parameters.Add("@k", SqlDbType.NVarChar, 30);
                    db.SelectCommand.Parameters["@k"].Value = index;
                    db.SelectCommand.ExecuteNonQuery();
                    db.Fill(table2);

                    kodzik   = table2.Rows[poznum][0].ToString();
                    nazwik   = table2.Rows[poznum][1].ToString();
                    opak     = table2.Rows[poznum][2].ToString();
                    vacik    = table2.Rows[poznum][3].ToString();
                    jedn     = table2.Rows[poznum][4].ToString();
                    asorcik  = table2.Rows[poznum][5].ToString();
                    cenik    = table2.Rows[poznum][6].ToString();
                    ceniksp  = table2.Rows[poznum][7].ToString();
                    statusik = table2.Rows[poznum][8].ToString();
                    wymagane = table2.Rows[poznum][9].ToString();
                    ilosc    = null;
                    id       = int.Parse(table2.Rows[poznum][10].ToString());
                    zliczono = "0";
                    SqlCeCommand cmd1 = cn.CreateCommand();
                    cmd1.CommandText = "SELECT kod, NrDok, Ilosc FROM fedibody WHERE kod = ? and NrDok = ?";
                    cmd1.Parameters.Add("@k", SqlDbType.NVarChar, 20);
                    cmd1.Parameters.Add("@d", SqlDbType.NVarChar, 20);
                    cmd1.Parameters["@k"].Value = kodzik;
                    cmd1.Parameters["@d"].Value = index;
                    cmd1.Prepare();
                    SqlCeDataReader dr1 = cmd1.ExecuteReader();
                    while (dr1.Read())
                    {
                        zliczono = ((decimal.Parse(zliczono) + decimal.Parse(dr1.GetString(2))).ToString());
                    }


                    cn.Close();

                    Form18 frm18 = new Form18(index, kodzik, nazwik, cenik, ceniksp, vacik, wymagane, zliczono, statusik, opak, jedn, asorcik, this, rownum, 1, ilosc, id);
                    frm18.Show();
                }
                else if (openflag == 0)
                {
                    poznum = dataGrid2.CurrentCell.RowNumber;
                    string connectionString;
                    connectionString = "DataSource=Baza.sdf; Password=matrix1";
                    SqlCeConnection cn = new SqlCeConnection(connectionString);
                    cn.Open();



                    SqlCeDataAdapter db     = new SqlCeDataAdapter("SELECT * FROM fedibody", cn);
                    DataTable        table2 = new DataTable();
                    db.SelectCommand = new SqlCeCommand("SELECT kod, Nazwa, IleWOpak, Vat, Jm, Asortyment, Cena, CenaSp, status, Ilosc, id FROM fedibody WHERE NrDok =  ?", cn);
                    db.SelectCommand.Parameters.Add("@k", SqlDbType.NVarChar, 30);
                    db.SelectCommand.Parameters["@k"].Value = index;
                    db.SelectCommand.ExecuteNonQuery();
                    db.Fill(table2);
                    zliczono = "0";
                    kodzik   = table2.Rows[poznum][0].ToString();
                    nazwik   = table2.Rows[poznum][1].ToString();
                    opak     = table2.Rows[poznum][2].ToString();
                    vacik    = table2.Rows[poznum][3].ToString();
                    jedn     = table2.Rows[poznum][4].ToString();
                    asorcik  = table2.Rows[poznum][5].ToString();
                    cenik    = table2.Rows[poznum][6].ToString();
                    ceniksp  = table2.Rows[poznum][7].ToString();
                    statusik = table2.Rows[poznum][8].ToString();
                    ilosc    = table2.Rows[poznum][9].ToString();
                    idf      = int.Parse(table2.Rows[poznum][10].ToString());

                    SqlCeCommand cmd1 = cn.CreateCommand();
                    cmd1.CommandText = "SELECT kod, NrDok, Ilosc FROM fedibody WHERE kod = ? and NrDok = ?";
                    cmd1.Parameters.Add("@k", SqlDbType.NVarChar, 20);
                    cmd1.Parameters.Add("@d", SqlDbType.NVarChar, 20);
                    cmd1.Parameters["@k"].Value = kodzik;
                    cmd1.Parameters["@d"].Value = index;
                    cmd1.Prepare();
                    SqlCeDataReader dr1 = cmd1.ExecuteReader();
                    while (dr1.Read())
                    {
                        zliczono = ((decimal.Parse(zliczono) + decimal.Parse(dr1.GetString(2))).ToString());
                    }


                    cn.Close();

                    Form18 frm18 = new Form18(index, kodzik, nazwik, cenik, ceniksp, vacik, wymagane, zliczono, statusik, opak, jedn, asorcik, this, rownum, 1, ilosc, idf);
                    frm18.Show();
                }
                else if (openflag == 2)
                {
                    poznum = dataGrid1.CurrentCell.RowNumber;
                    string connectionString;
                    connectionString = "DataSource=Baza.sdf; Password=matrix1";
                    SqlCeConnection cn = new SqlCeConnection(connectionString);
                    cn.Open();



                    SqlCeDataAdapter db     = new SqlCeDataAdapter("SELECT * FROM edibody", cn);
                    DataTable        table2 = new DataTable();
                    db.SelectCommand = new SqlCeCommand("SELECT kod, Nazwa, IleWOpak, Vat, Jm, Asortyment, Cena, CenaSp, status, Ilosc, id FROM edibody WHERE NrDok =  ? and complete = 0", cn);
                    db.SelectCommand.Parameters.Add("@k", SqlDbType.NVarChar, 20);
                    db.SelectCommand.Parameters["@k"].Value = index;
                    db.SelectCommand.ExecuteNonQuery();
                    db.Fill(table2);

                    kodzik   = table2.Rows[poznum][0].ToString();
                    nazwik   = table2.Rows[poznum][1].ToString();
                    opak     = table2.Rows[poznum][2].ToString();
                    vacik    = table2.Rows[poznum][3].ToString();
                    jedn     = table2.Rows[poznum][4].ToString();
                    asorcik  = table2.Rows[poznum][5].ToString();
                    cenik    = table2.Rows[poznum][6].ToString();
                    ceniksp  = table2.Rows[poznum][7].ToString();
                    statusik = table2.Rows[poznum][8].ToString();
                    wymagane = table2.Rows[poznum][9].ToString();
                    ilosc    = table2.Rows[poznum][9].ToString();
                    id       = int.Parse(table2.Rows[poznum][10].ToString());
                    zliczono = "0";
                    SqlCeCommand cmd1 = cn.CreateCommand();
                    cmd1.CommandText = "SELECT kod, NrDok, Ilosc FROM fedibody WHERE kod = ? and NrDok = ?";
                    cmd1.Parameters.Add("@k", SqlDbType.NVarChar, 20);
                    cmd1.Parameters.Add("@d", SqlDbType.NVarChar, 20);
                    cmd1.Parameters["@k"].Value = kodzik;
                    cmd1.Parameters["@d"].Value = index;
                    cmd1.Prepare();
                    SqlCeDataReader dr1 = cmd1.ExecuteReader();
                    while (dr1.Read())
                    {
                        zliczono = ((decimal.Parse(zliczono) + decimal.Parse(dr1.GetString(2))).ToString());
                    }


                    cn.Close();

                    Form18 frm18 = new Form18(index, kodzik, nazwik, cenik, ceniksp, vacik, wymagane, zliczono, statusik, opak, jedn, asorcik, this, rownum, 2, ilosc, id);
                    frm18.Show();
                }
                else if (openflag == 3)
                {
                    poznum = dataGrid2.CurrentCell.RowNumber;

                    string connectionString;
                    connectionString = "DataSource=Baza.sdf; Password=matrix1";
                    SqlCeConnection cn = new SqlCeConnection(connectionString);
                    cn.Open();



                    SqlCeDataAdapter db     = new SqlCeDataAdapter("SELECT * FROM fedibody", cn);
                    DataTable        table2 = new DataTable();
                    db.SelectCommand = new SqlCeCommand("SELECT kod, Nazwa, IleWOpak, Vat, Jm, Asortyment, Cena, CenaSp, status, Ilosc, id, wymagane FROM fedibody WHERE NrDok =  ?", cn);
                    db.SelectCommand.Parameters.Add("@k", SqlDbType.NVarChar, 30);
                    db.SelectCommand.Parameters["@k"].Value = index;
                    db.SelectCommand.ExecuteNonQuery();
                    db.Fill(table2);

                    kodzik   = table2.Rows[poznum][0].ToString();
                    nazwik   = table2.Rows[poznum][1].ToString();
                    opak     = table2.Rows[poznum][2].ToString();
                    vacik    = table2.Rows[poznum][3].ToString();
                    jedn     = table2.Rows[poznum][4].ToString();
                    asorcik  = table2.Rows[poznum][5].ToString();
                    cenik    = table2.Rows[poznum][6].ToString();
                    ceniksp  = table2.Rows[poznum][7].ToString();
                    statusik = table2.Rows[poznum][8].ToString();
                    wymagane = table2.Rows[poznum][11].ToString();
                    ilosc    = table2.Rows[poznum][9].ToString();
                    id       = int.Parse(table2.Rows[poznum][10].ToString());

                    zliczono = "0";
                    SqlCeCommand cmd1 = cn.CreateCommand();
                    cmd1.CommandText = "SELECT kod, NrDok, Ilosc FROM fedibody WHERE kod = ? and NrDok = ?";
                    cmd1.Parameters.Add("@k", SqlDbType.NVarChar, 20);
                    cmd1.Parameters.Add("@d", SqlDbType.NVarChar, 20);
                    cmd1.Parameters["@k"].Value = kodzik;
                    cmd1.Parameters["@d"].Value = index;
                    cmd1.Prepare();
                    SqlCeDataReader dr1 = cmd1.ExecuteReader();
                    while (dr1.Read())
                    {
                        zliczono = ((decimal.Parse(zliczono) + decimal.Parse(dr1.GetString(2))).ToString());
                    }


                    cn.Close();

                    Form18 frm18 = new Form18(index, kodzik, nazwik, cenik, ceniksp, vacik, wymagane, zliczono, statusik, opak, jedn, asorcik, this, rownum, 3, ilosc, id);
                    frm18.Show();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("brak pozycji");
            }
        }
Ejemplo n.º 4
0
        private void FindIndex()
        {
            string connectionString;

            connectionString = "DataSource=Baza.sdf; Password=matrix1";
            SqlCeConnection cn = new SqlCeConnection(connectionString);

            cn.Open();

            string kodbuf = kod_t.Text;

            kodzik = kodbuf;


            kod_t.Text = "SZUKAM TOWARU";
            kod_t.Refresh();

            SqlCeCommand cmd2 = cn.CreateCommand();

            cmd2.CommandText = "SELECT kod, count(Nazwa), NrDok, complete FROM edibody WHERE kod = ? and NrDok = ? and complete = 0 group by kod, NrDok, complete";
            cmd2.Parameters.Add("@k", SqlDbType.NVarChar, 20);
            cmd2.Parameters.Add("@nr", SqlDbType.NVarChar, 20);
            cmd2.Parameters["@k"].Value  = kodbuf;
            cmd2.Parameters["@nr"].Value = index;
            cmd2.Prepare();
            SqlCeDataReader dr2    = cmd2.ExecuteReader();
            int             rowqty = 0;

            while (dr2.Read())
            {
                rowqty = dr2.GetInt32(1);
            }

            if (rowqty > 0)
            {
                SqlCeCommand cmd = cn.CreateCommand();
                cmd.CommandText = "SELECT kod, Nazwa, IleWOpak, Vat, Jm, Asortyment, Cena, CenaSp, status, Ilosc, id FROM edibody WHERE kod = ? and NrDok = ? and complete = 0";
                cmd.Parameters.Add("@k", SqlDbType.NVarChar, 20);
                cmd.Parameters.Add("@nr", SqlDbType.NVarChar, 20);
                cmd.Parameters["@k"].Value  = kodbuf;
                cmd.Parameters["@nr"].Value = index;

                cmd.Prepare();
                SqlCeDataReader dr = cmd.ExecuteReader();



                while (dr.Read())
                {
                    kodzik   = dr.GetString(0);
                    nazwik   = dr.GetString(1);
                    opak     = dr.GetString(2);
                    vacik    = dr.GetString(3);
                    jedn     = dr.GetString(4);
                    asorcik  = dr.GetString(5);
                    cenik    = dr.GetString(6);
                    ceniksp  = dr.GetString(7);
                    statusik = dr.GetString(8);
                    wymagane = dr.GetString(9);
                    id       = dr.GetInt32(10);
                }

                SqlCeCommand cmd1 = cn.CreateCommand();
                cmd1.CommandText = "SELECT kod, NrDok, Ilosc FROM fedibody WHERE kod = ? and NrDok = ?";
                cmd1.Parameters.Add("@k", SqlDbType.NVarChar, 30);
                cmd1.Parameters.Add("@d", SqlDbType.NVarChar, 30);
                cmd1.Parameters["@k"].Value = kodzik;
                cmd1.Parameters["@d"].Value = index;
                cmd1.Prepare();
                SqlCeDataReader dr1 = cmd1.ExecuteReader();
                while (dr1.Read())
                {
                    zliczono = ((decimal.Parse(zliczono) + decimal.Parse(dr1.GetString(2))).ToString());
                }

                cn.Close();


                Form18 frm18 = new Form18(index, kodzik, nazwik, cenik, ceniksp, vacik, wymagane, zliczono, statusik, opak, jedn, asorcik, this, rownum, 1, ilosc, id);
                frm18.Show();
            }
            else
            {
                cn.Close();
                DialogResult result = MessageBox.Show("Brak towaru na liscie do kompletacji TAK - dodaj nowy z bazy NIE - wyj�cie ANULUJ - zast�p zaznaczony towarem z bazy", "Pytanie", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                if (result == DialogResult.Yes)
                {
                    FindIndexInBase();
                }
                else if (result == DialogResult.Cancel)
                {
                    FindIndexInBase();
                    if (goodfound > 0)
                    {
                        Deleterow(1);
                        Loaddata();
                    }
                }
            }

            kod_t.Text = "KOD LUB Z LISTY";
            kod_t.Refresh();

            /*
             * else
             * {
             *      DialogResult result = MessageBox.Show("Brak Towaru na li�cie, czy doda� z bazy?", "Pytanie", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
             *      if (result == DialogResult.Yes)
             *      {
             *
             *              kod_t.Text = kodbuf;
             *              nazwa_t.ReadOnly = false;
             *              cena_t.ReadOnly = false;
             *              nazwa_t.Focus();
             *      }
             *      else if (dialog == DialogResult.No)
             *      {
             *              kod_t.Text = null;
             *              kod_t.Focus();
             *      }
             *      else if (dialog == DialogResult.Cancel)
             *      {
             *              nazwa_t.ReadOnly = true;
             *              cena_t.ReadOnly = true;
             *              kod_t.Text = kodbuf;
             *              ilosc_t.Focus();
             *      }
             * }
             *
             * }*/
        }