public void PrepareRecipe()
        {
            var tea = new Tea();

            tea.PrepareRecipe();

            Assert.IsTrue(this.sw.ToString().Contains(BeverageMessages.BoilWater));
            Assert.IsTrue(this.sw.ToString().Contains(BeverageMessages.SteepTeaBag));
            Assert.IsTrue(this.sw.ToString().Contains(BeverageMessages.PourInCup));
            Assert.IsTrue(this.sw.ToString().Contains(BeverageMessages.AddLemon));
        }
 void when_making_tea()
 {
     context["that is 210 degrees"] = () =>
     {
         before = () => tea = MakeTea(210);
         it["should be hot"] = () => tea.Taste().should_be("hot");
     };
     context["that is 90 degrees"] = () =>
     {
         before = () => tea = MakeTea(90);
         it["should be cold"] = () => tea.Taste().should_be("cold");
     };
 }
        static void Main(string[] args)
        {
            Tea tea = new Tea();
            Coffee coffee = new Coffee();
            TeaWithHook teaWithHook = new TeaWithHook();

            Console.WriteLine("Make tea:");
            tea.PrepareReceipe();
            Console.WriteLine();

            Console.WriteLine("Make coffee:");
            coffee.PrepareReceipe();
            Console.WriteLine();

            Console.WriteLine("Make tea with hook:");
            teaWithHook.PrepareReceipe();
            Console.ReadLine();
        }
Exemple #4
0
 public void DeactivateTea(Tea tea)
 {
     tea.IsActive = false;
     tea.Quantity = 0;
     UpdateTea(tea);
 }
Exemple #5
0
 protected TeaRecipeBuilder()
 {
     _tea = new Tea();
 }
        public void ComputesTeaPrice()
        {
            var tea = new Tea();

            Assert.Equal(1.50, tea.Price(), 3);
        }
 public void Create(Tea entity)
 {
     context.Set <Tea>().Add(entity);
     context.SaveChanges();
 }
Exemple #8
0
 public void Encrypt_Exception_Key_Empty()
 {
     Assert.Throws <ArgumentNullException>(() => Tea.Encrypt(new byte[] { 0 }, new uint[] { }));
 }
Exemple #9
0
 public void Decrypt_Exception_Value_Empty()
 {
     Assert.Throws <ArgumentNullException>(() => Tea.Decrypt(new byte[] { }, new uint[] { 0 }));
 }
Exemple #10
0
        public void PrepareTea()
        {
            var tea = new Tea();

            tea.Prepare();
        }
Exemple #11
0
 public TeaDecorator(Tea tea, float optionPrice)
 {
     this.tea    = tea;
     OptionPrice = optionPrice;
 }
Exemple #12
0
 public virtual void RemoveCartLine(Tea tea)
 {
     Cart.RemoveAll(c => c.Tea.Id == tea.Id);
 }
        static void Main(string[] args)
        {
            /* Лабораторная работа №7 */
            Tea person_1 = new Tea()
            {
                Green_Tea = 1,
                Black_Tea = 2,
                White_Tea = 3,
            };

            try
            {
                Circle figure_7 = new Circle
                {
                    Radius = 99,
                    Length = 2 * 3.14 * 6,
                };
            }
            catch (Exception e)
            { Console.WriteLine($"Ошибка: {e.Message}"); }
            finally
            {
                Console.WriteLine("Всё супер!");
            }


            try
            {
                Rectangle figure_8 = new Rectangle
                {
                    Length_Rectangle = 0,
                    Width_Rectangle  = "23",
                };
            }
            catch (Figure_Exception_1 ex_1)
            { Console.WriteLine($"Ошибка: {ex_1.Message}"); }


            try
            {
                Geometric_figure figure_9 = new Geometric_figure
                {
                    Type_Of_Figure = "Многоугольник",
                    Angle          = 23,
                    Square         = 18,
                };
            }
            catch (Figure_Exception_2 ex_2)
            {
                Console.WriteLine($"Ошибка: {ex_2.Message}");
            }
            finally
            {
                Console.WriteLine("Всё супер!");
            }


            Debug.Assert(person_1.Black_Tea != 2, "Чёрный чай есть");
            Debug.Assert(person_1.White_Tea == 3, "Белого чая нет");

            Console.ReadKey();
        }
