当前位置: 首页>>代码示例>>C#>>正文


C# DataClasses1DataContext.SubmitChanges方法代码示例

本文整理汇总了C#中DataClasses1DataContext.SubmitChanges方法的典型用法代码示例。如果您正苦于以下问题:C# DataClasses1DataContext.SubmitChanges方法的具体用法?C# DataClasses1DataContext.SubmitChanges怎么用?C# DataClasses1DataContext.SubmitChanges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataClasses1DataContext的用法示例。


在下文中一共展示了DataClasses1DataContext.SubmitChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: update

 // Update Account <acc> in database
 public static bool update(Account acc)
 {
     using (DataClasses1DataContext database = new DataClasses1DataContext(Globals.connectionString))
     {
         var query = from a in database.Accounts
                     // Assuming the accountNumber is enough of an identifier.
                     // Additional 'where' clauses can be added if necessary.
                     where (a.AccountID == acc.AccountID)
                     select a;
         // It seems to me that a single account renders the foreach unnecessary. However, I can't
         // find another way to get the variable 'a' from 'query'.
         foreach (var a in query)
         {
             a.AccountAddress = acc.AccountAddress;
             a.AccountFirstName = acc.AccountFirstName;
             a.AccountLastName = acc.AccountLastName;
             a.AccountNum = acc.AccountNum;
             a.AccountPhoneNum = acc.AccountPhoneNum;
             a.AccountRoutingNum = acc.AccountRoutingNum;
             a.BankID = acc.BankID;
         }
         try
         {
             database.SubmitChanges();
             return true;
         }
         catch (Exception e)
         {
             return false;
         }
     }
 }
开发者ID:captaintino,项目名称:Bounced-Check-Manager,代码行数:33,代码来源:AccountDAO.cs

示例2: update

 // Update Store <store>
 public static bool update(Store store)
 {
     using (DataClasses1DataContext database = new DataClasses1DataContext(Globals.connectionString))
     {
         var query = from a in database.Stores
                     where (a.StoreID == store.StoreID)
                     select a;
         foreach (var a in query)
         {
             a.StoreNum = store.StoreNum;
             a.StoreName = store.StoreName;
             a.StoreAddress = store.StoreAddress;
             a.StoreServiceCharge = store.StoreServiceCharge;
         }
         try
         {
             database.SubmitChanges();
             return true;
         }
         catch (Exception e)
         {
             return false;
         }
     }
 }
开发者ID:captaintino,项目名称:Bounced-Check-Manager,代码行数:26,代码来源:StoreDAO.cs

示例3: update

 // Update Check <check>
 public static bool update(Check check)
 {
     using (DataClasses1DataContext database = new DataClasses1DataContext(Globals.connectionString))
     {
         var query = from a in database.Checks
                     where (a.CheckID == check.CheckID)
                     select a;
         foreach (var a in query)
         {
             a.CheckAmount = check.CheckAmount;
             a.CheckAmountOwed = check.CheckAmountOwed;
             a.CheckCashierID = check.CheckCashierID;
             a.CheckDate = check.CheckDate;
             a.CheckDeleted = check.CheckDeleted;
             a.CheckNum = check.CheckNum;
             a.CheckPaidDate = check.CheckPaidDate;
         }
         try
         {
             database.SubmitChanges();
             return true;
         }
         catch (Exception e)
         {
             return false;
         }
     }
 }
开发者ID:captaintino,项目名称:Bounced-Check-Manager,代码行数:29,代码来源:CheckDAO.cs

示例4: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if(!String.IsNullOrWhiteSpace(textBox1.Text) &&
                    !String.IsNullOrWhiteSpace(textBox2.Text) &&
                    !String.IsNullOrWhiteSpace(textBox3.Text))
                {
                    DataClasses1DataContext doctorContext= new DataClasses1DataContext();
                    Doctor doctor = new Doctor();
                    doctor.doctorName = textBox1.Text;
                    doctor.doctorID = textBox2.Text;
                    doctor.gloveSize = Decimal.Parse(textBox3.Text);
                    doctorContext.Doctors.InsertOnSubmit(doctor);

                    doctorContext.SubmitChanges();
                    textBox1.Text = "";
                    textBox2.Text = "";
                    textBox3.Text = "";
                    Form1.GetDoctors();
                    loadDoctors();
                }
                else
                {
                    MessageBox.Show("Cannot be empty...", "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

            }
            catch
            {
                MessageBox.Show("Something went wrong, does the doctor already exist? Please try again...", "Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
开发者ID:TrustLRon,项目名称:DoctorProcedures,代码行数:35,代码来源:NewDoctor.cs

示例5: advanceUserInStudy

        //public bool advanceUserInStudy(DataClasses1DataContext database, int SID, int UID)
        public bool advanceUserInStudy(int SID, int UID)
        {
            DataClasses1DataContext database = new DataClasses1DataContext();
            StudiesUser u = (from user in database.StudiesUsers
                             where user.StudyID == SID && user.UserID == UID
                             select user).Single();
            //database.Refresh(refresh_mode, new Object[] {u, database.WordSublists, database.TrialTypes});
            StudyUserGroup g = u.StudyUserGroup;
            //database.Refresh(refresh_mode, g);

            var subkeys = (from s in database.WordSublists
                           select s.ID);
            var typekeys = (from s in database.TrialTypes
                            select s.ID);

            int firstSublist = subkeys.Min();
            int lastSublist = subkeys.Max();
            int firstType = typekeys.Min();
            int lastType = typekeys.Max();

            if ((u.WordSublistID < lastSublist) && u.Mix)
            {
                u.WordSublistID++;
                u.Mix = false;
            }
            else if (!u.Mix)
            {
                if (u.WordSublistID == firstSublist) //nothing to mix at the beginning
                {
                    u.WordSublistID++;
                }
                else
                {
                    u.Mix = true;
                }
            }
            else if (u.TrialTypeID < lastType)
            {
                u.WordSublistID = firstSublist;
                u.TrialTypeID++;
                u.Mix = false;
            }
            else if (u.WordListID == g.FirstListID)
            {
                u.WordListID = g.SecondListID;
                u.WordSublistID = firstSublist;
                u.TrialTypeID = firstType;
            }
            else
            {
                u.Complete = true;
            }
            database.SubmitChanges();
            return u.Complete;
        }
开发者ID:spencer-langley,项目名称:AlohaKumu,代码行数:56,代码来源:DataAccessor.cs

示例6: Index

        public ActionResult Index(_Habitacion a)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            var id = db.habitacions.Where(b => b.numero == a.numero).First();
            id.disponibilidad = a.disponibilidad;
            id.precio = a.precio;
            id.tipo = a.tipo;
            db.SubmitChanges();

            ViewBag.gg = -1;
            ViewBag.t = new SelectListItem[] { new SelectListItem { Selected = true, Text = "0", Value = "0" } };

            return View();
        }
开发者ID:javzingsist,项目名称:HotelManagement,代码行数:14,代码来源:modificarController.cs

示例7: InsertZast

 public static bool InsertZast(ZAST z)
 {
     DataClasses1DataContext dc = new DataClasses1DataContext();
     try
     {
         dc.AddNewZast(z.FName, z.LName, z.CarNum, z.CarBrand, z.CarModel, (Int16)z.CarType, z.CarAddinfo, (Int16)z.ExpireDateDay, (Int16)z.ExpireDateMonth, (int)z.ExpireDateYear, (int)z.employee, z.Price, (Int16)z.City);
         dc.SubmitChanges();
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }
开发者ID:pow2,项目名称:TU-Sofia,代码行数:14,代码来源:ZastValidation.cs

示例8: Index

        public ActionResult Index(StructUser u)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            var id = db.Users.Where(b => b.UserId == u.id).First();
            id.UserName = u.nombre;
            id.Membership.Email = u.email;
            //            id.cliente.nit = u.nit;
            db.SubmitChanges();

            ViewBag.gg = Guid.Parse("00000000-0000-0000-0000-000000000000");
            ViewBag.t = new SelectListItem[] { new SelectListItem { Selected = true, Text = "0", Value = "0" } };

            return View();
        }
开发者ID:nishantd01,项目名称:HotelManagement,代码行数:14,代码来源:modificarUsuarioController.cs

示例9: create

 // Create Check <check>
 public static bool create(Check check)
 {
     using (DataClasses1DataContext database = new DataClasses1DataContext(Globals.connectionString))
     {
         database.Checks.InsertOnSubmit(check);
         try
         {
             database.SubmitChanges();
             return true;
         }
         catch (Exception e)
         {
             return false;
         }
     }
 }
开发者ID:captaintino,项目名称:Bounced-Check-Manager,代码行数:17,代码来源:CheckDAO.cs

示例10: submitEditDoctorButton_Click

        private void submitEditDoctorButton_Click(object sender, EventArgs e)
        {
            try
            {
                DoctorProcedureClassDataContext editDocSetupContext = new DoctorProcedureClassDataContext();
                DataClasses1DataContext editDocContext = new DataClasses1DataContext();

                var doctorSetups = (from setups in editDocSetupContext.DoctorsProcedures
                                    where setups.doctorName == oldDoctorName.Text
                                    select setups);

                var doctor = (from docs in editDocContext.Doctors
                              where docs.doctorName == oldDoctorName.Text
                              select docs).First();

                if (!String.IsNullOrWhiteSpace(newDoctorName.Text) &&
                    !String.IsNullOrWhiteSpace(newInitials.Text) &&
                    !String.IsNullOrWhiteSpace(newGloves.Text))
                {
                    foreach (DoctorsProcedure setup in doctorSetups)
                    {
                        setup.doctorName = newDoctorName.Text;
                        setup.gloveSize = Decimal.Parse(newGloves.Text);
                    }

                    doctor.doctorName = newDoctorName.Text;
                    doctor.gloveSize = Decimal.Parse(newGloves.Text);

                    editDocSetupContext.SubmitChanges();
                    editDocContext.SubmitChanges();
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;

                    MessageBox.Show("Updated", "Setup",
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Please fill out all data", "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch
            {
                MessageBox.Show("Something went wrong, try again", "Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
开发者ID:TrustLRon,项目名称:DoctorProcedures,代码行数:47,代码来源:DoctorEdit.cs

示例11: Create_Click

        protected void Create_Click(object sender, EventArgs e)
        {
            using (var db = new DataClasses1DataContext())
            {

                ShippingRestriction rest = new ShippingRestriction();
                rest.Code = Code.Text;
                rest.Caption = Caption.Text;
                rest.Comment = Comment.Text;
                rest.CityFilterMode = Convert.ToInt32(CityFilterMode.SelectedValue);
                rest.ProductFilterMode = Convert.ToInt32(ProductFilterMode.SelectedValue);
                rest.PrefName = PrefName.Text;
                DateTime dt;
                if (DateTime.TryParse(BeginDate.Text, out dt))
                {
                    rest.BeginDate = dt;
                }
                if (DateTime.TryParse(EndDate.Text, out dt))
                {
                    rest.EndDate = dt;
                }

                var products = new List<ShippingRestrictedProduct>();
                foreach (var item in Products.Text.Split(new char[] { ' ', '\t', ',', '、' }).Select(x => x.Trim()))
                {
                    products.Add(new ShippingRestrictedProduct() { ProductName = item, ShippingRestrictionCode = rest.Code });
                }

                var cities = new List<ShippingRestrictedCity>();
                foreach (var item in Cities.Text.Split(new char[] { ' ', '\t', ',', '、' }).Select(x => x.Trim()))
                {
                    cities.Add(new ShippingRestrictedCity() { CityName = item, ShippingRestrictionCode = rest.Code });
                }

                db.ShippingRestriction.InsertOnSubmit(rest);
                db.ShippingRestrictedProduct.InsertAllOnSubmit(products);
                db.ShippingRestrictedCity.InsertAllOnSubmit(cities);

                db.SubmitChanges();

                ClientScript.RegisterStartupScript(typeof(String), "msg", "alert('追加しました。')", true);
            }
        }
开发者ID:udawtr,项目名称:yasaikensa,代码行数:43,代码来源:srnew.aspx.cs

示例12: markAsVoid

 public static bool markAsVoid(Check check)
 {
     using (DataClasses1DataContext database = new DataClasses1DataContext(Globals.connectionString))
     {
         var query = from a in database.Checks
                     where (a.CheckID == check.CheckID)
                     select a;
         foreach (var a in query)
         {
             a.CheckDeleted = true;
         }
         try
         {
             database.SubmitChanges();
             return true;
         }
         catch (Exception e)
         {
             return false;
         }
     }
 }
开发者ID:captaintino,项目名称:Bounced-Check-Manager,代码行数:22,代码来源:CheckDAO.cs

示例13: SaveCoordinates

        public void SaveCoordinates(String modelPath, String imageStorage)
        {
            // loads from disk, saves to DB.
            var db = new DataClasses1DataContext(_connectionString);
            var aModel = db.TrainingRuns.Where(x => x.Name.Equals(_modelName)).Single();

            _dimensions = CAPI.TrainModel(modelPath + _modelName, true, -1, aModel.Rows, aModel.Cols, (int)CAPI.ImageMode.Undefined, (int)_modelType);
            if (aModel.Dimensions != _dimensions) throw new ApplicationException("Number of dimensions in db dont match number of dimensions in model flat file.");

            var faceCoords = new Dictionary<int, List<double>>();
            double[] coords = new double[_dimensions];
            System.Diagnostics.Debug.WriteLine("Start saving coords");
            var ic = new ImageCache(imageStorage);      // non S3 version
            foreach (String file in Directory.GetFiles(imageStorage, "*.jpg"))
            {
                CAPI.GetCoordinates(file, coords, aModel.Rows, aModel.Cols, (int) CAPI.ImageMode.Histogram);
                int ukey = int.Parse(Path.GetFileNameWithoutExtension(file));

                // store the greyscale for later upload to S3 and display in the carousel
                String histFacePath = ic.GetNormFacePath(ukey, aModel.Rows*2, aModel.Cols*2);     // TODO: maybe we can store larger versions?

                for (int i = 0; i < _dimensions; i++)
                {
                    db.Coordinates.InsertOnSubmit(new Coordinate()
                    {
                        TrainingRunID = aModel.TrainingRunID,
                        Dimension = i,
                        FaceUKey = ukey,
                        Coordinate1 = coords[i]
                    });
                }
                db.SubmitChanges();
                System.Diagnostics.Debug.WriteLine("Storing " + ukey);
            }
            System.Diagnostics.Debug.WriteLine("Done saving coords");

        }
开发者ID:rwoodley,项目名称:FaceToys,代码行数:37,代码来源:FacesLite.cs

示例14: update

 // Update Bank <bank>
 public static bool update(Bank bank)
 {
     using (DataClasses1DataContext database = new DataClasses1DataContext(Globals.connectionString))
     {
         var query = from a in database.Banks
                     where (a.BankID == bank.BankID)
                     select a;
         foreach (var a in query)
         {
             a.BankRoutingNum = bank.BankRoutingNum;
             a.BankName = bank.BankName;
             a.BankAddress = bank.BankAddress;
         }
         try
         {
             database.SubmitChanges();
             return true;
         }
         catch (Exception e)
         {
             return false;
         }
     }
 }
开发者ID:captaintino,项目名称:Bounced-Check-Manager,代码行数:25,代码来源:BankDAO.cs

示例15: recordTrialBlock

 public bool recordTrialBlock(TrialBlockData results)
 {
     DataClasses1DataContext database = new DataClasses1DataContext();
     StudiesUser x = (from su in database.StudiesUsers
                      where su.StudyID == results.studyID && su.UserID == results.userID
                      select su).Single();
     TrialBlock newBlock = new TrialBlock();
     newBlock.StudyID = results.studyID;
     newBlock.StartTime = results.taken;
     newBlock.UserID = results.userID;
     newBlock.TrialTypeID = results.typeID;
     newBlock.WordListID = x.WordListID;
     newBlock.WordSublistID = x.WordSublistID;
     database.TrialBlocks.InsertOnSubmit(newBlock);
     database.SubmitChanges();
     int trialcount = results.clickID1s.Length;
     for (int i = 0; i < trialcount; i++)
     {
         Trial newTrial = new Trial();
         newTrial.TrialBlockID = newBlock.ID;
         newTrial.WordID = results.words[i];
         newTrial.TimeFirstIDpresented = results.showID1s[i];
         newTrial.TimeFirstIDclicked = results.clickID1s[i];
         newTrial.TimeSecondIDpresented = results.showID2s[i];
         newTrial.TimeSecondIDclicked = results.clickID2s[i];
         newTrial.TimeOptionsPresented = results.optionsShown[i];
         newTrial.Option1ID = results.optionIDs[i][0];
         newTrial.Option2ID = results.optionIDs[i][1];
         newTrial.Option3ID = results.optionIDs[i][2];
         newTrial.TimeOptionClicked = results.clickOptionTimes[i];
         newTrial.OptionIDClicked = results.optionIDsClicked[i];
         database.Trials.InsertOnSubmit(newTrial);
         database.SubmitChanges();
     }
     return evalPerformance(database, newBlock.ID, newBlock.Study.TargetWordsPerMinute, results.studyID, results.userID);
 }
开发者ID:spencer-langley,项目名称:AlohaKumu,代码行数:36,代码来源:DataAccessor.cs


注:本文中的DataClasses1DataContext.SubmitChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。