Beispiel #1
0
        private void createpacking(object sender, EventArgs e)
        {
            String opt   = Properties.Settings.Default.username;
            String grade = Properties.Settings.Default.grade;

            String   packingsize = Properties.Settings.Default.packingsize;
            DateTime dt          = DateTime.Now;
            int      julian      = dt.DayOfYear;
            String   juliancode  = julian.ToString();
            String   curryear    = DateTime.Now.ToString("yy");

            List <object[]> ft  = new List <object[]>();
            MainMenu        frm = new MainMenu();

            //get sequence box, boxno, caseno, lot_number
            frm = new MainMenu();
            String boxno  = frm.get_data_sequence_boxno();
            String caseno = frm.get_data_sequence_caseno();


            /*
             * List<object[]> data1 = new List<object[]>();
             * do
             * {
             *  data1 = frm.get_data_table_string("tbpacking", "case_number", caseno);
             *  if (data1.Count > 0)
             *  {
             *      caseno = frm.get_data_sequence_caseno();
             *  }
             * }
             * while (data1.Count > 0);
             */


            String          lot_number = "L" + caseno;
            String          connString = Konek();
            MySqlConnection conn5      = new MySqlConnection(connString);

            conn5.Open();
            try
            {
                MySqlCommand mySql3  = conn5.CreateCommand();
                String       userlog = dt.ToString("yyyy-MM-dd hh:mm:ss") + "," + opt + ", rcv creation";
                mySql3.CommandText =
                    "Insert into tbpacking(box_number,case_number,grade,packingsize,username,moddatetime,lot_number,productname, productpacking)" +
                    " values(@box_number,@case_number,@grade,@packingsize,@username,@moddatetime,@lot_number, @productname, @productpacking)";
                mySql3.Parameters.AddWithValue("@box_number", boxno);
                mySql3.Parameters.AddWithValue("@case_number", caseno);
                mySql3.Parameters.AddWithValue("@grade", grade);
                mySql3.Parameters.AddWithValue("@packingsize", packingsize);
                mySql3.Parameters.AddWithValue("@moddatetime", DateTime.Parse(dt.ToString("yyyy-MM-dd HH:mm tt")));
                mySql3.Parameters.AddWithValue("@username", opt);
                mySql3.Parameters.AddWithValue("@lot_number", lot_number);
                mySql3.Parameters.AddWithValue("@productname", cbproducttype.Text.Trim());
                mySql3.Parameters.AddWithValue("@productpacking", cbproductsize.Text.Trim());
                mySql3.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error message " + ex.Message);
            }
            conn5.Close();
            packingentry(sender, e, caseno, boxno, grade, packingsize);
        }
Beispiel #2
0
        private void createpacking()
        {
            String   opt         = Properties.Settings.Default.username;
            String   grade       = cbgrade.Text.Trim();
            String   intlotcode  = get_intlotcode();
            String   packingsize = cbpackingsize.Text.Trim();
            DateTime dt          = DateTime.Now;
            int      julian      = dt.DayOfYear;
            String   juliancode  = julian.ToString();

            if (juliancode.Length == 1)
            {
                juliancode = "00" + juliancode;
            }
            else if (juliancode.Length == 2)
            {
                juliancode = "0" + juliancode;
            }

            String curryear = DateTime.Now.ToString("yy");

            List <object[]> ft  = new List <object[]>();
            MainMenu        frm = new MainMenu();

            //get sequence box, boxno, caseno, lot_number
            frm = new MainMenu();
            String boxno = frm.get_data_sequence_boxno();

            gboxno = boxno;
            String caseno = frm.get_data_sequence_caseno();

            gcaseno = caseno;
            String lot_number = "L" + caseno;

            glotnumber = lot_number;

            String          connString = Konek();
            MySqlConnection conn5      = new MySqlConnection(connString);

            conn5.Open();
            try
            {
                MySqlCommand mySql3  = conn5.CreateCommand();
                String       userlog = dt.ToString("yyyy-MM-dd hh:mm:ss") + "," + opt + ", rcv creation";
                mySql3.CommandText =
                    "Insert into tbpacking(box_number,case_number,grade,packingsize,username,moddatetime,lot_number,productname, productpacking, batchcode, suppcode, best_before_date, pieces, boxweight,proddate,certificate, intlotcode)" +
                    " values(@box_number,@case_number,@grade,@packingsize,@username,@moddatetime,@lot_number, @productname, @productpacking,@batchcode, @suppcode,@best_before_date,@pieces,@boxweight,@proddate,@certificate,@intlotcode)";
                mySql3.Parameters.AddWithValue("@box_number", boxno);
                mySql3.Parameters.AddWithValue("@case_number", caseno);
                mySql3.Parameters.AddWithValue("@grade", grade);
                mySql3.Parameters.AddWithValue("@packingsize", packingsize);
                mySql3.Parameters.AddWithValue("@moddatetime", frm.get_server_time());
                mySql3.Parameters.AddWithValue("@username", opt);
                mySql3.Parameters.AddWithValue("@lot_number", lot_number);
                mySql3.Parameters.AddWithValue("@productname", cbproductname.Text.Trim());
                mySql3.Parameters.AddWithValue("@productpacking", cbproductpacking.Text.Trim());
                mySql3.Parameters.AddWithValue("@batchcode", txtbatch.Text);
                mySql3.Parameters.AddWithValue("@suppcode", txtsuppcode.Text);

                DateTime processdate      = dateTimePicker1.Value;
                DateTime best_before_date = processdate.AddDays(730);
                gbest_before_date = best_before_date;
                mySql3.Parameters.AddWithValue("@best_before_date", best_before_date);
                mySql3.Parameters.AddWithValue("@pieces", Int32.Parse(txtpieces.Text.Trim()));
                mySql3.Parameters.AddWithValue("@boxweight", Double.Parse(txtboxweight.Text.Trim()));
                mySql3.Parameters.AddWithValue("@proddate", processdate);
                mySql3.Parameters.AddWithValue("@certificate", cbcertificate.Text.Trim());
                mySql3.Parameters.AddWithValue("@intlotcode", intlotcode);
                mySql3.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error message " + ex.Message);
            }
            conn5.Close();
        }