コード例 #1
0
        //---------------------------------------------------
        static Int32 makeNewPitcher(iLocalDB db, string yymmdd, string choice)
        {

            string query = "SELECT Max(xNumber) AS MaxNum FROM PITCHER";

            DB_Query(db, query);

            if (db.HasRows == false) return 1;

            db.Read();

            string maxNumStr = db.GetData("MaxNum").ToString();

            Int32 maxNumber;

            if (string.IsNullOrEmpty(maxNumStr))
            {
                maxNumber = 1;
            }

            else
            {
                maxNumber = Convert.ToInt32(db.GetData("MaxNum").ToString()) + 1;
            }

            double recipeAmount = getRecipeAmount(db, choice);

            query = string.Format("INSERT INTO PITCHER VALUES({0},'{1}','{2}',{3})",
                                  maxNumber, yymmdd, choice, recipeAmount);
            DB_Query(db, query);

            Console.WriteLine("new Pitcher {0}: '{1}' made", maxNumber, choice);

            return maxNumber;
        }
コード例 #2
0
        //----------------------------------------------

        //----------------------------------------------
        private bool IsSameDeptCode(iLocalDB db, string code)
        {
            db.Open();
            string query   = string.Format("SELECT xDept_name FROM xDEPARTMENT WHERE xDept_code='{0}'", code); // {0}에는 code 값이 들어감
            string err_msg = db.Query(query);
            string title   = "";

            if (err_msg != null)
            {
                MessageBox.Show(query + "\n\n" + err_msg, "SQL Error");
                return(false);
            }
            db.ExecuteReader(query);

            while (db.Read())
            {
                title = db.GetData("xDept_name").ToString();
            }
            if (title != cbx_학과입력.SelectedValue.ToString())  //입력 학과랑 학번이랑 틀림
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #3
0
        //---------------------------------------------------
        static double getPitcherAmount(iLocalDB db, Int32 pitcherNumber)
        {
            string query = string.Format("SELECT xAmount From PITCHER WHERE xNumber={0}", pitcherNumber);

            DB_Query(db, query);

            db.Read();
            double xAmount = Convert.ToDouble(db.GetData("xAmount").ToString());

            return xAmount;
        }
コード例 #4
0
        //---------------------------------------------------
        static Int32 getPitcher(iLocalDB db, string choice)
        {
            string query = string.Format("SELECT xNumber FROM PITCHER WHERE Recipe_used='{0}' AND xAmount > 0", choice);

            DB_Query(db, query);

            if (db.HasRows == false) return 0;

            db.Read();
            Int32 xNumber = Convert.ToInt32(db.GetData("xNumber").ToString());

            return xNumber;
        }
コード例 #5
0
        //-----------------------------------------------------
        static double getRecipeAmount(iLocalDB db, string recipeName)
        {
            string query = string.Format("SELECT Water From RECIPE WHERE Name='{0}'", recipeName);

            DB_Query(db, query);

            if (db.HasRows == false)
            {
                Console.WriteLine("Receipe name error");
                Environment.Exit(1);
            }

            db.Read();
            double waterAmount = Convert.ToDouble(db.GetData("Water").ToString());

            return waterAmount;
        }