Ejemplo n.º 1
0
        private static orderdetails ReaderDataOrderTotalAmount(MySqlDataReader reader)
        {
            orderdetails objorderdetails = new orderdetails();

            objorderdetails.TOTAL = Utility.IsValidInt(reader["TOTAL"]);

            return(objorderdetails);
        }
Ejemplo n.º 2
0
        public static string Saveorderdetails(orderdetails objorderdetails, MySqlConnection conn = null, MySqlTransaction trans = null)
        {
            string returnMessage = "";

            //string sORDERID = "";
            //sORDERID = objorderdetails.ORDERID.ToString();
            //var templstorderdetails = Getorderdetails("ORDERID='" + sORDERID + "'", conn);
            try
            {
                bool            isConnArgNull = (conn != null) ? false : true;
                MySqlConnection connection    = (conn != null) ? conn : PrimaryConnection();
                //MySqlConnection connection = new MySqlConnection("server=32.148.68.125;user id = testusr; password=Testusr123!@#; database=testdatabase");
                tryOpenConnection(connection);
                using (MySqlCommand command = new MySqlCommand())
                {
                    string sql;

                    sql = @"INSERT INTO ORDERDETAILS(ORDERID,ITEMID,QUANTITY) VALUES (@ORDERID,@ITEMID,@QUANTITY)";


                    if (trans != null)
                    {
                        command.Transaction = trans;
                    }
                    command.Connection  = connection;
                    command.CommandType = CommandType.Text;
                    command.CommandText = sql;

                    command.Parameters.AddWithValue("@ORDERID", objorderdetails.ORDERID);
                    command.Parameters.AddWithValue("@ITEMID", objorderdetails.ITEMID);
                    command.Parameters.AddWithValue("@QUANTITY", objorderdetails.QUANTITY);

                    int affectedRows = command.ExecuteNonQuery();
                    if (affectedRows > 0)
                    {
                        returnMessage = "OK";
                    }
                    else
                    {
                        returnMessage = Constants.MSG_ERR_DBSAVE.Text;
                    }
                }

                if (isConnArgNull == true)
                {
                    connection.Dispose();
                }
            }
            catch (Exception ex)
            {
            }

            return(returnMessage);
        }
Ejemplo n.º 3
0
        private static orderdetails ReaderDataorderdetails(MySqlDataReader reader)
        {
            orderdetails objorderdetails = new orderdetails();

            objorderdetails.ORDERID  = Utility.IsValidInt(reader["ORDERID"]);
            objorderdetails.ITEMID   = Utility.IsValidInt(reader["ITEMID"]);
            objorderdetails.QUANTITY = Utility.IsValidInt(reader["QUANTITY"]);


            return(objorderdetails);
        }
Ejemplo n.º 4
0
        private static orderdetails ReaderDataOrderDetailsItem(MySqlDataReader reader)
        {
            orderdetails objorderdetails = new orderdetails();

            objorderdetails.ITEMNAME       = Utility.IsValidString(reader["ITEMNAME"]);
            objorderdetails.PRICE          = Utility.IsValidInt(reader["PRICE"]);
            objorderdetails.QUANTITY       = Utility.IsValidInt(reader["QUANTITY"]);
            objorderdetails.AMOUNTSUBTOTAL = Utility.IsValidInt(reader["SUBTOTAL"]);

            return(objorderdetails);
        }
Ejemplo n.º 5
0
        public static int getTotalAmount(string OrderId, MySqlConnection conn = null)
        {
            int          Amount;
            orderdetails obj = new orderdetails();

            obj    = orderdetailsManager.getTotalAmount(OrderId, conn);
            Amount = obj.TOTAL;


            return(Amount);
        }
Ejemplo n.º 6
0
        public static List <orderdetails> Getorderdetails(string whereclause, MySqlConnection conn = null)
        {
            orderdetails        objorderdetails = new orderdetails();
            List <orderdetails> lstorderdetails = new List <orderdetails>();

            try
            {
                bool            isConnArgNull = (conn != null) ? false : true;
                MySqlConnection connection    = (conn != null) ? conn : PrimaryConnection();
                tryOpenConnection(connection);
                string sql = "select * from orderdetails ";
                if (!string.IsNullOrEmpty(whereclause))
                {
                    sql += " where " + whereclause;
                }
                using (MySqlCommand command = new MySqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandText = sql;
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                objorderdetails = ReaderDataorderdetails(reader);
                                lstorderdetails.Add(objorderdetails);
                            }
                        }
                        else
                        {
                        }
                    }
                }

                if (isConnArgNull == true)
                {
                    connection.Dispose();
                }
            }
            catch
            {
            }
            return(lstorderdetails);
        }
Ejemplo n.º 7
0
        public static List <orderdetails> GetOrderDetailsItem(string ORDERID, MySqlConnection conn = null)
        {
            orderdetails        objorderdetails = null;
            List <orderdetails> lstorderdetails = new List <orderdetails>();

            try
            {
                bool            isConnArgNull = (conn != null) ? false : true;
                MySqlConnection connection    = (conn != null) ? conn : PrimaryConnection();
                tryOpenConnection(connection);
                string sql = "SELECT        D.ORDERID, F.ITEMNAME, F.PRICE, SUM(D.QUANTITY) AS QUANTITY, SUM(D.QUANTITY * F.PRICE) AS SUBTOTAL FROM orderdetails D INNER JOIN fooditem F ON D.ITEMID = F.ITEMID WHERE (D.ORDERID= " + (ORDERID) + ")    GROUP BY D.ORDERID, F.ITEMNAME";
                //if (!string.IsNullOrEmpty(whereclause))
                //    sql += " where " + whereclause;
                using (MySqlCommand command = new MySqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandText = sql;
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                objorderdetails = ReaderDataOrderDetailsItem(reader);
                                lstorderdetails.Add(objorderdetails);
                            }
                        }
                        else
                        {
                        }
                    }
                }

                if (isConnArgNull == true)
                {
                    connection.Dispose();
                }
            }
            catch (Exception ex)
            {
            }

            return(lstorderdetails);
        }