Exemple #14
0
 public decimal GetCartLineSum(Tea tea)
 {
     return(Cart.Where(c => c.Tea.Id == tea.Id).Sum(c => c.Tea.Price * c.Quantity));
 }
Exemple #15
0
 public virtual OrderTea GetCartLineByTea(Tea tea)
 {
     return(Cart.Where(c => c.Tea.Id == tea.Id).FirstOrDefault());
 }
Exemple #16
0
        static void Main(string[] args)
        {
            Tea MyTea = new Tea();

            MyTea.PrepareRecipe();
        }
        //
        // GET: /StoreManager/Delete/5

        public ActionResult Delete(int id)
        {
            Tea tea = db.Teas.Find(id);

            return(View(tea));
        }
Exemple #18
0
    protected void ShowClassTable()
    {
        Session["HasShownTable"] = true;
        Table1.Rows.Clear();
        TableRow  head = new TableRow();
        TableCell t0   = new TableCell();
        TableCell t1   = new TableCell();

        t1.Text = "星期一";
        TableCell t2 = new TableCell();

        t2.Text = "星期二";
        TableCell t3 = new TableCell();

        t3.Text = "星期三";
        TableCell t4 = new TableCell();

        t4.Text = "星期四";
        TableCell t5 = new TableCell();

        t5.Text     = "星期五";
        t0.CssClass = "aspTableCell";
        t1.CssClass = "aspTableCell";
        t2.CssClass = "aspTableCell";
        t3.CssClass = "aspTableCell";
        t4.CssClass = "aspTableCell";
        t5.CssClass = "aspTableCell";

        head.Controls.Add(t0);
        head.Controls.Add(t1);
        head.Controls.Add(t2);
        head.Controls.Add(t3);
        head.Controls.Add(t4);
        head.Controls.Add(t5);
        head.CssClass = "aspTableRow1";
        Table1.Controls.Add(head);
        bool   hasTable        = true;
        string lessonTableName = "LessonTable" + DropDownList_Grade.SelectedValue;

        if (Cache[lessonTableName] == null)
        {
            hasTable = false;
            //return;
        }
        string dict_CourseNo_SubjectName_Name = "dict_CourseNo_SubjectName" + DropDownList_Grade.SelectedValue;

        if (Cache[dict_CourseNo_SubjectName_Name] == null)
        {
            hasTable = false;
            //return;
        }
        string dict_SubjectName_CourseNo_Name = "dict_SubjectName_CourseNo" + DropDownList_Grade.SelectedValue;

        if (Cache[dict_SubjectName_CourseNo_Name] == null)
        {
            hasTable = false;
            //return;
        }
        string dict_ClassName_ClassNo_Name = "dict_ClassName_ClassNo" + DropDownList_Grade.SelectedValue;

        if (Cache[dict_ClassName_ClassNo_Name] == null)
        {
            hasTable = false;
            //return;
        }

        //  else
        // {
        Dictionary <string, string> dict_CourseNo_SubjectName = null;
        Dictionary <string, string> dict_SubjectName_CourseNo = null;
        Dictionary <string, string> dict_ClassName_ClassNo    = null;

        Tea[,] Lessontable = null;
        Tea[] class_1 = null;
        if (hasTable)
        {
            if (DropDownList_class.Items.Count == 0)
            {
                return;
                //这一句是为了防止出现:选择某一个年级,由于没有班级,然后跳回有班级的年级之后无法显示课表
                //因为页面重载后,DropDownList_class的项都清空了,此时由于showTable()会在Page_load里面调用,而且
                //Cache里面存放了这几个映射和课表,所以会尝试显示课表,但是由于DropDownList_class的项是在后面
                //对年级切换的事件处理中才设定的,所以第一次执行Page_load会执行showTable函数,此时DropDownList_class
                //没有选项,所以出现异常!因此因为页面重载导致的showTable要判断这种情况
            }
            dict_CourseNo_SubjectName = (Dictionary <string, string>)Cache[dict_CourseNo_SubjectName_Name];
            dict_SubjectName_CourseNo = (Dictionary <string, string>)Cache[dict_SubjectName_CourseNo_Name];
            dict_ClassName_ClassNo    = (Dictionary <string, string>)Cache[dict_ClassName_ClassNo_Name];
            Lessontable = (Tea[, ])Cache[lessonTableName];
            class_1     = new Tea[Lessontable.GetLength(1) + 1];
            string className = DropDownList_class.SelectedValue.ToString().Substring(2);
            int    classInt;
            if (className.StartsWith("0"))
            {
                classInt = int.Parse(className.Substring(1));
            }
            else
            {
                classInt = int.Parse(className);
            }
            for (int t = 1; t <= 40; t++)//从1开始
            {
                class_1[t] = Lessontable[classInt, t];
            }
        }
        //Dictionary<string, string> dict_CourseNo_SubjectName = (Dictionary<string, string>)Cache[dict_CourseNo_SubjectName_Name];
        //Dictionary<string, string> dict_SubjectName_CourseNo = (Dictionary<string, string>)Cache[dict_SubjectName_CourseNo_Name];
        //Dictionary<string, string> dict_ClassName_ClassNo = (Dictionary<string, string>)Cache[dict_ClassName_ClassNo_Name];

        //Tea[]
        for (int lesson = 1; lesson <= 8; lesson++)
        {
            TableRow tablerow = new TableRow();
            tablerow.CssClass = "aspTableRow2";
            TableCell tc = new TableCell();
            tc.CssClass = "aspTableCell4";//第几节
            tc.Text     = "第" + lesson + "节";
            tablerow.Controls.Add(tc);
            for (int day = 1; day <= 5; day++)
            {
                TableCell cell = new TableCell();
                if (hasTable)
                {
                    MyButton button = new MyButton();
                    //  if (class_1[lesson + (day - 1) * 8] == null) {

                    // }
                    button.TeacherNo1   = class_1[lesson + (day - 1) * 8].id;//周四:day = 4,节次号为前三天的总次数加上这一天的节次号,3 * 8 + lesson+1
                    button.SubjectName1 = dict_CourseNo_SubjectName[class_1[lesson + (day - 1) * 8].cno];
                    //button.CourseNo1 = dict_SubjectName_CourseNo[button.SubjectName1];
                    button.CourseNo1       = class_1[lesson + (day - 1) * 8].cno;
                    button.Class_id        = dict_ClassName_ClassNo[DropDownList_class.SelectedItem.Text];
                    button.Day             = day;//day = 1,代表星期一,j = 1代表星期二
                    button.Lesson          = lesson;
                    button.IDForThisButton = "Button_" + DropDownList_Grade.SelectedValue + DropDownList_class.SelectedValue + day + lesson;
                    //一个button的ID号是这样组成的:年级 + 班级号 + 星期几 + 第几节 (如初一1603班周三第1节:Button_1160331)
                    //button.Text = button.SubjectName1 + "\n\r" + "aaa";
                    button.Text = button.SubjectName1;
                    if (Session[button.IDForThisButton] == null)//初始化时设定每一个按钮的颜色
                    {
                        //     Session[button.IDForThisButton] = "courseButton";
                        Session[button.IDForThisButton] = "aspTableCell";
                    }
                    button.Click += new EventHandler(Button_ShowOrChange);
                    //button.CssClass = Session[button.IDForThisButton].ToString();//如果刷新之前已经有记录,那么直接用之前的样式
                    button.CssClass = "courseButton";
                    //  button.CssClass = (string)Session[button.IDForThisButton];
                    //cell.CssClass = "aspTableCell";//具体安排
                    cell.CssClass = (string)Session[button.IDForThisButton];
                    cell.Controls.Add(button);
                }
                else
                {
                    cell.CssClass = "aspTableCell";
                }
                tablerow.Controls.Add(cell);
            }
            Table1.Controls.Add(tablerow);
        }
        // }
    }
        static void Main(string[] args)
        {
            Geometric_figure figure_1 = new Geometric_figure
            {
                Type_Of_Figure = "Квадрат",
                Angle_Quantity = 4,
                Square_figure  = 90,
            };

            Console.WriteLine("Фигура №1");
            figure_1.GetInfo();

            Circle figure_2 = new Circle
            {
                Radius_Circle = 4,
                Length_Circle = 2 * 3.14 * 4,
            };

            Console.WriteLine("Фигура №2");
            figure_2.GetInfo();

            Rectangle figure_3 = new Rectangle
            {
                Length_Rectangle = 4,
                Width_Rectangle  = "15",
            };

            Console.WriteLine("Фигура №3");
            figure_3.GetInfo();

            Console.WriteLine(figure_3.ToString());
            Console.WriteLine($"Фигура №1 и фигура №3 равны? -> {ReferenceEquals(figure_1, figure_3)}");
            Console.WriteLine($"Хэш-код: {figure_3.GetHashCode()}");
            Console.WriteLine(figure_1.Smile());

            Button button_1 = new Button {
            };

            Console.WriteLine(button_1.Smile());


            if (figure_2 is Rectangle)
            {
                Console.WriteLine("Да, фигура является прямоугольником");
            }
            else
            {
                Console.WriteLine("Это не прямоугольник");
            }

            Circle figure_4 = figure_2 as Circle;

            if (figure_4 == null)
            {
                Console.WriteLine("Неудачное преобразование");
            }
            else
            {
                Console.WriteLine("Преобразование выполнено успешно!");
            }
            Console.ReadKey();


            /* Лабораторная работа №6 */
            Console.WriteLine("\n\nЛабораторная работа №6");
            Cup water; // Перечисление

            water = Cup.Violet_Cup;
            Console.WriteLine(water);
            Console.WriteLine((int)water);
            Console.WriteLine();

            Tea person_1 = new Tea() // Структура
            {
                Green_Tea = 42,
                Black_Tea = 38,
                White_Tea = 20,
            };

            person_1.Created_Tea();
            Work_program program_1 = new Work_program(); // Частичный класс

            Console.WriteLine("Не могу найти решения для этой программы");
            program_1.Work();


            UI figure_5 = new UI() // Класс-контейнер
            {
                Type_Of_Figure = "Круг",
                Angle_Quantity = 0,
                Square_figure  = 26,
            };

            figure_5.Massiv();

            UI figure_6 = new UI()
            {
                Type_Of_Figure = "Квадрат",
                Angle_Quantity = 4,
                Square_figure  = 25,
            };

            figure_6.Massiv();

            List <UI> Massiv_1 = new List <UI> {
                figure_5, figure_6
            };

            figure_5.Read_Massiv(Massiv_1);
            Console.WriteLine("Общая площадь всех фигур UI: " + Controller.Squre_Number(Massiv_1) + " м^2 \n");
            figure_5.Delete_Massiv(Massiv_1, 0);
            Console.WriteLine("Общая площадь всех фигур UI: " + Controller.Squre_Number(Massiv_1) + " м^2 \n");
            Console.ReadKey();
        }
