//public static void LoadGrid_By_PlayingBoardTitle_Join_PlayingBoardType(PlayingBoardTitle PlayingBoardTitle, RadGridView grid, // DataBaseDataContext connection) //{ // //var myQuery = connection.PlayingBoards.Where(a => a.PlayingBoardTitle == playingBoardTitle).Select(a => new // //{ // // id = a.ID, // // title = a.PlayingBoardTitle.Title, // // number = a.Number // //}); // var query = connection.PlayingBoards.Where(a => a.PlayingBoardTitle == PlayingBoardTitle). // Join(connection.PlayingBoardTypes, // playingboard => playingboard.ID, // playingboardtype => playingboardtype.ID, // (a, b) => new // { // id = a.ID, // title = a.PlayingBoardTitle.Title, // number = a.Number, // type = b.Type, // price = b.Price // }); // grid.DataSource = query; // grid.Columns[1].IsVisible = false; // grid.Columns[2].HeaderText = "عنوان"; // grid.Columns[2].Width = 100; // grid.Columns[3].HeaderText = "شماره"; // grid.Columns[3].Width = 100; // grid.Columns[4].HeaderText = "نوع"; // grid.Columns[4].Width = 100; // grid.Columns[5].HeaderText = "قیمت"; // grid.Columns[5].Width = 100; // for (int i = 0; i < grid.RowCount; i++) // { // grid.Rows[i].Cells[0].Value = i + 1; // } //} public static void LoadGridByPlayingBoardTitle(PlayingBoardTitle PlayingBoardTitle, RadGridView grid, DataBaseDataContext connection) { var myQuery = connection.PlayingBoards.Where(a => a.PlayingBoardTitle == PlayingBoardTitle).Select(a => new { id = a.ID, title = a.PlayingBoardTitle.Title, number = a.Number }); grid.DataSource = myQuery; grid.Columns[1].IsVisible = false; grid.Columns[2].HeaderText = "عنوان"; grid.Columns[2].Width = 300; grid.Columns[3].HeaderText = "شماره"; grid.Columns[3].Width = 300; for (int i = 0; i < grid.RowCount; i++) { grid.Rows[i].Cells[0].Value = i + 1; } }
private void btnEdit_Click(object sender, EventArgs e) { if (gridPlayingBoardTitle.SelectedRows.Count == 0) { DataValidationMesaage.NoSelectedItemFromList(gridPlayingBoardTitle.Text); return; } DataBaseDataContext myConnection = Setting.DataBase; #region PlayingBoardTitle Casting int playingBoardTitleId = int.Parse(gridPlayingBoardTitle.SelectedRows[0].Cells[1].Value.ToString()); if (!PlayingBoardTitle.Validation(playingBoardTitleId, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } PlayingBoardTitle playingBoardTitle = PlayingBoardTitle.Get(playingBoardTitleId, myConnection); #endregion txtTitle.Text = playingBoardTitle.Title; FormManagement.EnableYesNo(this.Controls); txtTitle.Focus(); //myConnection.Dispose(); }
public static void Edit(PlayingBoardTitle playingBoardTitle, string title, DataBaseDataContext connection) { playingBoardTitle.Title = title; connection.SubmitChanges(); }
private void FrmPlayingBoardTitle_Load(object sender, EventArgs e) { DataBaseDataContext myConnection = Setting.DataBase; PlayingBoardTitle.LoadGrid_By_PlayingBoardGroupTitle(gridPlayingBoardTitle, FrmPlayingBoard.SelectedPlayingBoardGroupTitle, myConnection); myConnection.Dispose(); }
public static void Edit(PlayingBoard playingBoard, PlayingBoardTitle PlayingBoardTitle, string number, bool isAvailable, DataBaseDataContext connection) { playingBoard.Number = number; playingBoard.PlayingBoardTitle = PlayingBoardTitle; playingBoard.IsAvailable = isAvailable; connection.SubmitChanges(); }
public static PlayingBoard Insert(PlayingBoardTitle PlayingBoardTitle, string number, bool isAvailable, DataBaseDataContext connection) { PlayingBoard playingBoard = new PlayingBoard(number, isAvailable); playingBoard.PlayingBoardTitle = PlayingBoardTitle; connection.PlayingBoards.InsertOnSubmit(playingBoard); connection.SubmitChanges(); return(playingBoard); }
private void FrmSetRaspberryRelays_Load(object sender, EventArgs e) { DataBaseDataContext myConnection = Setting.DataBase; RaspBerryPlayingBoard.ShowList(lstRaspberryRelays, myConnection); RaspberryPin.LoadComboBoxAvailables(cmbRaspberryRelay, myConnection); PlayingBoardGroupTitle.LoadComboBox(cmbPlayingBoardGroupTitle, myConnection); if (myConnection.PlayingBoardGroupTitles.Any()) { #region PlayingBoardGroupTitle Cast int playingBoardGroupTitleId = ((PlayingBoardGroupTitle)cmbPlayingBoardGroupTitle.SelectedItem).ID; if (!PlayingBoardGroupTitle.Validation(playingBoardGroupTitleId, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } PlayingBoardGroupTitle playingBoardGroupTitle = PlayingBoardGroupTitle.Get(playingBoardGroupTitleId, myConnection); #endregion PlayingBoardTitle.LoadComboBox_By_PlayingBoardGroupTitle(cmbPlayingBoardTitle, playingBoardGroupTitle, myConnection); if (myConnection.PlayingBoardTitles.Any(a => a.PlayingBoardGroupTitle.Equals(playingBoardGroupTitle))) { #region PlayingBoardTitle Cast int playingBoardTitleId = ((PlayingBoardTitle)cmbPlayingBoardTitle.SelectedItem).ID; if (!PlayingBoardTitle.Validation(playingBoardTitleId, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } PlayingBoardTitle playingBoardTitle = PlayingBoardTitle.Get(playingBoardTitleId, myConnection); #endregion PlayingBoard.LoadComboBoxByFilter(cmbPlayingBoard, playingBoardTitle, myConnection); } } }
public static PlayingBoardTitle Insert(string title, PlayingBoardGroupTitle playingBoardGroupTitle, DataBaseDataContext connection) { PlayingBoardTitle playingBoardTitle = new PlayingBoardTitle(title); playingBoardTitle.PlayingBoardGroupTitle = playingBoardGroupTitle; connection.PlayingBoardTitles.InsertOnSubmit(playingBoardTitle); connection.SubmitChanges(); return(playingBoardTitle); }
private void btnYes_Click(object sender, EventArgs e) { DataBaseDataContext myConnection = Setting.DataBase; if (string.IsNullOrEmpty(txtTitle.Text) || string.IsNullOrWhiteSpace(txtTitle.Text)) { DataValidationMesaage.BlankTextBox("عنوان"); return; } #region PlayingBoardTitle Casting int playingBoardTitleID = int.Parse(gridPlayingBoardTitle.SelectedRows[0].Cells[1].Value.ToString()); if (!PlayingBoardTitle.Validation(playingBoardTitleID, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } PlayingBoardTitle playingBoardTitle = PlayingBoardTitle.Get(playingBoardTitleID, myConnection); #endregion if (myConnection.PlayingBoardTitles.Any(a => a.Title == txtTitle.Text.Trim() && a.ID != playingBoardTitleID)) { DataValidationMesaage.DuplicateData(txtTitle.Text); return; } PlayingBoardTitle.Edit(playingBoardTitle, txtTitle.Text.Trim(), myConnection); DataValidationMesaage.EditMessage(); ClearTextBox(); txtTitle.Focus(); PlayingBoardTitle.LoadGrid_By_PlayingBoardGroupTitle(gridPlayingBoardTitle, FrmPlayingBoard.SelectedPlayingBoardGroupTitle, myConnection); FormManagement.DisableYesNo(this.Controls); //myConnection.Dispose(); }
private void FrmPlayingBoard_Load(object sender, EventArgs e) { DataBaseDataContext myConnection = Setting.DataBase; PlayingBoardGroupTitle.LoadComboBox(cmbPlayingBoardGroupTitle, myConnection); if (myConnection.PlayingBoardGroupTitles.Any()) { #region PlayingBoardGroupTitle Cast int playingBoardGroupTitleId = ((PlayingBoardGroupTitle)cmbPlayingBoardGroupTitle.SelectedItem).ID; if (!PlayingBoardGroupTitle.Validation(playingBoardGroupTitleId, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } PlayingBoardGroupTitle playingBoardGroupTitle = PlayingBoardGroupTitle.Get(playingBoardGroupTitleId, myConnection); #endregion if (myConnection.PlayingBoardTitles.Any(a => a.PlayingBoardGroupTitle.Equals(playingBoardGroupTitle))) { #region PlayingBoardTitle Cast int playingBoardTitleId = ((PlayingBoardTitle)cmbPlayingBoardTitle.SelectedItem).ID; if (!PlayingBoardTitle.Validation(playingBoardTitleId, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } PlayingBoardTitle playingBoardTitle = PlayingBoardTitle.Get(playingBoardTitleId, myConnection); #endregion PlayingBoard.LoadGridColorful_By_PlayingBoardTitle(gridPlayingBoard, playingBoardTitle, myConnection); } } myConnection.Dispose(); }
private void cmbPlayingBoardGroupTitle_SelectedIndexChanged(object sender, EventArgs e) { DataBaseDataContext myConnection = Setting.DataBase; if (myConnection.PlayingBoardGroupTitles.Any()) { #region PlayingBoardGroupTitle Cast int playingBoardGroupTitleId = ((PlayingBoardGroupTitle)cmbPlayingBoardGroupTitle.SelectedItem).ID; if (!PlayingBoardGroupTitle.Validation(playingBoardGroupTitleId, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } PlayingBoardGroupTitle playingBoardGroupTitle = PlayingBoardGroupTitle.Get(playingBoardGroupTitleId, myConnection); #endregion PlayingBoardTitle.LoadComboBox_By_PlayingBoardGroupTitle(cmbPlayingBoardTitle, playingBoardGroupTitle, myConnection); if (myConnection.PlayingBoardTitles.Any(a => a.PlayingBoardGroupTitle.Equals(playingBoardGroupTitle))) { #region PlayingBoardTitle Cast int playingBoardTitleId = ((PlayingBoardTitle)cmbPlayingBoardTitle.SelectedItem).ID; if (!PlayingBoardTitle.Validation(playingBoardTitleId, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } PlayingBoardTitle playingBoardTitle = PlayingBoardTitle.Get(playingBoardTitleId, myConnection); #endregion PlayingBoard.LoadComboBoxByFilter(cmbPlayingBoard, playingBoardTitle, myConnection); } } }
private void btnDelete_Click(object sender, EventArgs e) { if (gridPlayingBoardTitle.SelectedRows.Count == 0) { DataValidationMesaage.NoSelectedItemFromList(gridPlayingBoardTitle.Text); return; } DataBaseDataContext myConnection = Setting.DataBase; #region PlayingBoardTitle Casting int playingBoardTitleId = int.Parse(gridPlayingBoardTitle.SelectedRows[0].Cells[1].Value.ToString()); if (!PlayingBoardTitle.Validation(playingBoardTitleId, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } PlayingBoardTitle playingBoardTitle = PlayingBoardTitle.Get(playingBoardTitleId, myConnection); #endregion if (playingBoardTitle.PlayingBoards.Any()) { DataValidationMesaage.DataInUse(playingBoardTitle.Title, gridPlayingBoardTitle.Text); return; } DialogResult message = DataValidationMesaage.ConfirmDeleteData(playingBoardTitle.Title); if (message == DialogResult.Yes) { PlayingBoardTitle.Delete(playingBoardTitle, myConnection); DataValidationMesaage.DeleteMessage(); PlayingBoardTitle.LoadGrid_By_PlayingBoardGroupTitle(gridPlayingBoardTitle, FrmPlayingBoard.SelectedPlayingBoardGroupTitle, myConnection); } //myConnection.Dispose(); }
public static void LoadGrid_By_PlayingBoardTitle_Join_PlayingBoardType(PlayingBoardTitle playingBoardTitle, RadGridView grid, DataBaseDataContext connection) { //var myQuery = connection.PlayingBoards.Where(a => a.PlayingBoardTitle == playingBoardTitle).Select(a => new //{ // id = a.ID, // title = a.PlayingBoardTitle.Title, // number = a.Number //}); var query = connection.PlayingBoards.Where(a => a.PlayingBoardTitle == playingBoardTitle) .Join(connection.PlayingBoardTypes, playingboard => playingboard.ID, playingboardtype => playingboardtype.PlayingBoardID, (a, b) => new { id = a.ID, title = a.PlayingBoardTitle.PlayingBoardGroupTitle.GroupTitle + " " + a.PlayingBoardTitle.Title + " " + a.Number, type = b.Type, price = b.Price }); grid.DataSource = query; grid.Columns[1].IsVisible = false; grid.Columns[2].HeaderText = "عنوان"; grid.Columns[2].Width = 207; grid.Columns[4].HeaderText = "نوع بازی"; grid.Columns[4].Width = 100; grid.Columns[5].HeaderText = "قیمت به ساعت"; grid.Columns[5].Width = 100; for (int i = 0; i < grid.RowCount; i++) { grid.Rows[i].Cells[0].Value = i + 1; } }
public static void LoadGridColorful_By_PlayingBoardTitle(RadGridView grid, PlayingBoardTitle PlayingBoardTitle, DataBaseDataContext connection) { var myQuery = connection.PlayingBoards .Where(a => a.PlayingBoardTitle == PlayingBoardTitle) .Select(a => new { id = a.ID, title = a.PlayingBoardTitle.Title, number = a.Number, isAvailable = a.IsAvailable }); grid.DataSource = myQuery; grid.Columns[1].IsVisible = false; grid.Columns[2].HeaderText = "عنوان"; grid.Columns[2].Width = (int)Math.Ceiling(0.44 * grid.Width); grid.Columns[3].HeaderText = "شماره"; grid.Columns[3].Width = (int)Math.Ceiling(0.44 * grid.Width); grid.Columns[4].IsVisible = false; for (int i = 0; i < grid.RowCount; i++) { grid.Rows[i].Cells[0].Value = i + 1; for (int j = 0; j < grid.Rows[i].Cells.Count; j++) { grid.Rows[i].Cells[j].Style.CustomizeFill = true; grid.Rows[i].Cells[j].Style.DrawFill = true; grid.Rows[i].Cells[j].Style.BackColor = (bool)grid.Rows[i].Cells[4].Value ? Color.LightGreen : Color.Gray; } } }
private void btnSave_Click(object sender, EventArgs e) { DataBaseDataContext myConnection = Setting.DataBase; if (string.IsNullOrWhiteSpace(txtTitle.Text.Trim()) || string.IsNullOrEmpty(txtTitle.Text.Trim())) { DataValidationMesaage.BlankTextBox("عنوان دستگاه"); return; } #region PlayingBoardGroupTitle Cast int id = FrmPlayingBoard.SelectedPlayingBoardGroupTitle.ID; if (!PlayingBoardGroupTitle.Validation(id, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } PlayingBoardGroupTitle playingBoardGroupTitle = PlayingBoardGroupTitle.Get(id, myConnection); #endregion if (myConnection.PlayingBoardTitles.Any(a => a.Title == txtTitle.Text.Trim())) { DataValidationMesaage.DuplicateData("عنوان دستگاه"); return; } PlayingBoardTitle.Insert(txtTitle.Text.Trim(), playingBoardGroupTitle, myConnection); PlayingBoardTitle.LoadGrid_By_PlayingBoardGroupTitle(gridPlayingBoardTitle, playingBoardGroupTitle, myConnection); ClearTextBox(); //myConnection.Dispose(); }
public static void LoadComboBoxByFilter(ComboBox cmbBox, PlayingBoardTitle PlayingBoardTitle, DataBaseDataContext connection) { IQueryable <PlayingBoard> myQuery = connection.PlayingBoards.Where(a => a.PlayingBoardTitle == PlayingBoardTitle); cmbBox.Items.Clear(); foreach (var item in myQuery) { cmbBox.Items.Add(item); } if (!myQuery.Any()) { cmbBox.Items.Add("یک آیتم به ثبت برسانید"); cmbBox.SelectedIndex = 0; return; } cmbBox.SelectedIndex = 0; }
public static void Delete(PlayingBoardTitle playingBoardTitle, DataBaseDataContext connection) { connection.PlayingBoardTitles.DeleteOnSubmit(playingBoardTitle); connection.SubmitChanges(); }
private void btnSave_Click(object sender, EventArgs e) { DataBaseDataContext myConnection = Setting.DataBase; if (string.IsNullOrEmpty(txtNumber.Text) || string.IsNullOrWhiteSpace(txtNumber.Text)) { DataValidationMesaage.BlankTextBox("شماره دستگاه"); return; } if (myConnection.PlayingBoardGroupTitles.Any()) { #region PlayingBoardGroupTitle Cast int playingBoardGroupTitleId = ((PlayingBoardGroupTitle)cmbPlayingBoardGroupTitle.SelectedItem).ID; if (!PlayingBoardGroupTitle.Validation(playingBoardGroupTitleId, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } PlayingBoardGroupTitle playingBoardGroupTitle = PlayingBoardGroupTitle.Get(playingBoardGroupTitleId, myConnection); #endregion if (!myConnection.PlayingBoardTitles.Any(a => a.PlayingBoardGroupTitle.Equals(playingBoardGroupTitle))) { DataValidationMesaage.BlankComboBox("عنوان دستگاه"); return; } if ( myConnection.PlayingBoardTitles.Any( a => a.Title.Equals(txtNumber.Text.Trim()) && a.PlayingBoardGroupTitle.Equals(playingBoardGroupTitle))) { MessageBox.Show("کاربر گرامی مقادیر شماره میز و عنوان بازی نمیتوانند یکسان باشند.", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } #region PlayingBoardTitle Cast int id = ((PlayingBoardTitle)cmbPlayingBoardTitle.SelectedItem).ID; if (!PlayingBoardTitle.Validation(id, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } PlayingBoardTitle playingBoardTitle = PlayingBoardTitle.Get(id, myConnection); #endregion if (myConnection.PlayingBoards.Any(a => a.PlayingBoardTitle == playingBoardTitle && a.Number.Equals(txtNumber.Text.Trim()))) { DataValidationMesaage.DuplicateData("شماره میز"); return; } PlayingBoard playingBoard = PlayingBoard.Insert(playingBoardTitle, txtNumber.Text, true, myConnection); DataValidationMesaage.AcceptMessage(); DialogResult result1 = MessageBox.Show("آیا مایلید برق میز بازی ثبت شده را به صورت سیستمی کنترل نمایید؟", "کاربر گرامی", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result1 == DialogResult.Yes) { btnRaspberryRelay.PerformClick(); } DialogResult result2 = MessageBox.Show("آیا مایلید برای میز بازی ثبت شده بهاء تعیین نمایید؟", "کاربر گرامی", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result2 == DialogResult.Yes) { btnPrice.PerformClick(); } clearTextBox(); PlayingBoard.LoadGridColorful_By_PlayingBoardTitle(gridPlayingBoard, playingBoardTitle, myConnection); }
private void btnYes_Click(object sender, EventArgs e) { #region Check Blank txtNumber if (string.IsNullOrEmpty(txtNumber.Text.Trim()) && string.IsNullOrWhiteSpace(txtNumber.Text.Trim())) { DataValidationMesaage.BlankTextBox("شماره دستگاه"); return; } #endregion DataBaseDataContext myConnection = Setting.DataBase; if (myConnection.PlayingBoardGroupTitles.Any()) { #region PlayingBoardTitle Cast int playingBoardTitleId = ((PlayingBoardTitle)cmbPlayingBoardTitle.SelectedItem).ID; if (!PlayingBoardTitle.Validation(playingBoardTitleId, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } PlayingBoardTitle playingBoardTitle = PlayingBoardTitle.Get(playingBoardTitleId, myConnection); #endregion #region Check Duplicate cmbPlayingBoardTitle and txtNumber if ( myConnection.PlayingBoards.Any( a => a.PlayingBoardTitle.Title.Equals(txtNumber.Text.Trim()))) { MessageBox.Show("کاربر گرامی مقادیر شماره میز و عنوان بازی نمیتوانند یکسان باشند.", "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } #endregion #region Check Duplicate Data if ( myConnection.PlayingBoards.Any( a => a.Number.Equals(txtNumber.Text.Trim()) && a.PlayingBoardTitle.Equals(playingBoardTitle))) { DataValidationMesaage.DuplicateData("شماره میز"); return; } #endregion #region PlayingBoard Cast int PlayingBoardId = (int)gridPlayingBoard.SelectedRows[0].Cells[1].Value; if (!PlayingBoard.Validation(PlayingBoardId, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } PlayingBoard playingBoard = PlayingBoard.Get(PlayingBoardId, myConnection); #endregion PlayingBoard.Edit(playingBoard, playingBoardTitle, txtNumber.Text.Trim(), true, myConnection); DataValidationMesaage.EditMessage(); clearTextBox(); FormManagement.DisableYesNoIncludingComboBox(this.Controls); PlayingBoard.LoadGridColorful_By_PlayingBoardTitle(gridPlayingBoard, playingBoardTitle, myConnection); } myConnection.Dispose(); }
private void cmbPlayingBoardGroupTitle_SelectedIndexChanged(object sender, EventArgs e) { gridPlayingBoard.Rows.Clear(); DataBaseDataContext myConnection = Setting.DataBase; if (myConnection.PlayingBoardGroupTitles.Any()) { btnAddPlayingboardTitle.Visible = true; #region PlayingBoardGroupTitle Cast int playingBoardGroupTitleId = ((PlayingBoardGroupTitle)cmbPlayingBoardGroupTitle.SelectedItem).ID; if (!PlayingBoardGroupTitle.Validation(playingBoardGroupTitleId, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } PlayingBoardGroupTitle playingBoardGroupTitle = PlayingBoardGroupTitle.Get(playingBoardGroupTitleId, myConnection); #endregion PlayingBoardTitle.LoadComboBox_By_PlayingBoardGroupTitle(cmbPlayingBoardTitle, playingBoardGroupTitle, myConnection); if (myConnection.PlayingBoardTitles.Any(a => a.PlayingBoardGroupTitle.Equals(playingBoardGroupTitle))) { #region PlayingBoardTitle Cast int playingBoardTitleId = ((PlayingBoardTitle)cmbPlayingBoardTitle.SelectedItem).ID; if (!PlayingBoardTitle.Validation(playingBoardTitleId, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } PlayingBoardTitle playingBoardTitle = PlayingBoardTitle.Get(playingBoardTitleId, myConnection); #endregion PlayingBoard.LoadGridColorful_By_PlayingBoardTitle(gridPlayingBoard, playingBoardTitle, myConnection); } } else { btnAddPlayingboardTitle.Visible = false; cmbPlayingBoardTitle.Items.Add("گروه بازی کامل شود"); cmbPlayingBoardTitle.SelectedIndex = 0; return; } }