private void expiryDateButton_Click(object sender, EventArgs e) { DateCriteria dateCriteria = new DateCriteria(); DateTime expiryDate = calculateExpiryDate(); dateCriteria.ExpiryDate = expiryDate; mainForm.ExpiryCriterias.Add(dateCriteria); expiryDateButton.Enabled = false; }
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ْ"; } }
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); } }
public static DateCriteria GetDateCriteria(int itemID) { SqlConnection sqlConnection = new SqlConnection(Properties.Settings.Default.MyConnectionString); string query = "Select dbo.dateExpiryTbl.* from dbo.dateExpiryTbl,dbo.expiryCriteriaTbl where (dbo.expiryCriteriaTbl.ID=dbo.dateExpiryTbl.ExpiryCriteriaID) AND (dbo.expiryCriteriaTbl.ItemID=" + itemID + ")"; SqlCommand sqlCommand = new SqlCommand(query, sqlConnection); sqlConnection.Open(); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); DateCriteria dateCriteria = null; if (sqlDataReader.Read()) { dateCriteria = new DateCriteria(); dateCriteria.ExpiryDate = DateTime.Parse(sqlDataReader["ExpiryDate"].ToString()); dateCriteria.ID = Int32.Parse(sqlDataReader["ExpiryCriteriaID"].ToString()); } sqlConnection.Close(); return(dateCriteria); }
private void videoStreamingPictureBox_Click(object sender, EventArgs e) { DateCriteria dateCriteria = new DateCriteria(); DateTime expiryDate = DateTime.Now; if (videoStreaming.cameraExist) { if (videoStreaming.streamingVideoCamera) { videoStreaming.CloseVideoSource(); try { TesseractOCREngine OCREngine = new TesseractOCREngine(new Bitmap(videoStreamingPictureBox.Image, new Size(800, 600))); expiryDate = OCREngine.GetExpiredDate(); expiryDateTimePicker.Value = expiryDate; } catch (Exception ex) { MessageBox.Show(ex.Message, "Ops...", MessageBoxButtons.OK, MessageBoxIcon.Error); videoStreaming.StartStreaming(); return; } } else { videoStreaming.StartStreaming(); return; } } else { expiryDate = getExpiryDateFromDateTimePicker(); } dateCriteria.ExpiryDate = expiryDate; mainForm.ExpiryCriterias.Add(dateCriteria); videoStreamingPictureBox.Enabled = false; }