예제 #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            using (SqlConnection con = new SqlConnection(@"Data source=.\SQLEXPRESS;Initial Catalog=I002_Solodkov;User ID=user;Password=Passw0rd;"))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = con.CreateCommand();
                    //заполнение данных
                    cmd.CommandText = "DELETE [pcoming] WHERE [pcoming].id=" + ids;
                    cmd.ExecuteScalar();


                    coming_new uc = new coming_new(id_com);
                    uc.Location = new Point(0, 30);
                    uc.Size     = Size;
                    this.Parent.Controls.Add(uc);
                    this.Parent.Controls.RemoveAt(1);
                }
                catch (Exception ex)
                {
                    errol.Text    = "Ошибка записи";
                    errol.Visible = true;
                }
                finally
                {
                    con.Close();
                }
            }
        }
예제 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            coming_new uc = new coming_new(id_com);

            uc.Location = new Point(0, 30);
            uc.Size     = Size;
            this.Parent.Controls.Add(uc);
            this.Parent.Controls.RemoveAt(1);
        }
예제 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (SqlConnection con = new SqlConnection(@"Data source=.\SQLEXPRESS;Initial Catalog=I002_Solodkov;User ID=user;Password=Passw0rd;"))
            {
                try
                {
                    con.Open();
                    SqlCommand    cmd = con.CreateCommand();
                    SqlDataReader reader;
                    cmd.CommandText = "INSERT coming (date) VALUES ('" + Convert.ToString(DateTime.Now) + "')";
                    cmd.ExecuteScalar();

                    cmd.CommandText = "SELECT * FROM [coming] ORDER BY id DESC";
                    string id_coming = "";
                    reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        id_coming = Convert.ToString(String.Format("{0}", reader[0]));
                        break;
                    }
                    reader.Close();

                    coming_new uc = new coming_new(id_coming);
                    uc.Location = new Point(0, 30);
                    uc.Size     = Size;
                    this.Parent.Controls.Add(uc);
                    this.Parent.Controls.RemoveAt(1);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Convert.ToString(ex));
                }
                finally
                {
                    con.Close();
                }
            }
        }
예제 #4
0
        private void table_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == 1 || e.ColumnIndex == 2 || e.ColumnIndex == 3 || e.ColumnIndex == 4 || e.ColumnIndex == 5)
                {
                    String id = Convert.ToString(table.Rows[Convert.ToInt32(e.RowIndex.ToString())].Cells[0].Value);


                    using (SqlConnection con = new SqlConnection(@"Data source=.\SQLEXPRESS;Initial Catalog=I002_Solodkov;User ID=user;Password=Passw0rd;"))
                    {
                        try
                        {
                            con.Open();
                            SqlCommand cmd = con.CreateCommand();
                            //заполнение данных
                            cmd.CommandText = "UPDATE [coming] SET id_kontragent='" + id + "' Where [coming].id=" + ids;
                            cmd.ExecuteScalar();


                            coming_new uc = new coming_new(ids);
                            uc.Location = new Point(0, 30);
                            uc.Size     = Size;
                            this.Parent.Controls.Add(uc);
                            this.Parent.Controls.RemoveAt(1);
                        }
                        catch (Exception ex)
                        {
                        }
                        finally
                        {
                            con.Close();
                        }
                    }
                }
            }
            catch { }
        }
예제 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            string namess = textBox2.Text;
            string kol    = textBox1.Text;
            string prices = textBox3.Text;

            if (namess != "" && kol != "" && prices != "")
            {
                using (SqlConnection con = new SqlConnection(@"Data source=.\SQLEXPRESS;Initial Catalog=I002_Solodkov;User ID=user;Password=Passw0rd;"))
                {
                    try
                    {
                        con.Open();
                        SqlCommand cmd = con.CreateCommand();



                        cmd.CommandText = "select * from pcoming where id_coming=" + id_com + "AND id_product=" + id_product;

                        bool          prov   = true;
                        SqlDataReader reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            prov = false;
                        }
                        reader.Close();


                        if (prov)
                        {
                            //заполнение данных
                            cmd.CommandText = "UPDATE [pcoming] SET id_product='" + id_product + "', price='" + prices + "', count='" + kol + "' Where [pcoming].id=" + ids;
                            cmd.ExecuteScalar();


                            coming_new uc = new coming_new(id_com);
                            uc.Location = new Point(0, 30);
                            uc.Size     = Size;
                            this.Parent.Controls.Add(uc);
                            this.Parent.Controls.RemoveAt(1);
                        }
                        else
                        {
                            errol.Text    = "Ошибка записи";
                            errol.Visible = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        errol.Text    = "Ошибка записи";
                        errol.Visible = true;
                    }
                    finally
                    {
                        con.Close();
                    }
                }
            }
            else
            {
                errol.Text    = "Не все поля заполнены";
                errol.Visible = true;
            }
        }