public static void Edit(CardSerialPayment cardSerialPayment, string cardPaymentIdentity, string cardNumber, string accountNumber, Payment payment, BankAccount bankAccount, DataBaseDataContext connection) { cardSerialPayment.CardPaymentIdentity = cardPaymentIdentity; cardSerialPayment.CardNumber = cardNumber; cardSerialPayment.AccountNumber = accountNumber; cardSerialPayment.BankAccount = BankAccount.Get(bankAccount.ID, connection); cardSerialPayment.Payment = Payment.Get(payment.ID, connection); connection.SubmitChanges(); }
public static CardSerialPayment Insert(string cardPaymentIdentity, string cardNumber, string accountNumber, Payment payment, BankAccount bankAccount, DataBaseDataContext connection) { CardSerialPayment cardSerialPayment = new CardSerialPayment(cardPaymentIdentity, cardNumber, accountNumber); cardSerialPayment.BankAccount = BankAccount.Get(bankAccount.ID, connection); cardSerialPayment.Payment = Payment.Get(payment.ID, connection); connection.CardSerialPayments.InsertOnSubmit(cardSerialPayment); connection.SubmitChanges(); return(cardSerialPayment); }
private void btnPayment_Click(object sender, EventArgs e) { if (gridMember.SelectedRows.Count == 0) { DataValidationMesaage.NoSelectedItemFromList(gridMember.Text); return; } DataBaseDataContext myConnection = Setting.DataBase; #region RentPlayingBoard Cast int rentid = memberRentPlayingBoard.RentPlayingBoardID; if (!RentPlayingBoard.Validation(rentid, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } RentPlayingBoard rentPlayingBoard = RentPlayingBoard.Get(rentid, myConnection); #endregion if (radioOther.Checked) { #region Member Cast int id = int.Parse(gridMember.SelectedRows[0].Cells[1].Value.ToString()); if (!Member.Validation(id, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } _member = Member.Get(id, myConnection); #endregion } if (radioMySelf.Checked) { #region Member Cast int id = memberRentPlayingBoard.Member.ID; if (!Member.Validation(id, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } _member = Member.Get(id, myConnection); #endregion } RentPlayingBoard myRentPlayingBoard = RentPlayingBoard.Edit(rentPlayingBoard, DateTime.Now.ToString("HH:mm:ss"), false, myConnection); MemberRentPlayingBoard closerMemberRentPlayingBoard = MemberRentPlayingBoard.Insert(myRentPlayingBoard, _member, "Closer", myConnection); myRentPlayingBoard.PlayingBoardType.PlayingBoard.IsAvailable = true; int playingBoardID = myRentPlayingBoard.PlayingBoardType.PlayingBoardID; #region Raspberry Check and Turn off if (myConnection.RaspBerryPlayingBoards.Any(a => a.PlayingBoardID.Equals(playingBoardID))) { if (!RaspBerryPlayingBoard.Validation_By_PlayingBoardID(playingBoardID, myConnection)) { DataValidationMesaage.NoDataInBank(); return; } #region RaspBerryPlayingBoard Cast RaspBerryPlayingBoard raspBerryPlayingBoard = RaspBerryPlayingBoard.Get_By_PlayingBoardID( playingBoardID, myConnection); #endregion MemberRentPlayingBoard.PowerOnOff(raspBerryPlayingBoard.RaspberryPin, "0", Setting.RaspberryIPAddress, Setting.RaspberryPortNumber); } #endregion bool isCredit = true && cmbIsCredit.SelectedText.Equals("نسیه"); bool isCard = true && radioCard.Checked; if (string.IsNullOrWhiteSpace(txtPrice.Text.Trim()) || string.IsNullOrEmpty(txtPrice.Text.Trim())) { DataValidationMesaage.BlankTextBox("مبلغ پرداختی"); return; } if (isCard) { if (string.IsNullOrWhiteSpace(txtCardPaymentIdentity.Text.Trim()) || string.IsNullOrEmpty(txtCardPaymentIdentity.Text.Trim())) { DataValidationMesaage.BlankTextBox("شناسه پرداخت"); return; } if (myConnection.CardSerialPayments.Any(a => a.CardPaymentIdentity.Equals(txtCardPaymentIdentity.Text.Trim()))) { DataValidationMesaage.DuplicateData("شناسه پرداخت"); return; } } Payment payment = Payment.Insert(int.Parse(txtPrice.Text.Trim()), DateTime.Now, isCredit, isCard, "", closerMemberRentPlayingBoard.ID, _member, myConnection); if (isCard) { CardSerialPayment.Insert(txtCardPaymentIdentity.Text.Trim(), txtCardNumber.Text.Trim(), txtAccountNumber.Text.Trim(), payment, (BankAccount)cmbBankAccount.SelectedItem, myConnection); } myConnection.SubmitChanges(); MessageBox.Show("بازی تمام شد."); DialogResult message = MessageBox.Show( "پرداخت انجام شد و میز بازی بسته شد. آیا مایل هستید پنجره جاری بسته شود؟ ", "کاربر گرامی", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (message == DialogResult.Yes) { this.Close(); } myConnection.Dispose(); }
public static void Delete(CardSerialPayment cardSerialPayment, DataBaseDataContext connection) { connection.CardSerialPayments.DeleteOnSubmit(cardSerialPayment); connection.SubmitChanges(); }