Esempio n. 1
0
        private void Information_Click(object sender, RoutedEventArgs e)
        {
            var quotationWindow = new QuotationWindow()
            {
                UserData      = this.UserData,
                QuotationData = QuotationData,
            };

            quotationWindow.ShowDialog();
        }
Esempio n. 2
0
        private void Quote_Click(object sender, RoutedEventArgs e)
        {
            if (InquiriesList.SelectedItem is Inquiry inquiryData)
            {
                User      usedBy;
                Quotation quotationData = new Quotation()
                {
                    InquiryId = inquiryData.Id, Inquiry = inquiryData
                };

                using (SqlConnection connection = new SqlConnection(Database.ConnectionString))
                {
                    usedBy = connection.AccessValidation(nameof(quotationData.InquiryId), inquiryData.Id);

                    if (usedBy == null)
                    {
                        string query = $"Select MAX(Number) as Number From [Quotation].[_Qoutations] Where Year = {DateTime.Now.Year}";
                        quotationData.Number = connection.QueryFirstOrDefault <Quotation>(query).Number + 1;
                        quotationData.Year   = DateTime.Now.Year;
                        quotationData.Month  = DateTime.Now.Month;
                        quotationData.Code   =
                            $"ER-{quotationData.Number:000}/{UserData.UserCode}/{quotationData.Month}/{quotationData.Year}/R00";
                        quotationData.ReviseDate = DateTime.Now;

                        quotationData.Id = Convert.ToInt32(connection.Insert <Quotation>(quotationData));
                        Term.GetDefaultTerms(connection, quotationData.Id);

                        UserData.InquiryId = inquiryData.Id;
                        connection.UserAccessUpdate(UserData, nameof(UserData.InquiryId));

                        UserData.QuotationId = quotationData.Id;
                        connection.UserAccessUpdate(UserData, nameof(UserData.QuotationId));
                    }
                }

                if (usedBy == null)
                {
                    var quotationWindow = new QuotationWindow()
                    {
                        UserData         = this.UserData,
                        OpenPanelsWindow = true,
                        QuotationData    = quotationData
                    };
                    this.Close();
                    quotationWindow.ShowDialog();
                }
                else
                {
                    MessageWindow.Show($"Access", $"This inquiry underwork by {usedBy.Name}!", MessageWindowButton.OK, MessageWindowImage.Warning);
                }
            }
        }