Exemple #20
0
 void MakeTea(int temperature)
 {
     tea = new Tea(temperature);
 }
Exemple #21
0
        public void Encrypt_Valid(byte[] value, uint[] key, byte[] expected)
        {
            var result = Tea.Encrypt(value, key);

            Assert.True(result.SequenceEqual(expected));
        }
Exemple #22
0
 public void Decrypt_Exception_Key_Length()
 {
     Assert.Throws <ArgumentNullException>(() => Tea.Decrypt(new byte[] { 0 }, new uint[] { 0, 1, 2 }));
 }
Exemple #23
0
        public void Decrypt_Valid(byte[] value, uint[] key, byte[] encrypted)
        {
            var result = Tea.Decrypt(encrypted, key);

            Assert.True(result.SequenceEqual(value));
        }
Exemple #24
0
        public static void Demo()
        {
            var coffee1    = new Coffee();
            var coffee2    = new Coffee();
            var tea1       = new Tea();
            var tea2       = new Tea();
            var tea3       = new Tea();
            var arrayList1 = new ArrayList();

            arrayList1.Add(coffee1);
            arrayList1.Add(coffee2);
            arrayList1.Add(tea1);
            arrayList1.Add(tea2);
            arrayList1.Add(tea3);
            try
            {
                arrayList1.Sort();
            }
            catch
            {
                Console.WriteLine("Error in sort arrayList1");
            }

            foreach (object o in arrayList1)
            {
                Console.WriteLine($"{o} type is {o.GetType()}");
            }

            var arrayList2 = new List <Coffee>();

            Console.WriteLine("");
            try
            {
                arrayList2.Add(coffee1);
                arrayList2.Add(coffee2);
                //arrayList2.Add(tea1);
                //arrayList2.Add(tea2);
                //arrayList2.Add(tea3);
            }
            catch
            {
                Console.WriteLine("Error in adding all elements");
            }

            foreach (object o in arrayList2)
            {
                Console.WriteLine($"{o} type is {o.GetType()}");
            }
            Console.WriteLine("");
            int number1 = 1;

            arrayList1.Add(number1);
            int number2 = (int)arrayList1[arrayList1.Count - 1];

            foreach (object o in arrayList1)
            {
                Console.WriteLine($"{o} type is {o.GetType()}");
            }
            Console.WriteLine("");

            var genericList2 = new List <Int32>();

            genericList2.Add(number1);
            int number3 = genericList2[0];

            foreach (object o in genericList2)
            {
                Console.WriteLine($"{o} type is {o.GetType()}");
            }
            Console.WriteLine("");
        }
