private void expiryTemperatureButton_Click(object sender, EventArgs e)
        {
            TemperatureCriteria tempCriteria = new TemperatureCriteria();

            tempCriteria.MinTemperature = getMinTemperature();
            tempCriteria.MaxTemperature = getMaxTemperature();
            mainForm.ExpiryCriterias.Add(tempCriteria);
            expiryTemperatureButton.Enabled = false;
        }
Esempio n. 2
0
        private void checkCriteria(int itemID)
        {
            DateCriteria dateCriteria = DateCriteria.GetDateCriteria(itemID);

            if (dateCriteria != null)
            {
                expireLabel.Text = "Expiry Date: " + dateCriteria.ExpiryDate.ToShortDateString() + "\n";
            }
            TemperatureCriteria tempCriteria = TemperatureCriteria.GetTemperatureCriteria(itemID);

            if (tempCriteria != null)
            {
                expireLabel.Text += "Best Temp: from " + tempCriteria.MinTemperature + "Cْ  to  " + tempCriteria.MaxTemperature + "Cْ";
            }
        }
Esempio n. 3
0
        private void checkCriteria(int itemID)
        {
            string       toolTipText  = "";
            DateCriteria dateCriteria = DateCriteria.GetDateCriteria(itemID);

            if (dateCriteria != null)
            {
                expireLabel.Text = "Expiry Date: " + dateCriteria.ExpiryDate.ToShortDateString() + "\n";
                TimeSpan time = dateCriteria.ExpiryDate - DateTime.Now;
                if (time.Days > 0 && time.Days < 8)
                {
                    itemToolTip.ToolTipIcon = ToolTipIcon.Warning;
                    toolTipText             = "Expiry Date after " + (time.Days).ToString() + " day(s).";
                }
                else if (time.Days < 0)
                {
                    itemToolTip.ToolTipIcon = ToolTipIcon.Error;
                    toolTipText             = "Item has been expired" + (time.Days).ToString() + " day(s)ago.";
                }
            }
            TemperatureCriteria tempCriteria = TemperatureCriteria.GetTemperatureCriteria(itemID);

            if (tempCriteria != null)
            {
                expireLabel.Text += "Temp: from " + tempCriteria.MinTemperature + " Cْ  to  " + tempCriteria.MaxTemperature + " Cْ ْ";
                int refTemp = Properties.Settings.Default.refrigeratorInternalTemperature;
                if (refTemp < tempCriteria.MinTemperature || refTemp > tempCriteria.MaxTemperature)
                {
                    if (toolTipText != "")
                    {
                        toolTipText += "\n";
                    }
                    if (refTemp < tempCriteria.MinTemperature)
                    {
                        toolTipText += "Temperature's too low for this item.";
                    }
                    else
                    {
                        toolTipText += "Temperature's too high for this item.";
                    }
                }
            }
            if (toolTipText != "")
            {
                itemToolTip.SetToolTip(this, toolTipText);
            }
        }
Esempio n. 4
0
        public static TemperatureCriteria GetTemperatureCriteria(int itemID)
        {
            SqlConnection sqlConnection = new SqlConnection(Properties.Settings.Default.MyConnectionString);
            string        query         = "Select dbo.temperatureExpiryTbl.* from dbo.temperatureExpiryTbl,dbo.expiryCriteriaTbl where (dbo.expiryCriteriaTbl.ID=dbo.temperatureExpiryTbl.ExpiryCriteriaID) AND (dbo.expiryCriteriaTbl.ItemID=" + itemID + ")";
            SqlCommand    sqlCommand    = new SqlCommand(query, sqlConnection);

            sqlConnection.Open();
            SqlDataReader       sqlDataReader      = sqlCommand.ExecuteReader();
            TemperatureCriteria tempratureCriteria = null;

            if (sqlDataReader.Read())
            {
                tempratureCriteria = new TemperatureCriteria();
                tempratureCriteria.MaxTemperature = Int32.Parse(sqlDataReader["MaxTemperature"].ToString());
                tempratureCriteria.MinTemperature = Int32.Parse(sqlDataReader["MinTemperature"].ToString());
                tempratureCriteria.ID             = Int32.Parse(sqlDataReader["ExpiryCriteriaID"].ToString());
            }
            sqlConnection.Close();
            return(tempratureCriteria);
        }