//-----End of coding line #region Founctions //----- #region FormLoad private void FormLoad() { Models.DataBaseContext dataBaseContext = null; try { dataBaseContext = new Models.DataBaseContext(); Models.Hookah hookah = dataBaseContext.Hookahs .Where(current => string.Compare(current.HookahName, HookahName_FirstLoad, true) == 0) .FirstOrDefault(); HookahName = null; HookahName_New = null; hookahNameTextBox.Text = hookah.HookahName; HookahPrice = null; HookahName_New = null; HookahPrice_Int = 0; hookahPriceTextBox.Text = hookah.HookahPrice; HookahPrice_FirstLoad = hookah.HookahPrice; hookahPriceTextBox.ForeColor = Infrastructure.Utility.DimGrayColor(); hookahPricePanel.BackColor = Infrastructure.Utility.DimGrayColor(); HookahDescription = null; HookahDescription_New = null; hookahDescriptionTextBox.Text = hookah.HookahDescription; HookahDescription_FirstLoad = hookah.HookahDescription; hookahDescriptionTextBox.ForeColor = Infrastructure.Utility.DimGrayColor(); hookahDescriptionPanel.BackColor = Infrastructure.Utility.DimGrayColor(); HookahImage = null; HookahImage_New = null; Select_HookahImage = null; HookahImage_FirstLoad = hookah.HookahImage; var byteImage = hookah.HookahImage; using (System.IO.MemoryStream ms = new System.IO.MemoryStream(byteImage)) { hookahImagePicturBox.Image = System.Drawing.Image.FromStream(ms); } } catch (System.Exception ex) { Infrastructure.Utility.ExceptionShow(ex); } finally { if (dataBaseContext != null) { dataBaseContext.Dispose(); dataBaseContext = null; } } }
private void DeleteRecordButton_Click(object sender, System.EventArgs e) { if (hookahStoreDataGridView.Rows.Count >= 1) { System.Windows.Forms.DialogResult dialogResult = Mbb.Windows.Forms.MessageBox.Show (text: $"{hookahStoreDataGridView.CurrentRow.Cells[0].Value} حذف گردد؟!", caption: "هشدار", icon: Mbb.Windows.Forms.MessageBoxIcon.Warning, button: Mbb.Windows.Forms.MessageBoxButtons.YesNo); if (dialogResult == System.Windows.Forms.DialogResult.Yes) //----جهت حذف مشترک { string hookahName = hookahStoreDataGridView.CurrentRow.Cells[0].Value.ToString(); using (Models.DataBaseContext dataBaseContext = new Models.DataBaseContext()) { Models.Hookah hookah = dataBaseContext.Hookahs .Where(current => string.Compare(current.HookahName, hookahName) == 0) .FirstOrDefault(); if (hookah != null) { var entry = dataBaseContext.Entry(hookah); if (entry.State == EntityState.Detached) { dataBaseContext.Hookahs.Attach(hookah); } } #region EventLog Username = Program.AuthenticatedUser.Username; FullName = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}"; EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; EventTime = $"{Infrastructure.Utility.ShowTime()}"; EventTitle = $"{hookahName} حذف گردید."; Infrastructure.Utility.EventLog(username: Username, fullName: FullName, eventDate: EventDate, eventTime: EventTime, eventTitle: EventTitle); #endregion /EventLog dataBaseContext.Hookahs.Remove(hookah); dataBaseContext.SaveChanges(); HookahLoader(); } Infrastructure.Utility.WindowsNotification (message: "کد مورد نظر حذف گردید!", caption: Infrastructure.PopupNotificationForm.Caption.موفقیت); } } else { Mbb.Windows.Forms.MessageBox.Show (text: $"موردی برای حذف وجود ندارد!", caption: "اطلاع", icon: Mbb.Windows.Forms.MessageBoxIcon.Information, button: Mbb.Windows.Forms.MessageBoxButtons.Ok); return; } }
private void UpdateDataHookahButton_Click(object sender, System.EventArgs e) { Models.DataBaseContext dataBaseContext = null; try { dataBaseContext = new Models.DataBaseContext(); string hookaName = null; if (string.IsNullOrEmpty(HookahName_New)) { HookahName = HookahName_FirstLoad; } else { HookahName = HookahName_New; } if (string.IsNullOrEmpty(HookahPrice_New)) { HookahPrice = HookahPrice_FirstLoad; } else { HookahPrice = HookahPrice_New; } if (string.IsNullOrEmpty(HookahDescription_New)) { HookahDescription = HookahDescription_FirstLoad; } else { HookahDescription = HookahDescription_New; } if (string.IsNullOrEmpty(Select_HookahImage)) { HookahImage = HookahImage_FirstLoad; } else { HookahImage = HookahImage_New; } System.Windows.Forms.DialogResult dialogResult; dialogResult = Mbb.Windows.Forms.MessageBox.Show (text: $"{HookahName} به روز گردد؟", caption: "به روز رسانی", icon: Mbb.Windows.Forms.MessageBoxIcon.Question, button: Mbb.Windows.Forms.MessageBoxButtons.YesNo); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { Models.Hookah hookah = dataBaseContext.Hookahs .Where(current => string.Compare(current.HookahName, HookahName_FirstLoad, false) == 0) .FirstOrDefault(); HookahNumberUpdate = hookah.NumberUpdate; HookahUpdateTime = $"{Infrastructure.Utility.ShowTime()} - {Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; HookahNumberUpdate++; hookah.HookahName = HookahName; hookah.HookahPrice = HookahPrice; hookah.HookahDescription = HookahDescription; hookah.HookahImage = HookahImage; hookah.UpdateTime = HookahUpdateTime; hookah.NumberUpdate = HookahNumberUpdate; dataBaseContext.SaveChanges(); //-----جهت بارگذاری اطلاعات قلیان در جدول داده if (HOOKAH_SALON.MainForm.HookahStoreForm != null) { HOOKAH_SALON.MainForm.HookahStoreForm.HookahLoader(); } #region EventLogForFood if (string.IsNullOrEmpty(HookahName_New) && string.IsNullOrEmpty(HookahPrice_New) && string.IsNullOrEmpty(HookahDescription_New) && string.IsNullOrEmpty(Select_HookahImage)) { return; } else if (string.IsNullOrEmpty(HookahName_New) == false && string.IsNullOrEmpty(HookahPrice_New) && string.IsNullOrEmpty(HookahDescription_New) && string.IsNullOrEmpty(Select_HookahImage)) { #region EventLog Username = Program.AuthenticatedUser.Username; FullName = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}"; EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; EventTime = $"{Infrastructure.Utility.ShowTime()}"; EventTitle = $"نام {HookahName_FirstLoad} به {HookahName_New} تغییر کرد."; Infrastructure.Utility.EventLog (username: Username, fullName: FullName, eventDate: EventDate, eventTime: EventTime, eventTitle: EventTitle); #endregion /EventLog } else if (string.IsNullOrEmpty(HookahName_New) == false && string.IsNullOrEmpty(HookahPrice_New) == false && string.IsNullOrEmpty(HookahDescription_New) && string.IsNullOrEmpty(Select_HookahImage)) { #region EventLog Username = Program.AuthenticatedUser.Username; FullName = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}"; EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; EventTime = $"{Infrastructure.Utility.ShowTime()}"; EventTitle = $"نام {HookahName_FirstLoad} به {HookahName_New} و مبلغ آن از {HookahPrice_FirstLoad} به {HookahPrice_New} تغییر کرد."; Infrastructure.Utility.EventLog (username: Username, fullName: FullName, eventDate: EventDate, eventTime: EventTime, eventTitle: EventTitle); #endregion /EventLog } else if (string.IsNullOrEmpty(HookahName_New) == false && string.IsNullOrEmpty(HookahPrice_New) && string.IsNullOrEmpty(HookahDescription_New) == false && string.IsNullOrEmpty(Select_HookahImage)) { #region EventLog Username = Program.AuthenticatedUser.Username; FullName = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}"; EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; EventTime = $"{Infrastructure.Utility.ShowTime()}"; EventTitle = $"نام {HookahName_FirstLoad} به {HookahName_New}و توضیحات آن از {HookahDescription_FirstLoad} به {HookahDescription_New} تغییر کرد."; Infrastructure.Utility.EventLog (username: Username, fullName: FullName, eventDate: EventDate, eventTime: EventTime, eventTitle: EventTitle); #endregion /EventLog } else if (string.IsNullOrEmpty(HookahName_New) == false && string.IsNullOrEmpty(HookahPrice_New) && string.IsNullOrEmpty(HookahDescription_New) && string.IsNullOrEmpty(Select_HookahImage) == false) { #region EventLog Username = Program.AuthenticatedUser.Username; FullName = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}"; EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; EventTime = $"{Infrastructure.Utility.ShowTime()}"; EventTitle = $"نام {HookahName_FirstLoad} به {HookahName_New} و عکس آن تغییر کرد."; Infrastructure.Utility.EventLog (username: Username, fullName: FullName, eventDate: EventDate, eventTime: EventTime, eventTitle: EventTitle); #endregion /EventLog } else if (string.IsNullOrEmpty(HookahName_New) == false && string.IsNullOrEmpty(HookahPrice_New) == false && string.IsNullOrEmpty(HookahDescription_New) == false && string.IsNullOrEmpty(Select_HookahImage)) { #region EventLog Username = Program.AuthenticatedUser.Username; FullName = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}"; EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; EventTime = $"{Infrastructure.Utility.ShowTime()}"; EventTitle = $"نام {HookahName_FirstLoad} به {HookahName_New} و قیمت آن از {HookahPrice_FirstLoad} به {HookahPrice_New} و توضیحات آن از {HookahDescription_FirstLoad} به {HookahDescription_New} تغییر یافت."; Infrastructure.Utility.EventLog (username: Username, fullName: FullName, eventDate: EventDate, eventTime: EventTime, eventTitle: EventTitle); #endregion /EventLog } else if (string.IsNullOrEmpty(HookahName_New) == false && string.IsNullOrEmpty(HookahPrice_New) == false && string.IsNullOrEmpty(HookahDescription_New) && string.IsNullOrEmpty(Select_HookahImage) == false) { #region EventLog Username = Program.AuthenticatedUser.Username; FullName = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}"; EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; EventTime = $"{Infrastructure.Utility.ShowTime()}"; EventTitle = $"نام {HookahName_FirstLoad} به {HookahName_New} و قیمت آن از {HookahPrice_FirstLoad} به {HookahPrice_New} و عکس آن تغییر یافت."; Infrastructure.Utility.EventLog (username: Username, fullName: FullName, eventDate: EventDate, eventTime: EventTime, eventTitle: EventTitle); #endregion /EventLog } else if (string.IsNullOrEmpty(HookahName_New) == false && string.IsNullOrEmpty(HookahPrice_New) && string.IsNullOrEmpty(HookahDescription_New) == false && string.IsNullOrEmpty(Select_HookahImage) == false) { #region EventLog Username = Program.AuthenticatedUser.Username; FullName = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}"; EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; EventTime = $"{Infrastructure.Utility.ShowTime()}"; EventTitle = $"نام {HookahName_FirstLoad} به {HookahName_New} و توضیحات آن از {HookahDescription_FirstLoad} به {HookahDescription_New} و عکس آن تغییر یافت."; Infrastructure.Utility.EventLog (username: Username, fullName: FullName, eventDate: EventDate, eventTime: EventTime, eventTitle: EventTitle); #endregion /EventLog } else if (string.IsNullOrEmpty(HookahName_New) == false && string.IsNullOrEmpty(HookahPrice_New) == false && string.IsNullOrEmpty(HookahDescription_New) == false && string.IsNullOrEmpty(Select_HookahImage) == false) { #region EventLog Username = Program.AuthenticatedUser.Username; FullName = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}"; EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; EventTime = $"{Infrastructure.Utility.ShowTime()}"; EventTitle = $"نام {HookahName_FirstLoad} به {HookahName_New} و قیمت از {HookahPrice_FirstLoad} به {HookahPrice_New} و توضیحات از {HookahDescription_FirstLoad} به {HookahDescription_FirstLoad} و عکس آن تغییر یافت."; Infrastructure.Utility.EventLog (username: Username, fullName: FullName, eventDate: EventDate, eventTime: EventTime, eventTitle: EventTitle); #endregion /EventLog } else if (string.IsNullOrEmpty(HookahName_New) && string.IsNullOrEmpty(HookahPrice_New) == false && string.IsNullOrEmpty(HookahDescription_New) && string.IsNullOrEmpty(Select_HookahImage)) { #region EventLog Username = Program.AuthenticatedUser.Username; FullName = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}"; EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; EventTime = $"{Infrastructure.Utility.ShowTime()}"; EventTitle = $"قیمت {HookahName_FirstLoad} از {HookahPrice_FirstLoad} به {HookahPrice_New} تغییر کرد."; Infrastructure.Utility.EventLog (username: Username, fullName: FullName, eventDate: EventDate, eventTime: EventTime, eventTitle: EventTitle); #endregion /EventLog } else if (string.IsNullOrEmpty(HookahName_New) && string.IsNullOrEmpty(HookahPrice_New) == false && string.IsNullOrEmpty(HookahDescription_New) == false && string.IsNullOrEmpty(Select_HookahImage)) { #region EventLog Username = Program.AuthenticatedUser.Username; FullName = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}"; EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; EventTime = $"{Infrastructure.Utility.ShowTime()}"; EventTitle = $"قیمت {HookahName_FirstLoad} از {HookahPrice_FirstLoad} به {HookahPrice_New} و توضیحات آن از {HookahDescription_New} به {HookahDescription_New} تغییر کرد."; Infrastructure.Utility.EventLog (username: Username, fullName: FullName, eventDate: EventDate, eventTime: EventTime, eventTitle: EventTitle); #endregion /EventLog } else if (string.IsNullOrEmpty(HookahName_New) && string.IsNullOrEmpty(HookahPrice_New) == false && string.IsNullOrEmpty(HookahDescription_New) && string.IsNullOrEmpty(Select_HookahImage) == false) { #region EventLog Username = Program.AuthenticatedUser.Username; FullName = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}"; EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; EventTime = $"{Infrastructure.Utility.ShowTime()}"; EventTitle = $"قیمت {HookahName_FirstLoad} از {HookahPrice_FirstLoad} به {HookahPrice_New} و عکس آن تغییر کرد."; Infrastructure.Utility.EventLog (username: Username, fullName: FullName, eventDate: EventDate, eventTime: EventTime, eventTitle: EventTitle); #endregion /EventLog } else if (string.IsNullOrEmpty(HookahName_New) && string.IsNullOrEmpty(HookahPrice_New) == false && string.IsNullOrEmpty(HookahDescription_New) == false && string.IsNullOrEmpty(Select_HookahImage) == false) { #region EventLog Username = Program.AuthenticatedUser.Username; FullName = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}"; EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; EventTime = $"{Infrastructure.Utility.ShowTime()}"; EventTitle = $"قیمت {HookahName_FirstLoad} از {HookahPrice_FirstLoad} به {HookahPrice_New} و توضیحات آن از {HookahDescription_New} به {HookahDescription_New} و عکس آن تغییر کرد."; Infrastructure.Utility.EventLog (username: Username, fullName: FullName, eventDate: EventDate, eventTime: EventTime, eventTitle: EventTitle); #endregion /EventLog } else if (string.IsNullOrEmpty(HookahName_New) && string.IsNullOrEmpty(HookahPrice_New) && string.IsNullOrEmpty(HookahDescription_New) == false && string.IsNullOrEmpty(Select_HookahImage)) { #region EventLog Username = Program.AuthenticatedUser.Username; FullName = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}"; EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; EventTime = $"{Infrastructure.Utility.ShowTime()}"; EventTitle = $"توضیحات {HookahName_FirstLoad} از {HookahDescription_New} به {HookahDescription_New} تغییر کرد."; Infrastructure.Utility.EventLog (username: Username, fullName: FullName, eventDate: EventDate, eventTime: EventTime, eventTitle: EventTitle); #endregion /EventLog } else if (string.IsNullOrEmpty(HookahName_New) && string.IsNullOrEmpty(HookahPrice_New) && string.IsNullOrEmpty(HookahDescription_New) == false && string.IsNullOrEmpty(Select_HookahImage) == false) { #region EventLog Username = Program.AuthenticatedUser.Username; FullName = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}"; EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; EventTime = $"{Infrastructure.Utility.ShowTime()}"; EventTitle = $"توضیحات {HookahName_FirstLoad} از {HookahDescription_New} به {HookahDescription_New} و عکس آن تغییر کرد."; Infrastructure.Utility.EventLog (username: Username, fullName: FullName, eventDate: EventDate, eventTime: EventTime, eventTitle: EventTitle); #endregion /EventLog } else if (string.IsNullOrEmpty(HookahName_New) && string.IsNullOrEmpty(HookahPrice_New) && string.IsNullOrEmpty(HookahDescription_New) && string.IsNullOrEmpty(Select_HookahImage) == false) { #region EventLog Username = Program.AuthenticatedUser.Username; FullName = $"{Program.AuthenticatedUser.First_Name} {Program.AuthenticatedUser.Last_Name}"; EventDate = $"{Infrastructure.Utility.PersianCalendar(System.DateTime.Now)}"; EventTime = $"{Infrastructure.Utility.ShowTime()}"; EventTitle = $"عکس {HookahName_FirstLoad} تغییر کرد."; Infrastructure.Utility.EventLog (username: Username, fullName: FullName, eventDate: EventDate, eventTime: EventTime, eventTitle: EventTitle); #endregion /EventLog } #endregion /EventLogForFood string message = $"{HookahName} بروز رسانی گردید."; Infrastructure.Utility.WindowsNotification (message: message, caption: Infrastructure.PopupNotificationForm.Caption.موفقیت, picture: HookahImage); } else { return; } } catch (System.Exception ex) { Infrastructure.Utility.ExceptionShow(ex); } finally { if (dataBaseContext != null) { dataBaseContext.Dispose(); dataBaseContext = null; } } }