Esempio n. 1
0
        public void SavePartMethod()
        {
            if (string.IsNullOrEmpty(this.partDateModel.Name))
            {
                MessageBox.Show("Part name can not be empty.");
                return;
            }
            if (string.IsNullOrEmpty(this.partDateModel.Desc1))
            {
                MessageBox.Show("Number field is required.");
                return;
            }
            int myNumber;

            if (!Int32.TryParse(this.partDateModel.Desc1, out myNumber))
            {
                MessageBox.Show("It Should contain numbers only");
                return;
            }

            MainDatabaseSourceDataContext dbContext = new MainDatabaseSourceDataContext();
            myPart part = new myPart();

            part.Name  = this.partDateModel.Name;
            part.Desc1 = Int32.Parse(this.partDateModel.Desc1);
            part.Desc2 = this.partDateModel.Desc2.Date;
            part.Desc3 = this.partDateModel.Desc3;
            part.desc4 = this.partDateModel.Desc4;
            dbContext.myParts.InsertOnSubmit(part);
            dbContext.SubmitChanges();

            MessageBox.Show("Saved Successfuly !");
            //---- Clear the object details after saving -----
            ClearObjectDetails();
        }
Esempio n. 2
0
        public void SaveInstall()
        {
            if (!CheckCarAvailability())
            {
                MessageBox.Show("Car name not found.");
                return;
            }

            if (myPartsList.Count == 0)
            {
                MessageBox.Show("Please add at least one part");
                return;
            }

            MainDatabaseSourceDataContext dbContext = new MainDatabaseSourceDataContext();
            int     myId    = GetMaxInstallId() + 1;
            Install install = new Install();

            install.ID                = myId;
            install.Car_ID            = GetCarIdByName(this.MyInstallModel.CarName);
            install.other_desc_fields = this.MyInstallModel.InstallDisc;
            dbContext.Installs.InsertOnSubmit(install);

            int instapPartID = GetMaxInstallPartId();

            foreach (var item in myPartsList)
            {
                Install_Detail install_Detail = new Install_Detail();

                install_Detail.ID = instapPartID + 1;

                instapPartID += 1;

                install_Detail.Part_ID = item.PartId;

                install_Detail.Other_desc_fields = item.Disc;

                install_Detail.Install_ID = myId;

                install.Install_Details.Add(install_Detail);

                dbContext.Install_Details.InsertOnSubmit(install_Detail);
            }
            dbContext.SubmitChanges();
            //--------------Confirmation message ------------------
            MessageBox.Show("saved successfuly");
            myPartsList.Clear();
            this.installPartModelw.PartName = "";
            this.installPartModelw.PartDesc = "";
            this.MyInstallModel.CarName     = "";
            this.MyInstallModel.InstallDisc = "";
            this.searchModel.MyPartsToDisp  = myPartsList;
        }
Esempio n. 3
0
        ///=======================================================
        ///

        public void SaveCarMethod()
        {
            MainDatabaseSourceDataContext dbContext = new MainDatabaseSourceDataContext();
            myCar car = new myCar();

            car.Name  = this.dataModel.myName;
            car.Desc1 = Int32.Parse(this.dataModel.myDesc1);
            car.Desc2 = this.dataModel.myDesc2.Date;
            car.Desc3 = this.dataModel.myDesc3;
            car.Desc4 = this.dataModel.myDesc4;
            dbContext.myCars.InsertOnSubmit(car);
            dbContext.SubmitChanges();
            MessageBox.Show("Saved Successfuly !");
            //---- Clear the object details after saving -----
            ClearObjectDetails();
        }
Esempio n. 4
0
        public void SaveMethod()
        {
            MainDatabaseSourceDataContext dbContext = new MainDatabaseSourceDataContext();

            MyConstantInfo myConstantInfo = new MyConstantInfo();

            /*string ImageStringName = SelectImageToBeSaved();
             * if (!string.IsNullOrEmpty(ImageStringName))
             * {
             *  this.constInfoModel.MyImage = File.ReadAllBytes(ImageStringName);
             *  //using UploadImage stored procedure
             *  dbContext.UploadImage(this.constInfoModel.MyImage);
             * }
             */
            // --- to be able to update
            myConstantInfo = dbContext.MyConstantInfos.Single(p => p.ID == 1);

            myConstantInfo.MYINFO = this.constInfoModel.InfoString;
            myConstantInfo.more   = this.constInfoModel.MoreInfoe;
            myConstantInfo.myDate = this.constInfoModel.InfoDate;
            dbContext.SubmitChanges();
            MessageBox.Show("Informations has been saved.");
        }