Пример #1
0
        private void New_Click(object sender, RoutedEventArgs e)
        {
            InquiryWindow inquiryWindow = new InquiryWindow()
            {
                InquiryData = new Inquiry()
                {
                    Status = Statuses.New.ToString()
                },
                UserData              = this.UserData,
                WindowMode            = Actions.New,
                InquiriesDataToUpdate = inquiriesData,
            };

            inquiryWindow.ShowDialog();
        }
Пример #2
0
        private void Edit_ClicK(object sender, RoutedEventArgs e)
        {
            if (InquiriesList.SelectedItem is Inquiry inquiry)
            {
                User      usedBy;
                Quotation quotation;
                using (SqlConnection connection = new SqlConnection(Database.ConnectionString))
                {
                    usedBy    = connection.AccessValidation(nameof(UserData.InquiryId), inquiry.Id);
                    quotation = connection.QueryFirstOrDefault <Quotation>($"Select * From [Quotation].[_Quotations] Where InquiryId = {inquiry.Id}");

                    if (usedBy == null)
                    {
                        UserData.InquiryId = inquiry.Id;
                        connection.UserAccessUpdate(UserData, nameof(UserData.InquiryId));
                    }
                }

                if (quotation != null)
                {
                    if (quotation.Status != Statuses.Running.ToString())
                    {
                        MessageWindow.Show($"Access", $"Can't edit this Inquiry!", MessageWindowButton.OK, MessageWindowImage.Warning);
                        return;
                    }
                }

                if (usedBy == null || usedBy.Id == UserData.Id)
                {
                    var inquiryWindow = new InquiryWindow()
                    {
                        UserData    = this.UserData,
                        WindowMode  = Actions.Edit,
                        InquiryData = inquiry,
                    };
                    inquiryWindow.ShowDialog();
                }
                else
                {
                    MessageWindow.Show($"Access", $"This inquiry underwork by {usedBy.Name}!", MessageWindowButton.OK, MessageWindowImage.Warning);
                }
            }
        }