Exemple #25
0
 public void Decrypt_Exception_Value_Null()
 {
     Assert.Throws <ArgumentNullException>(() => Tea.Decrypt(null, new uint[] { 0 }));
 }
Exemple #26
0
    protected void Button_SubmitSchedule_Click(object sender, EventArgs e)
    {
        if (Cache["auto"] == null)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('请先生成课表。')", true);
            //Response.Write("<script>alert('请先生成课表。')</script>");
            return;
        }
        string lessonTableName = "LessonTable" + DropDownList_Grade.SelectedValue;

        if (Cache[lessonTableName] == null)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('请先生成课表。')", true);
            return;
        }
        string dict_CourseNo_SubjectName_Name = "dict_CourseNo_SubjectName" + DropDownList_Grade.SelectedValue;

        if (Cache[dict_CourseNo_SubjectName_Name] == null)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('请先生成课表。')", true);
            return;
        }
        string dict_SubjectName_CourseNo_Name = "dict_SubjectName_CourseNo" + DropDownList_Grade.SelectedValue;

        if (Cache[dict_SubjectName_CourseNo_Name] == null)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('请先生成课表。')", true);
            return;
        }
        string dict_ClassName_ClassNo_Name = "dict_ClassName_ClassNo" + DropDownList_Grade.SelectedValue;

        if (Cache[dict_ClassName_ClassNo_Name] == null)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('请先生成课表。')", true);
            return;
        }

        Dictionary <string, string> dict_SubjectName_CourseNo = (Dictionary <string, string>)Cache[dict_SubjectName_CourseNo_Name];
        Dictionary <string, string> dict_CourseNo_SubjectName = (Dictionary <string, string>)Cache[dict_CourseNo_SubjectName_Name];
        Dictionary <string, string> dict_ClassName_ClassNo    = (Dictionary <string, string>)Cache[dict_ClassName_ClassNo_Name];

        Tea[,] Lessontable = (Tea[, ])Cache[lessonTableName];
        //以上已获得某一个年级的全部课表,老师号-科目名映射,学科号-科目名映射,班级名和班级号映射

        /*
         *   create table gcgLectureForm(--授课安排表
         *          LectureNo char(7) primary key,--授课安排编号
         *          SemesterNo char(6),--学期号,蕴含年份和上下学期信息
         *          TeacherNo char(8),--教师工号
         *          CourseNo char(3) foreign key references gcgcourse(CourseNo),--学科编号
         *          ClassNo char(4)--班级编号
         *  )
         *  create table gcgLesson(--课表
         *          LectureNo char(7) foreign key references gcgLectureForm(LectureNo),--授课安排编号
         *          --ClassRoomNo char(*)
         *          Timeid char(4) foreign key references gcgSchedule(Timeid),--时间段编号
         *          primary key(LectureNo,Timeid)--表级主码
         *  )
         */
        string          sql_forSemester = "select MAX(SemesterNo) from gcgLectureForm ";
        DBManipulation  dbm             = new DBManipulation();
        object          o          = dbm.ExecuteScalar(sql_forSemester, null);
        string          semesterNo = o.ToString();
        string          grade      = DropDownList_Grade.SelectedValue;
        string          sql_deleteTheSameSemesterRecord = "delete from gcgLesson where LectureNo in ( select LectureNo from gcgLectureForm,temp_class where gcgLectureForm.ClassNo = temp_class.class_id and class_grade = @Grade and SemesterNo = @SemesterNo)";
        ParameterStruct p_grade = new ParameterStruct("@Grade", grade);
        ParameterStruct p_seme  = new ParameterStruct("@SemesterNo", semesterNo);
        ArrayList       palist  = new ArrayList();

        palist.Add(p_grade);
        palist.Add(p_seme);

        dbm.ExecuteNonQuery(sql_deleteTheSameSemesterRecord, palist);

        /*string sql_MappingClassNameAndClassNo =
         * "    select class_name,class_id
         *      from temp_class,(
         *          select distinct ClassNo
         *              from gcgLectureForm
         *                  where SemesterNo = (
         *                      select MAX(SemesterNo)
         *                          from gcgLectureForm)) AS temp
         *      where class_id = ClassNo and class_grade = '" + DropDownList_Grade.SelectedValue + "'";
         */
        string        sql_forClassNo = "select class_id from temp_class,(select distinct ClassNo from gcgLectureForm where SemesterNo = (select MAX(SemesterNo) from gcgLectureForm)) AS temp where class_id = ClassNo and class_grade = '" + DropDownList_Grade.SelectedValue + "'";
        ArrayList     classlist      = new ArrayList();
        SqlDataReader dr             = dbm.ExecuteQueryOnLine(sql_forClassNo, null);

        while (dr.Read())
        {
            classlist.Add(dr.GetString(0));
        }
        dr.Close();
        for (int i = 0; i < classlist.Count; i++)
        {//一个一个班的写入
            //[,]Lessontable一行就存放了一个班的所有记录
            Tea[]    classTable  = new Tea[Lessontable.GetLength(1) + 1];
            string[] courseTable = new string[Lessontable.GetLength(1) + 1];
            for (int t = 0; t < 40; t++)
            {
                classTable[t] = Lessontable[i + 1, t + 1];               //取到某一个班40节课的所有教师工号
                string subjectname = dict_CourseNo_SubjectName[classTable[t].cno];
                courseTable[t] = dict_SubjectName_CourseNo[subjectname]; //取到这四十节课的学科号
            }
            for (int t = 0; t < 40; t++)
            {
                //classlist[i-1]就是对应的班级号
                string          sql_forLectureID = "select LectureNo from gcgLectureForm where SemesterNo = @SemesterNo and ClassNo = @ClassNo and CourseNo = @CourseNo";
                ParameterStruct p_semester       = new ParameterStruct("@SemesterNo", semesterNo);
                ParameterStruct p_classNo        = new ParameterStruct("@ClassNo", (string)classlist[i]);//第i个班级的班级号
                ParameterStruct p_courseNo       = new ParameterStruct("@CourseNo", courseTable[t]);
                ArrayList       plist            = new ArrayList();
                plist.Add(p_semester); plist.Add(p_classNo); plist.Add(p_courseNo);
                Object lectureID = dbm.ExecuteScalar(sql_forLectureID, plist);
                //string Timeid1 = grade + week + "0" + "1";
                string Time_part1 = DropDownList_Grade.SelectedValue;
                int    week       = 0;
                string Time_part3;
                int    temp = t + 1;
                if (temp % 8 == 0)
                {
                    week       = temp / 8;
                    Time_part3 = "0" + 8;
                }
                else
                {
                    week       = temp / 8 + 1;
                    Time_part3 = "0" + (temp - (week - 1) * 8);
                }
                string Time_part2 = week + "";

                // string Time_part3 = "0" + (t - (t / 8) * 8);

                string          sql_insert  = "insert into gcgLesson values(@lectureID,@TimeID)";
                ParameterStruct p_LectureID = new ParameterStruct("@lectureID", lectureID.ToString());
                ParameterStruct p_timeID    = new ParameterStruct("@TimeID", Time_part1 + Time_part2 + Time_part3);//第i个班级的班级号
                ArrayList       plist1      = new ArrayList();
                plist1.Add(p_LectureID);
                plist1.Add(p_timeID);
                dbm.ExecuteNonQuery(sql_insert, plist1);
            }
        }
        dbm.Close();
        System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('课表已保存!')", true);
    }
