private static int DoRegisterNewPaymentInDb(PaymentInfo peaymentDetails)
        {
            int returnVal = 0;
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {
                //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();

                //define the connection used by the command object
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "INSERT INTO payment(id,customerId,amount,dop) "
                                                   + "VALUES(@id,@customerId,@amount,@dop)";

                msqlCommand.Parameters.AddWithValue("@id", peaymentDetails.id);
                msqlCommand.Parameters.AddWithValue("@customerId", peaymentDetails.customerId);
                msqlCommand.Parameters.AddWithValue("@amount", peaymentDetails.amount);
                msqlCommand.Parameters.AddWithValue("@dop", peaymentDetails.dop);

                msqlCommand.ExecuteNonQuery();

                returnVal = 1;
            }
            catch (Exception er)
            {
                returnVal = 0;
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
            return returnVal;
        }
        public static List<PaymentInfo> GetUnassignedPaymentList()
        {
            List<PaymentInfo> PaymentList = new List<PaymentInfo>();
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "Select * From payment;";
                MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();

                while (msqlReader.Read())
                {
                    PaymentInfo Payment = new PaymentInfo();

                    Payment.id = msqlReader.GetString("id");
                    Payment.customerId = msqlReader.GetString("customerId");
                    Payment.amount = msqlReader.GetDouble("amount");
                    Payment.dop = msqlReader.GetDateTime("dop");

                    PaymentList.Add(Payment);
                }

            }
            catch (Exception er)
            {
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }

            return PaymentList;
        }
        public static PaymentInfo GetPaymentInfo(string paymentId)
        {
            PaymentInfo payment = new PaymentInfo();

            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "Select * From payment WHERE id=@id;";
                msqlCommand.Parameters.AddWithValue("@id", paymentId);
                MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader();

                msqlReader.Read();

                payment.id = msqlReader.GetString("id");
                payment.customerId = msqlReader.GetString("customerId");
                payment.amount = msqlReader.GetDouble("amount");
                payment.dop = msqlReader.GetDateTime("dop");
            }
            catch (Exception er)
            {
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }

            return payment;
        }
        public static void EditPayment(PaymentInfo paymentToEdit)
        {
            MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection();

            try
            {   //define the command reference
                MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand();
                msqlCommand.Connection = msqlConnection;

                msqlCommand.CommandText = "UPDATE payment SET customerId=@customerId,amount=@amount,dop=@dop WHERE id=@id";

                msqlCommand.Parameters.AddWithValue("@customerId", paymentToEdit.customerId);
                msqlCommand.Parameters.AddWithValue("@amount", paymentToEdit.amount);
                msqlCommand.Parameters.AddWithValue("@dop", paymentToEdit.dop);
                msqlCommand.Parameters.AddWithValue("@id", paymentToEdit.id);
                msqlCommand.ExecuteNonQuery();

            }
            catch (Exception er)
            {
            }
            finally
            {
                //always close the connection
                msqlConnection.Close();
            }
        }
 public static int DoRegisterNewPayment(PaymentInfo peaymentDetails)
 {
     return DoRegisterNewPaymentInDb(peaymentDetails);
 }
        private void submitBtn_Click(object sender, RoutedEventArgs e)
        {
            ESCMSData.PaymentInfo PaymentData = new ESCMSData.PaymentInfo();

            PaymentData.id = paymentIdLbl.Content.ToString();
            PaymentData.customerId = nameTxtbox.SelectedValue.ToString();
            PaymentData.amount = Convert.ToDouble(amountTxtbox.Text);
            PaymentData.dop = dopDatePicker.SelectedDate.Value;

            if (isEdit == false)
            {
                PaymentData.id = GenerateId();
                ESCMSStorage.DbInteraction.DoRegisterNewPayment(PaymentData);
            }
            else
            {
                PaymentData.id = paymentId;
                ESCMSStorage.DbInteraction.EditPayment(PaymentData);
            }

            this.Close();
        }