public outDelivery() { InitializeComponent(); Connection cn = new Connection(); Utilities ut = new Utilities(); try { cn.connect(); cn.cmd.Connection = cn.cnn; cn.cmd.Connection.Open(); cn.cmd.CommandText = "SELECT Delivered FROM MilkCreameryDelivery WHere Date='" + DateTime.Now.ToShortDateString() + "' AND TimeOfDay='" + ut.TimeOfDay() + "'"; object x=cn.cmd.ExecuteScalar(); if (x==null) { }else { lock_load= bool.Parse(cn.cmd.ExecuteScalar().ToString()); } } catch (Exception ex) { MessageBox.Show(ex.Message); } fillStaff(); fillTransporter(); }
private async void fillCombo() { Utilities f=new Utilities(); farmerNumber.Items.Clear(); Connection cn = new Connection(); cn.connect(); cn.cmd.Connection = cn.cnn; cn.cmd.Connection.Open(); cn.cmd.CommandText = "select FarmerNo from Farmer where FarmerNo NOT IN (Select farmerNo from MilkDelivery where DateOfDelivery = '"+DateTime.Now.ToShortDateString()+"' And TimeofDay='"+f.TimeOfDay()+"')"; try { cn.dr = cn.cmd.ExecuteReader(); while (cn.dr.Read()) { farmerNumber.Items.Add(cn.dr.GetString(0)); } } catch(Exception ex){ MessageBox.Show(ex.Message); } if (farmerNumber.Items.Count != 0) { farmerNumber.SelectedIndex = 0; fillName(); } else { MessageDialogResult x; MetroDialogSettings yl=new MetroDialogSettings(); yl.AffirmativeButtonText="Quit"; yl.NegativeButtonText = "View Deliveries"; x=await this.ShowMessageAsync("Entry Complete!", "All Farmers with Valid Farmer Numbers have been Processed. any other processing will have to be done Manualy",MessageDialogStyle.AffirmativeAndNegative,yl); if (x == MessageDialogResult.Affirmative) { this.Hide(); } } }
private void totalMilk(DateTime TotalDate) { if (blovkLoop == false) { float totalmilk = 0; String obj; Utilities ut = new Utilities(); Connection cn = new Connection(); try { cn.connect(); cn.cmd.Connection = cn.cnn; cn.cmd.Connection.Open(); cn.cmd.CommandText = "Select sum(FarmerMilkDelivery) from MilkDelivery Where DateOfDelivery='" + TotalDate + "' AND TimeofDay='"+ut.TimeOfDay()+"' AND DateOfDelivery NOT IN(SELECT Date FROM MilkCreameryDelivery WHere Date='" + TotalDate + "' AND TimeOfDay='"+ut.TimeOfDay()+"' )"; obj = cn.cmd.ExecuteScalar().ToString(); if (obj == "") { obj = "0"; notifyDelivery(); loadEdatCoop.IsEnabled = false; fillTodayDelivery(); tabC.SelectedIndex = 1; } else { totalmilk = float.Parse(obj); } } catch (Exception ex) { displayMetroError(ex); System.Diagnostics.Debugger.Log(0, "db Error", ex.Message); totalmilk = 0; } loadedmilk.Text = totalmilk.ToString(); blovkLoop = true; } }
private void Tile10_Click(object sender, RoutedEventArgs e) { apps.Utilities x = new apps.Utilities(); }
private async void AddDelivery_Click(object sender, RoutedEventArgs e) { Connection cn = new Connection(); String DeliveryID = IdGen(); float Loaded=float.Parse(loadedmilk.Text); float UnLoaded = 0; float Deficit=Loaded-UnLoaded; String Supplier =suppliercombo.SelectedItem.ToString(); String DelVehicle = Vehicle.Text; String DOD=DateTime.Now.ToShortDateString(); String driver=Driver.Text; String conductor = Conductor.Text; String StaffName=staffcombo.SelectedItem.ToString(); Utilities f = new Utilities(); try { //MessageBox.Show(cn.connectionString); cn.connect(); cn.cmd.Connection = cn.cnn; cn.cmd.Connection.Open(); cn.cmd.CommandText = "INSERT INTO MilkCreameryDelivery(DeliveryID,Date,timeofday,Litres_loaded,Litres_Unloaded,Deficit,Loader,Driver,Conductor,Vehicle,Supplier,Delivered) VALUES('" + DeliveryID + "','" + DOD + "','"+f.TimeOfDay()+"','" + Loaded + "','" + UnLoaded + "','" + Deficit + "','" + StaffName + "','" + driver + "','" + conductor + "','" + DelVehicle + "','" + Supplier + "','0')"; cn.cmd.ExecuteNonQuery(); MessageDialogResult x = new MessageDialogResult(); MetroDialogSettings y = new MetroDialogSettings(); y.AffirmativeButtonText = "Go to Delivery Tab"; y.NegativeButtonText = "Close"; x= await this.ShowMessageAsync("Delivery Added", "You have Added the Delivery Successfuly. Upon return, the Transporter("+Supplier+") Must enter milk unloaded at the creamery in the next Tab", MessageDialogStyle.AffirmativeAndNegative, y); if (x.ToString() == "Negative") { this.Close(); } else { loadEdatCoop.IsEnabled = false; fillTodayDelivery(); tabC.SelectedIndex = 1; } //farmerDatagrid.ItemsSource = LoadCollectionData(); //ViewFarmersTab.BringIntoView(); // clearRegFields(); } catch (Exception ex) { displayMetroError(ex); } }
private async void registerFarmersDelivery_Click(object sender, RoutedEventArgs e) { if (farmerNumber.Items.Count != 0) { Connection cn = new Connection(); double delivery = (double)deliveryNum.Value; delivery = System.Math.Round(delivery, 2); string deliveryhash = farmerNumber.Text.ToUpper() + DateTime.Now.ToShortDateString()+DateTime.Now.ToShortTimeString(); try { //MessageBox.Show(cn.connectionString); Utilities f=new Utilities(); cn.connect(); cn.cmd.Connection = cn.cnn; cn.cmd.Connection.Open(); cn.cmd.CommandText = "insert into MilkDelivery(FarmerHash,FarmerNo,FarmerName,FarmerMilkDelivery,DateOfDelivery,timeofdelivery,timeofday,BoughtAt,ReceivedBy) VALUES('" + deliveryhash + "','" + farmerNumber.Text + "','" + farmerName + "','" + delivery + "','" + DateTime.Now.ToShortDateString() + "','"+DateTime.Now.ToLongTimeString()+"','"+f.TimeOfDay()+"','" + buyingPrice + "','SELF')"; //MessageBox.Show( "insert into MilkDelivery(FarmerHash,FarmerNo,FarmerName,FarmerMilkDelivery,DateOfDelivery,timeofdelivery,timeofday,BoughtAt,ReceivedBy) VALUES('" + deliveryhash + "','" + farmerNumber.Text + "','" + farmerName + "','" + delivery + "','" + DateTime.Now.ToShortDateString() + "','"+DateTime.Now.ToLongTimeString()+"','"+f.TimeOfDay()+"','" + buyingPrice + "','SELF')"); cn.cmd.ExecuteNonQuery(); await this.ShowMessageAsync("Delivery Registered!", "You have entered a milk delivery of " + delivery + " kg's for " + farmerNumber.Text + " Bought at Sh" + buyingPrice + "", MessageDialogStyle.Affirmative, null); deliveryNum.Value = 0; deliveryGrid.ItemsSource = LoadCollection(); fillCombo(); } catch (Exception ex) { ShowOverlay(); MessageBox.Show(ex.Message);//"Entry Failed! Most probable cause for this is that "+farmerName+ "'s has already delivered milk today", "Entry Failure", MessageBoxButton.OK, MessageBoxImage.Error); HideOverlay(); } } else { MessageDialogResult x; MetroDialogSettings yl=new MetroDialogSettings(); yl.AffirmativeButtonText="Quit"; x=await this.ShowMessageAsync("Entry Complete!", "All Farmers with Valid Farmer Numbers have been Processed. any other processing will have to be done Manualy",MessageDialogStyle.Affirmative,yl); if (x == MessageDialogResult.Affirmative) { MessageBox.Show("t"); this.Close(); } } }
private void Tile10_Click(object sender, RoutedEventArgs e) { apps.Utilities x=new apps.Utilities(); }