Exemple #27
0
 public void Decrypt_Exception_Key_Null()
 {
     Assert.Throws <ArgumentNullException>(() => Tea.Decrypt(new byte[] { 0 }, null));
 }
Exemple #28
0
        static async Task Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("Make Breakfast using differnt levels asynchronicity");
                Console.WriteLine("Enter 1 for sync");
                Console.WriteLine("Enter 2 for sync over async");
                Console.WriteLine("Enter 3 for async");

                var line = Console.ReadLine() ?? "3";

                DateTime start;
                TimeSpan difference;

                switch (line)
                {
                case "1":

                    WriteMessage("sync selected");
                    start = DateTime.UtcNow;
                    Kettle hotwater = BoilKettle();
                    Egg    eggs     = FryEgg(2);
                    Bacon  bacon    = FryBacon(3);
                    Toast  toast    = MakeToast(3);
                    ButterToast(toast);
                    Tea tea = MakeTea(hotwater);
                    WriteMessage("Breakfast is ready!");
                    difference = DateTime.UtcNow.Subtract(start);
                    WriteMessage($"Time taken {difference.TotalSeconds} (seconds)");
                    break;

                case "2":
                    WriteMessage("sync over async");
                    start = DateTime.UtcNow;
                    Task <Kettle> hotwaterAsync = BoilKettleAsync();
                    Task <Egg>    eggsaAsync    = FryEggAsync(2);
                    Task <Bacon>  baconAsync    = FryBaconAsync(3);
                    Task <Toast>  toastAsync    = MakeToastAsync(3);

                    /*
                     * We are calling ButterToast synchronously
                     * i.e we have to await the result of toastAsync
                     * to pass it ButterToast affectlying making the process
                     * syncronously
                     */
                    WriteMessage("Awaiting Toast");
                    var toastready = await toastAsync;
                    ButterToast(toastready);

                    /*
                     * We are calling MakeTea synchronously
                     * i.e we have to await the result of hotwaterAsync
                     * to pass it MakeTea affectlying making the process
                     * syncronously
                     */
                    WriteMessage("Awaiting Kettle");
                    var hotwaterready = await hotwaterAsync;
                    MakeTea(hotwaterready);

                    WriteMessage("Awaiting Breakfast");
                    await Task.WhenAll(hotwaterAsync, eggsaAsync, baconAsync, toastAsync);

                    WriteMessage("Breakfast is ready!");
                    difference = DateTime.UtcNow.Subtract(start);
                    WriteMessage($"Time taken {difference.TotalSeconds} (seconds)");
                    break;

                case "3":

                    WriteMessage("async");
                    start = DateTime.UtcNow;
                    Task <Kettle> hotwaterFullAsync = BoilKettleAsync();
                    Task <Egg>    eggsFullAsync     = FryEggAsync(2);
                    Task <Bacon>  baconFullAsync    = FryBaconAsync(3);
                    Task <Toast>  toastFullAsync    = MakeToastAsync(3);

                    /*
                     * We pass the Task returned from MakeToastAsync to ToastWithButter so the thread can continue
                     * processing. ToastWithButter awaits the Task.
                     */
                    toastFullAsync = ToastWithButter(toastFullAsync);

                    /*
                     * We pass the Task returned from hotwaterFullAsync to TeaWithHotWater so the thread can continue
                     * processing. TeaWithHotWater awaits the Task.
                     */
                    Task <Tea> teaFullAsync = TeaWithHotWater(hotwaterFullAsync);
                    WriteMessage("Awaiting Breakfast");
                    await Task.WhenAll(hotwaterFullAsync, eggsFullAsync, baconFullAsync, toastFullAsync, teaFullAsync);

                    WriteMessage("Breakfast is ready!");
                    difference = DateTime.UtcNow.Subtract(start);
                    WriteMessage($"Time taken {difference.TotalSeconds} (seconds)");
                    break;
                }
            }
        }
        /// <summary>
        /// 废物的小小梦想
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void uiSymbolButton_tea_Click(object sender, EventArgs e)
        {
            Tea tea = new Tea();

            tea.ShowDialog();
        }
        public void OrderTeaWithoutSugar()
        {
            Order order = new Tea();

            order.TranslateOrder().Should().Be("T::");
        }
Exemple #31
0
 public void AddTea(Tea tea)
 {
     tea.IsActive = true;
     _context.Teas.Add(tea);
 }
        public void OrderTeaWith2Sugar()
        {
            Order order = new Tea(2);

            order.TranslateOrder().Should().Be("T:2:0");
        }
 //helper methods do not have underscores
 void MakeTea(int temperature)
 {
     tea = new Tea(temperature);
 }
        //
        // GET: /StoreManager/Details/5

        public ViewResult Details(int id)
        {
            Tea tea = db.Teas.Find(id);

            return(View(tea));
        }