コード例 #1
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            bool isReady = false;
            var  message = "Please Enter:";

            if (newInquiryData.CustomerId == 0)
            {
                message += $"\n  Customer Name."; isReady = true;
            }
            if (newInquiryData.ProjectName == null || newInquiryData.ProjectName == "")
            {
                message += $"\n  Project Name."; isReady = true;
            }

            if (!isReady)
            {
                using (SqlConnection connection = new SqlConnection(Database.ConnectionString))
                {
                    connection.Update <Inquiry>(newInquiryData);
                }

                if (WindowMode == Actions.New)
                {
                    if (InquiriesDataToUpdate != null)
                    {
                        InquiriesDataToUpdate.Insert(0, newInquiryData);
                    }
                }
                else if (WindowMode == Actions.Edit)
                {
                    InquiryData.Update(newInquiryData);
                }

                isSaving = true;
                this.Close();
            }
            else
            {
                MessageWindow.Show("Error", message, MessageWindowButton.OK, MessageWindowImage.Information);
            }
        }