コード例 #1
0
 private void buttonRepoSave_Click(object sender, EventArgs e)
 {
     if (CheckValues())
     {
         KindaRepository model = InitializeModel();
         addModel.InsertNewValue(model);
     }
 }
コード例 #2
0
        public void InsertNewValue(KindaRepository newObject)
        {
            try
            {
                swApp    = (SldWorks)Marshal.GetActiveObject("SldWorks.Application");
                modelDoc = swApp?.ActiveDoc;
                if (modelDoc != null)
                {
                    using (dataContest = new SQLRepositoryDataContext(ConfigurationSettings.SQLConnection1))
                    {
                        if (dataContest != null)
                        {
                            if (!dataContest.KindaRepositories.Any(x => x.Size1.Equals(newObject.Size1) && x.Size2.Equals(newObject.Size2) && x.Size3.Equals(newObject.Size3) &&
                                                                   x.DimVal1.Equals(newObject.DimVal1) && x.DimVal2.Equals(newObject.DimVal2) && x.DimVal3.Equals(newObject.DimVal3)))
                            {
                                dataContest.KindaRepositories.InsertOnSubmit(newObject);

                                dataContest.SubmitChanges(System.Data.Linq.ConflictMode.FailOnFirstConflict);
                                dataContest.Refresh(System.Data.Linq.RefreshMode.KeepChanges);
                                System.Windows.Forms.MessageBox.Show("Сохранено!");
                            }
                            else
                            {
                                System.Windows.Forms.MessageBox.Show("Такая деталь уже есть в базе данных!");
                            }
                        }
                        else
                        {
                            System.Windows.Forms.MessageBox.Show("Не удалось установить подключение к базе даных. Проверте строку подключения и настройки сети!");
                        }
                    }
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Нету открытых документов. Откройте документ для сохранения.");
                }
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }
コード例 #3
0
        private KindaRepository InitializeModel()
        {
            SizeM point3dSize = SomeHelpful.OrderSize(height, width, lenght);


            model       = new KindaRepository();
            model.Size1 = point3dSize.P1;
            model.Size2 = point3dSize.P2;
            model.Size3 = point3dSize.P3;

            SizeM diamOfVals = SomeHelpful.OrderSize(dimVal1, dimVal2, dimVal3);

            model.DimVal1 = diamOfVals.P1;
            model.DimVal2 = diamOfVals.P2;
            model.DimVal3 = diamOfVals.P3;


            model.Path  = addModel.GetPath();
            model.Model = addModel.ModelBytes(model.Path);

            return(model);
        }
コード例 #4
0
 partial void DeleteKindaRepository(KindaRepository instance);
コード例 #5
0
 partial void UpdateKindaRepository(KindaRepository instance);
コード例 #6
0
 partial void InsertKindaRepository(KindaRepository instance);