Пример #1
0
        static void Main()
        {
            DeliveryOrder dor = new DeliveryOrder("3320-17020041", "1001", "001", 8000, "25/06/2018");

            Validation test = new Validation();

            if (test.Validate(dor))
            {
                Console.Write("Validated");
            }
            else
            {
                Console.Write("Wrong");
            }

            Calculation cal = new Calculation();

            if (cal.confirmDeliveryDate(dor))
            {
                Console.Write("True");
            }
            else
            {
                Console.Write("False");
            }
        }
Пример #2
0
        public bool read(String directory, ref DeliveryOrder deliveryOrder)
        {
            if (!isEmpty(directory))
            {
                DirectoryInfo dir      = new DirectoryInfo(@directory);
                FileInfo[]    TXTFiles = dir.GetFiles("*.txt");

                var lines = File.ReadAllLines(@dir + "\\" + TXTFiles[0].Name);

                string[] data = lines[0].Split(',');

                deliveryOrder.setPONo(data[0]);
                deliveryOrder.setDescriptionNo(data[1]);
                deliveryOrder.setLineNo(data[2]);
                int deliveryQty = int.Parse(data[3]);
                deliveryOrder.setDeliveryQty(deliveryQty);
                deliveryOrder.setDeliveryDate(data[4]);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        public bool confirmDeliveryDate(DeliveryOrder deliveryOrder)
        {
            PurchaseOrderItem po = new PurchaseOrderItem();

            string        connectionString = null;
            SqlConnection connection;
            SqlCommand    command;
            string        sql = null;
            SqlDataReader dataReader;

            connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=\"C:\\Users\\PUA\\Desktop\\FYP test\\FYP test\\fypDB.mdf\";Integrated Security=True";
            sql        = "select * from POItems where PONo = @PONo";
            connection = new SqlConnection(connectionString);

            try
            {
                connection.Open();
                command = new SqlCommand(sql, connection);
                command.Parameters.AddWithValue("@PONo", deliveryOrder.getPONo());
                dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    po.setLineNO(dataReader["LineNo"].ToString());
                    po.setPONo(dataReader["PONo"].ToString());
                    po.setDescriptionNO(dataReader["DescriptionNo"].ToString());
                    po.setETADate(dataReader["ETADate"].ToString());
                }
                connection.Close();
            }
            catch (Exception ex)
            {
            }

            DateTime poETADate = DateTime.Parse(po.getETADate());
            DateTime doDate    = DateTime.Parse(deliveryOrder.getDeliveryDate());

            if (doDate <= poETADate)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Пример #4
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (btnStart.Text.Equals("Start"))
            {
                fdb.SelectedPath = originalPath;
                if (MessageBox.Show("Is this the folder " + "\n" + originalPath + "   ?", "", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    fdb.ShowDialog();
                    String folderName = fdb.SelectedPath;
                    originalPath   = folderName;
                    lblStatus.Text = folderName;
                }


                picStatus.Image = FYP_test.Properties.Resources.Neon_green_dot_hi;
                btnStart.Text   = "Stop";
                lblStatus.Text  = "Running";
                var test = new Process();
                if (test.Start(originalPath))
                {
                    lblFolder.Text = "Folder is empty";
                }
                else
                {
                    lblFolder.Text = "Folder is not empty";
                    DeliveryOrder deliveryOrder = new DeliveryOrder();
                    Folder        folder        = new Folder();
                    if (folder.read(originalPath, ref deliveryOrder))
                    {
                        txtResult.AppendText("Read Successfully");
                        txtResult.AppendText(Environment.NewLine);
                        txtResult.AppendText(deliveryOrder.ToString());
                    }
                }
            }
            else
            {
                btnStart.Text   = "Start";
                lblStatus.Text  = "Down";
                picStatus.Image = FYP_test.Properties.Resources.red_dot_md;
            }
        }
Пример #5
0
        public bool Validate(DeliveryOrder deliveryOrder)
        {
            PurchaseOrderItem po = new PurchaseOrderItem();

            //var con = ConfigurationManager.ConnectionStrings["Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=\"C: \\Users\\PUA\\Desktop\\FYP test\\FYP test\\fypDB.mdf\";Integrated Security=True"] .ConnectionString;
            //SqlConnection myConnection = new SqlConnection(con);
            //string queryString = "select * from PurchaseOrder where PONo = @PONo";
            //SqlCommand query = new SqlCommand(queryString, myConnection);
            //query.Parameters.AddWithValue("@PONo", deliveryOrder.getPONo());
            //}
            //myConnection.Open();


            //using (SqlDataReader oReader = query.ExecuteReader())
            //{
            //    while (oReader.Read())
            //    {
            //        po.setLineNO(oReader["LineNo"].ToString());
            //        po.setPONo(oReader["PONo"].ToString());
            //        po.setDescriptionNO(oReader["DescriptionNo"].ToString());
            //        po.setETADate(oReader["ETADate"].ToString());
            //    }
            //}

            string        connectionString = null;
            SqlConnection connection;
            SqlCommand    command;
            string        sql = null;
            SqlDataReader dataReader;

            connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=\"C:\\Users\\PUA\\Desktop\\FYP test\\FYP test\\fypDB.mdf\";Integrated Security=True";
            sql        = "select * from POItems where PONo = @PONo";
            connection = new SqlConnection(connectionString);

            try
            {
                connection.Open();
                command = new SqlCommand(sql, connection);
                command.Parameters.AddWithValue("@PONo", deliveryOrder.getPONo());
                dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    po.setLineNO(dataReader["LineNo"].ToString());
                    po.setPONo(dataReader["PONo"].ToString());
                    po.setDescriptionNO(dataReader["DescriptionNo"].ToString());
                    po.setETADate(dataReader["ETADate"].ToString());
                }
            }catch (Exception ex)
            {
            }


            if (deliveryOrder.getPONo().Equals(po.getPoNo()))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }