private void btnConvert3_Click(object sender, EventArgs e) { StoreDataContext db = new StoreDataContext(); foreach (var item in db.QuestionT3s) { String value = item.Question52; Char delimiter = ')'; if (!String.IsNullOrEmpty(value)) { String[] substrings = value.Split(delimiter); int intLimit = 0; foreach (var substring in substrings) { if (intLimit <= 2) { SubQuestionT3 itm = new SubQuestionT3(); itm.QuestionT3ID = item.QuestionT3_ID; itm.ContentText = substring.Trim(); if (!String.IsNullOrEmpty(substring)) { db.SubQuestionT3s.InsertOnSubmit(itm); } } intLimit = intLimit + 1; } } db.SubmitChanges(); } }
public static void SetRequestProceeded(int requestId, DateTime answerDate) { using (StoreDataContext ctx = new StoreDataContext()) { var request = _getVinRequest(ctx, requestId).Single(); request.Proceeded = true; request.AnswerDate = answerDate; ctx.SubmitChanges(); } }
public void ClearItems(StoreDataContext context) { context .ShoppingCartItems .DeleteAllOnSubmit( context .ShoppingCartItems .Where(i => i.OwnerID == _ownerId && i.ClientID == _clientId)); context.SubmitChanges(); }
private int CommitChanges() { this.questionT1BS.EndEdit(); var changes = db.GetChangeSet(); if ((changes.Inserts.Count + changes.Updates.Count + changes.Deletes.Count) > 0) { ((QuestionT1)this.questionT1BS.Current).User_Name = GlobalClass.UserName; this.questionT1BS.EndEdit(); } db.SubmitChanges(); isTableChanged = true; return(1); }
private void Delete_Click(object sender, EventArgs e) { if (this.radGridView1.SelectedRows.Count > 0) { this.Cursor = Cursors.WaitCursor; this.Enabled = false; if (MessageBox.Show("Դուք համոզված էք, որ ցանկանում էք հեռացնել ընտրված գրառումները՞", "Ուշադրություն", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { foreach (var item in radGridView1.SelectedRows) { vQuestionX obj = (vQuestionX)item.DataBoundItem; var q = (from p in db.QuestionXes where p.QuestionX_ID.Equals(obj.QuestionX_ID) select p).Single(); db.QuestionXes.DeleteOnSubmit(q); } db.SubmitChanges(); this.Filter(); } this.Cursor = Cursors.Default; this.Enabled = true; } }
internal static void DeleteEntry(Guid entryUid, StoreDataContext context) { context.UserMaintEntries.DeleteOnSubmit(_getEntries(context, entryUid).Single()); context.SubmitChanges(); }
void delPhoto(ref StoreDataContext store, string a, string m, string p, string id, string nm) { // проверяем есть ли фотография на удаление if (a == "del" && m != null && p != null && id != null && nm != null) { // достаем фотографию из бд SparePartImage deleteImage = store.SparePartImages.SingleOrDefault(q => q.Manufacturer == m && q.PartNumber == p && q.SupplierID == Convert.ToInt32(id) && q.ImageNumber == Convert.ToInt32(nm)); // если фотография есть, удаляем ee if (deleteImage != null) { store.SparePartImages.DeleteOnSubmit(deleteImage); store.SubmitChanges(); string storage = id == "1212" ? "Уценка 20%" : "Уценка 50%"; LblMessage.Text = "Фотография с параметрами: Производитель=" + m + ", Артикул=" + p + ", Склад уценки=" + storage + ", Номер фотографии=" + nm + " - удалена."; LblMessage.Visible = true; } } }
public void SaveItems( StoreDataContext context, IEnumerable<ShoppingCartItem> items ) { //using (var context = new StoreDataContext()) //{ foreach ( var item in items ) { // deas 28.02.2011 task2401 // изменено сравнение на ItemID для хранения нескольких строк с разными ReferenceID var existing = context.ShoppingCartItems.SingleOrDefault( i => i.ItemID == item.ItemID ); //i.OwnerID == _ownerId && //i.ClientID == _clientId && //i.Manufacturer == item.Manufacturer && //i.PartNumber == item.PartNumber && //i.SupplierID == item.SupplierID ); if ( existing != null ) { if ( item.Qty == 0 ) context.ShoppingCartItems.DeleteOnSubmit( existing ); else { existing.UnitPrice = item.UnitPrice; existing.Qty = item.Qty; existing.ReferenceID = item.ReferenceID; existing.VinCheckupDataID = item.VinCheckupDataID; existing.StrictlyThisNumber = item.StrictlyThisNumber; existing.ItemNotes = item.ItemNotes; } } else { // deas 28.04.2011 task3929 добавление в корзине флага отправить в заказ context.ShoppingCartItems.InsertOnSubmit( new ShoppingCartItem { ClientID = _clientId, OwnerID = _ownerId, Manufacturer = item.Manufacturer, PartNumber = item.PartNumber, SupplierID = item.SupplierID, DeliveryDaysMin = item.DeliveryDaysMin, DeliveryDaysMax = item.DeliveryDaysMax, PartName = item.PartName, PartDescription = item.PartDescription, StrictlyThisNumber = item.StrictlyThisNumber, Qty = item.Qty, ReferenceID = item.ReferenceID, UnitPrice = item.UnitPrice, AddToOrder = item.AddToOrder, UnitPriceYesterday = item.UnitPriceYesterday } ); } } context.SubmitChanges(); //} }
public static void UpdateVinRequestItem(VinRequestItem item) { using (StoreDataContext ctx = new StoreDataContext()) { var old = _getRequestItem(ctx, item.Id).Single(); old.Name = item.Name; old.ManagerComment = item.ManagerComment; old.Manufacturer = item.Manufacturer; old.PartNumber = item.PartNumber; old.PartNumberOriginal = item.PartNumberOriginal; old.DeliveryDays = item.DeliveryDays; old.PricePerUnit = item.PricePerUnit; old.Quantity = item.Quantity; ctx.SubmitChanges(); } }
internal static void AddUser( User user, StoreDataContext context ) { context.Users.InsertOnSubmit( user ); //создать запись для сервиса отправки оповещений if( user.Role == SecurityRole.Client ) { var alert = context.ClientAlertInfos.SingleOrDefault( a => a.ClientID == user.AcctgID ); if( alert == null ) context.ClientAlertInfos.InsertOnSubmit( new ClientAlertInfo { ClientID = user.AcctgID, OrderTrackingLastAlertDate = DateTime.Now } ); else alert.OrderTrackingLastAlertDate = DateTime.Now; } context.SubmitChanges(); }
internal static void UpdatePassword( int userId, string password, StoreDataContext context ) { context.Users .Single( u => u.UserID == userId ) .Password = password; context.SubmitChanges(); }