Exemple #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == string.Empty)
            {
                MessageBox.Show("product name field can't be empty, please enter a value!");
                return;
            }


            if (textBox2.Text == string.Empty)
            {
                MessageBox.Show("description of product field can't be empty, please enter a value!");
                return;
            }

            if (textBox3.Text == string.Empty)
            {
                MessageBox.Show("unit price field can't be empty, please enter a value!");
                return;
            }
            if (textBox4.Text == string.Empty)
            {
                MessageBox.Show("quantity field can't be empty, please enter a value!");
                return;
            }

            if (textBox5.Text == string.Empty)
            {
                MessageBox.Show("field can't be empty, please enter a value!");
                return;
            }
            if (textBox6.Text == string.Empty)
            {
                MessageBox.Show("product id field can't be empty, please enter a   value!");
                return;
            }

            if (textBox31.Text == string.Empty)
            {
                MessageBox.Show("field can't be empty, please enter a value!");
                return;
            }
            if (textBox32.Text == string.Empty)
            {
                MessageBox.Show("field can't be empty, please enter a value!");
                return;
            }

            if (textBox33.Text == string.Empty)
            {
                MessageBox.Show("sales rep field can't be empty, please enter a value!");
                return;
            }
            if (textBox34.Text == string.Empty)
            {
                MessageBox.Show("name of customer field can't be empty, please enter a value!");
                return;
            }

            if (textBox35.Text == string.Empty)
            {
                MessageBox.Show("month field can't be empty, please enter a numeric value! eg 1 for january, 6 for june.");
                return;
            }

            MySqlConnection con = new MySqlConnection("server=localhost;user id=root;database=erp_crm");

            con.Open();
            MySqlCommand cmd = new MySqlCommand("INSERT INTO salesreg(`name_prd`, `desc`, `unit_price`, `qty`, `total`,`prd_id`,`name_cus`, `sales_rep`, `grand_total`, `invoice_no`, `month`) VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "', '" + textBox4.Text + "','" + textBox5.Text + "', '" + textBox6.Text + "','" + textBox34.Text + "', '" + textBox33.Text + "','" + textBox31.Text + "', '" + textBox32.Text + "', '" + textBox35.Text + "')", con);

            cmd.ExecuteNonQuery();
            MessageBox.Show("record has been succesfully inserted in the database, Click Ok to proceed in prinitng receipt");
            Form8 myform = new Form8();

            this.Hide();
            myform.Show();
            con.Close();
        }
Exemple #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == string.Empty)
            {
                MessageBox.Show("field can't be empty, please enter a value!");
                return;
            }


            if (textBox2.Text == string.Empty)
            {
                MessageBox.Show("field can't be empty, please enter a value!");
                return;
            }

            if (textBox3.Text == string.Empty)
            {
                MessageBox.Show("field can't be empty, please enter a value!");
                return;
            }
            if (textBox4.Text == string.Empty)
            {
                MessageBox.Show("field can't be empty, please enter a value!");
                return;
            }

            if (textBox5.Text == string.Empty)
            {
                MessageBox.Show("field can't be empty, please enter a value!");
                return;
            }
            if (textBox6.Text == string.Empty)
            {
                MessageBox.Show("field can't be empty, please enter a   value!");
                return;
            }

            if (textBox31.Text == string.Empty)
            {
                MessageBox.Show("field can't be empty, please enter a value!");
                return;
            }
            if (textBox32.Text == string.Empty)
            {
                MessageBox.Show("field can't be empty, please enter a value!");
                return;
            }

            if (textBox33.Text == string.Empty)
            {
                MessageBox.Show("field can't be empty, please enter a value!");
                return;
            }
            if (textBox34.Text == string.Empty)
            {
                MessageBox.Show("field can't be empty, please enter a value!");
                return;
            }

            if (textBox35.Text == string.Empty)
            {
                MessageBox.Show("field for month can't be empty, please enter a value!");
                return;
            }

            {
                long   ticks = DateTime.Now.Ticks;
                byte[] bytes = BitConverter.GetBytes(ticks);
                string id    = Convert.ToBase64String(bytes)
                               .Replace('+', '_')
                               .Replace('/', '-')
                               .TrimEnd('=');
                textBox32.Text = id.ToString();

                DateTime.Now.ToString("yyMMddHHmmssff");
                textBox32.Text = DateTime.Now.ToLongTimeString();
            }
            MySqlConnection con = new MySqlConnection("server=localhost;user id=root;database=erp_crm");

            con.Open();
            MySqlCommand cmd = new MySqlCommand("INSERT INTO salesreg(`name_prd`, `desc`, `unit_price`, `qty`, `total`,`prd_id`,`name_cus`, `sales_rep`, `grand_total`, `invoice_no`, `month`) VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "', '" + textBox4.Text + "','" + textBox5.Text + "', '" + textBox6.Text + "','" + textBox34.Text + "', '" + textBox33.Text + "','" + textBox31.Text + "', '" + textBox32.Text + "', '" + textBox35.Text + "')", con);

            cmd.ExecuteNonQuery();
            MessageBox.Show("record has been succesfully inserted in the database, Click Ok to proceed in prinitng receipt");
            Form8 myform = new Form8();

            this.Hide();
            myform.Show();
            con.Close();
        }