Пример #1
0
        private void OnMouseUp()
        {
            resizeDir = 0;
            mouseDown = false;
            if (currentlySelected is null)
            {
                return;
            }

            Panel parent = (Panel)currentlySelected.Parent;

            if (parent == grd)
            {
                parent.Children.Remove(currentlySelected);
                if (currentlySelected.Tag is string id)
                {
                    MiscRequests.DeleteItem("Shift", "Shift ID", id);
                }
                currentlySelected = null;
                return;
            }

            bool isNew = false;

            // If this is a new shift
            if (currentlySelected.Tag is string sTag && sTag == "")
            {
                string id = MiscRequests.GetMinKeyNotUsed("Shift", "Shift ID");
                currentlySelected.Tag = id;
                isNew = true;
            }

            string[] data = GetDataFromShift(currentlySelected);
            DBAccess.UpdateTable("Shift", shiftColumns.Select(c => c.Name).ToArray(), data, isNew);

            currentlySelected.IsHitTestVisible = true;
            currentlySelected.Children.OfType <Rectangle>().Where(r => r.Name == "rctBase").First().IsHitTestVisible = true;
        }
Пример #2
0
        private async void BtnConfirmNewEx_Click(object sender, RoutedEventArgs e)
        {
            Button   btnConfirmNewEx = (Button)sender;
            ComboBox cbxNewExStaff   = stpNewExc.Children.OfType <ComboBox>().First();

            ValidatedDatePicker[] dates = stpNewExc.Children.OfType <ValidatedDatePicker>().ToArray();

            if (dates[0].IsValid && dates[1].IsValid && dates[0].SelectedDate <= dates[1].SelectedDate)
            {
                btnConfirmNewEx.Content = " Submitted! ";
                string[] newData = new string[4];
                newData[0] = MiscRequests.GetMinKeyNotUsed("Shift Exception", "Shift Exception ID");
                newData[1] = cbxNewExStaff.SelectedIndex.ToString();
                newData[2] = dates[0].SelectedDate.ToString("dd-MM-yyyy");
                newData[3] = dates[1].SelectedDate.ToString("dd-MM-yyyy");

                DBAccess.UpdateTable("Shift Exception", shiftExcColumns.Select(c => c.Name).ToArray(), newData, true);

                UpdateShiftExcs();
                await Task.Delay(2000);

                btnConfirmNewEx.Content = " Submit ";
            }
        }