Example #1
0
        /// <summary>
        /// Creates a new instance of the Qds_PaymentMethodAvailableByDepot class and populates it with data from the specified SqlDataReader.
        /// </summary>
        protected virtual Qds_PaymentMethodAvailableByDepot MakeQds_PaymentMethodAvailableByDepot(SqlDataReader dataReader)
        {
            Qds_PaymentMethodAvailableByDepot qds_PaymentMethodAvailableByDepot = new Qds_PaymentMethodAvailableByDepot();

            qds_PaymentMethodAvailableByDepot.DepotID         = SqlClientUtility.GetString(dataReader, "DepotID", String.Empty);
            qds_PaymentMethodAvailableByDepot.PaymentMethodID = SqlClientUtility.GetInt32(dataReader, "PaymentMethodID", 0);
            qds_PaymentMethodAvailableByDepot.DepotDefault    = SqlClientUtility.GetBoolean(dataReader, "DepotDefault", false);

            return(qds_PaymentMethodAvailableByDepot);
        }
Example #2
0
        /// <summary>
        /// Updates a record in the Qds_PaymentMethodAvailableByDepot table.
        /// </summary>
        public virtual void Update(Qds_PaymentMethodAvailableByDepot qds_PaymentMethodAvailableByDepot)
        {
            ValidationUtility.ValidateArgument("qds_PaymentMethodAvailableByDepot", qds_PaymentMethodAvailableByDepot);

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@DepotID", qds_PaymentMethodAvailableByDepot.DepotID),
                new SqlParameter("@PaymentMethodID", qds_PaymentMethodAvailableByDepot.PaymentMethodID),
                new SqlParameter("@DepotDefault", qds_PaymentMethodAvailableByDepot.DepotDefault)
            };

            SqlClientUtility.ExecuteNonQuery(connectionStringName, CommandType.StoredProcedure, "Qds_PaymentMethodAvailableByDepot_Update", parameters);
        }
Example #3
0
        /// <summary>
        /// Selects all records from the Qds_PaymentMethodAvailableByDepot table.
        /// </summary>
        public virtual List <Qds_PaymentMethodAvailableByDepot> SelectAll()
        {
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "Qds_PaymentMethodAvailableByDepot_SelectAll"))
            {
                List <Qds_PaymentMethodAvailableByDepot> qds_PaymentMethodAvailableByDepotList = new List <Qds_PaymentMethodAvailableByDepot>();
                while (dataReader.Read())
                {
                    Qds_PaymentMethodAvailableByDepot qds_PaymentMethodAvailableByDepot = MakeQds_PaymentMethodAvailableByDepot(dataReader);
                    qds_PaymentMethodAvailableByDepotList.Add(qds_PaymentMethodAvailableByDepot);
                }

                return(qds_PaymentMethodAvailableByDepotList);
            }
        }
Example #4
0
        /// <summary>
        /// Selects all records from the Qds_PaymentMethodAvailableByDepot table by a foreign key.
        /// </summary>
        public virtual List <Qds_PaymentMethodAvailableByDepot> _SelectAllByPaymentMethodID(int paymentMethodID)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@PaymentMethodID", paymentMethodID)
            };

            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "Qds_PaymentMethodAvailableByDepot_SelectAllByPaymentMethodID", parameters))
            {
                List <Qds_PaymentMethodAvailableByDepot> qds_PaymentMethodAvailableByDepotList = new List <Qds_PaymentMethodAvailableByDepot>();
                while (dataReader.Read())
                {
                    Qds_PaymentMethodAvailableByDepot qds_PaymentMethodAvailableByDepot = MakeQds_PaymentMethodAvailableByDepot(dataReader);
                    qds_PaymentMethodAvailableByDepotList.Add(qds_PaymentMethodAvailableByDepot);
                }

                return(qds_PaymentMethodAvailableByDepotList);
            }
        }
Example #5
0
        private int NextPaymentMethodID()
        {
            //
            if (qds_PaymentMethod_Sp == null)
            {
                qds_PaymentMethod_Sp = new Qds_PaymentMethod_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }

            List <Qds_PaymentMethod> qds_PaymentMethodList = qds_PaymentMethod_Sp.SelectAll();

            if (qds_PaymentMethodList.Count < 1)
            {
                return(-1);
            }

            if (qds_PaymentMethodAvailableByDepot_Sp == null)
            {
                qds_PaymentMethodAvailableByDepot_Sp = new Qds_PaymentMethodAvailableByDepot_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }

            foreach (Qds_PaymentMethod pm in qds_PaymentMethodList)
            {
                if (pm.PaymentMethodID == 0)
                {
                    continue;
                }

                qds_PaymentMethodAvailableByDepot = qds_PaymentMethodAvailableByDepot_Sp.Select(depotID, pm.PaymentMethodID);

                if (qds_PaymentMethodAvailableByDepot == null)
                {
                    return(pm.PaymentMethodID);
                }
            }


            return(-1);
        }
Example #6
0
        private void OK_Click(object sender, EventArgs e)
        {
            if (DataGridView1.Rows.Count < 1)
            {
                return;
            }

            int paymentMethodID = (int)DataGridView1.CurrentRow.Cells[1].Value;

            if (paymentMethodID == 0)
            {
                MessageBox.Show("Please select another method!");
                return;
            }

            //Check that PaymentMethod is not assigned if change
            if (formerPaymentMethodID != paymentMethodID)
            {
                if (qds_PaymentMethodAvailableByDepot_Sp == null)
                {
                    qds_PaymentMethodAvailableByDepot_Sp = new Qds_PaymentMethodAvailableByDepot_Sp(Properties.Settings.Default.WsirDbConnectionString);
                }

                qds_PaymentMethodAvailableByDepot = qds_PaymentMethodAvailableByDepot_Sp.Select(depotID, paymentMethodID);

                if (qds_PaymentMethodAvailableByDepot != null)
                {
                    MessageBox.Show("Payment Method already assigned!");
                    return;
                }
            }

            //only on DepotDefault
            bool depotDefault = (bool)DataGridView1.CurrentRow.Cells[2].Value;

            if (depotDefault &&
                (formerDepotDefault != depotDefault))
            {
                using (SqlConnection connection = new SqlConnection(Properties.Settings.Default.WsirDbConnectionString))
                {
                    try
                    {
                        string query =
                            "UPDATE [Qds_PaymentMethodAvailableByDepot] WITH (ROWLOCK) " +
                            "SET [DepotDefault] = 0 " +
                            "WHERE [DepotID] = '" + depotID + "' ";
                        using (SqlCommand command = new SqlCommand(query, connection))
                        {
                            connection.Open();
                            command.ExecuteNonQuery();
                        }
                    }
                    catch
                    {
                        //
                    }
                    finally
                    {
                        connection.Close();
                    }
                }
            }

            if (OK.Text == "&Select")
            {
                try
                {
                    int.TryParse(this.DataGridView1.CurrentRow.Cells[0].Value.ToString(), out fieldId);
                    if (fieldId < 1)
                    {
                        throw new Exception();
                    }
                    fieldName = DataGridView1.CurrentRow.Cells[1].Value.ToString().Trim();
                }
                catch
                {
                    MessageBox.Show("Please select a valid item.");
                    return;
                }

                Close();
                return;
            }


            BindingNavigatorSaveItem.PerformClick();
        }