コード例 #1
0
        //添加课程信息
        private void AddSchedule(Entity.Schedule schedule)
        {
            Border border = new Border();

            border.Background = ColorUtils.GetSolidColorBrush(schedule.colorCode);
            border.Tag        = schedule;
            border.Tapped    += new TappedEventHandler(ShowScheduleDetailInfo);
            TextBlock textBlock = new TextBlock();

            textBlock.TextTrimming        = TextTrimming.CharacterEllipsis;
            textBlock.TextWrapping        = TextWrapping.Wrap;
            textBlock.TextAlignment       = TextAlignment.Center;
            textBlock.HorizontalAlignment = HorizontalAlignment.Center;
            textBlock.VerticalAlignment   = VerticalAlignment.Center;
            textBlock.FontSize            = 13;
            textBlock.Foreground          = new SolidColorBrush(Colors.White);
            textBlock.Text = schedule.scheduleName + "@" + schedule.scheduleLocation;
            border.Child   = textBlock;
            Grid.Children.Add(border);
            Grid.SetRow(border, schedule.row.Value + 2);
            Grid.SetColumn(border, schedule.column.Value + 1);
            Grid.SetRowSpan(border, schedule.scheduleLength.Value);
            elementList.Add(border);
            scheduleList.Add(schedule);
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int sid = Convert.ToInt32(Request.QueryString["id"]);
                Schedule Schedule=new Entity.Schedule();
                List<Department> Departments=new List<Department> ();
                List<User> Users = new List<User>();
                using (Dal.DB db = new Dal.DB())
                {
                    Departments=(from d in db.Departments select d).ToList();
                    Schedule = db.Schedules.Find(sid);
                    Users = db.Users.Where<User>(u => u.DepartmentID == Schedule.DepartmentID).ToList();
                    txtEditScheduleName.Text = Schedule.Title;
                    txtEditScheduleContent.Text = Schedule.Content;

                    foreach (Department Department in Departments)
                    {
                        ddlEditScheduleDepartment.Items.Add(Department.Title);
                        ddlEditScheduleDepartment.Items.FindByText(Department.Title).Value = Department.ID.ToString();
                    }
                    ddlEditScheduleDepartment.SelectedValue = Schedule.DepartmentID.ToString();

                    foreach (User User in Users)
                    {
                        ddlEditScheduleToUser.Items.Add(User.Username);
                        ddlEditScheduleToUser.Items.FindByText(User.Username).Value = User.ID.ToString();

                    }
                    ddlEditScheduleToUser.SelectedValue = Schedule.ToUserID.ToString();

                }
            }
        }
コード例 #3
0
        //显示课程表详细信息
        private async void ShowScheduleDetailInfo(object sender, TappedRoutedEventArgs e)
        {
            Entity.Schedule schedule      = (sender as Border).Tag as Entity.Schedule;
            StringBuilder   stringBuilder = new StringBuilder();

            stringBuilder.Append("课程类型:" + schedule.scheduleType + "\n");
            stringBuilder.Append("上课节数:" + schedule.scheduleLesson + "\n");
            stringBuilder.Append("上课周数:" + "第" + schedule.minScheduleWeek + "周至第" + schedule.maxScheduleWeek + "周\n");
            stringBuilder.Append("任课教师:" + schedule.scheduleTeacher + "\n");
            stringBuilder.Append("上课地点:" + schedule.scheduleLocation + "\n");
            var messageDialog = new MessageDialog(stringBuilder.ToString())
            {
                Title = schedule.scheduleName
            };

            messageDialog.Commands.Add(new UICommand("确定"));
            await messageDialog.ShowAsync();
        }
コード例 #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("fdsf");
            //First we have to insert data into route table and then into the schedule table
            this.RouteFill();

            Entity.Schedule schedule = new Entity.Schedule();
            try
            {
                schedule.ScheduleId = ScheduleRepo.GetId();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }

            schedule.DeptTime    = this.dtpDeparture.Text;
            schedule.ArrivalTime = this.dtpArrival.Text;
            schedule.RouteId     = this.Route.RouteId; //In Schedule table route_id is a foreign key.

            try
            {
                RouteRepo.Insert(this.Route);  //inserting into the route table
                ScheduleRepo.Insert(schedule); //inserting into schedule table

                MessageBox.Show("Created Successfully");

                //After inserting data the route home page will be redirected
                controlRoute route = new controlRoute();
                MainControl.showControl(route, frmAdminDashboard.ActiveForm);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Please Select A Bus No", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #5
0
ファイル: Database.cs プロジェクト: tuminskiy/TimeTableEditor
 public abstract bool Update(Entity.Schedule item);
コード例 #6
0
ファイル: Database.cs プロジェクト: tuminskiy/TimeTableEditor
 public abstract bool Delete(Entity.Schedule item);
コード例 #7
0
ファイル: Database.cs プロジェクト: tuminskiy/TimeTableEditor
 public abstract uint Insert(Entity.Schedule item);
コード例 #8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool idExist;
            bool checkIfBusExistSignal;

            try
            {
                idExist = RouteRepo.SearchRouteId(this.disableBusIdText.Text);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                throw;
            }
            if (idExist) //For Update purpose
            {
                if (!this.RouteFill())
                {
                    return;
                }
                else
                {
                    Route.Status = this.routeStatus.Text;

                    //Following line used to store Route information when a row from data grid view is double clicked.
                    Route singleRouteInfo = RouteRepo.SingleRouteInfo(this.disableBusIdText.Text);

                    //Following line gets the route_id.
                    string secondRouteId = RouteRepo.CheckIfTwoRoutesExist(singleRouteInfo);

                    try
                    {
                        if (secondRouteId != null)//if two routes exist, will get a route_id, else null
                        {
                            //So there is two routes, and now checking if the bus exist to any different route if we select a different
                            //bus and click on save button.
                            checkIfBusExistSignal = RouteRepo.CheckIfBusExistInTwoRoutesForUpdate(this.cmbBus.Text, this.disableBusIdText.Text, secondRouteId);
                        }
                        else
                        {
                            //So there is one route, and now checking if the bus exist to any different route if we select a different
                            //bus and click on save button.
                            checkIfBusExistSignal = RouteRepo.CheckIfBusExistInRouteForUpdate(this.cmbBus.Text, this.disableBusIdText.Text);
                        }
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show("Something went wrong when check bus exist or not");
                        throw;
                    }

                    //we will check if the bus number exist for particular route_id in route table.
                    //If exist we will not update, else will update.
                    if (checkIfBusExistSignal == false)
                    {
                        try
                        {
                            bool updateRouteSignal = RouteRepo.Update(this.Route);

                            Entity.Schedule schedule = new Entity.Schedule();
                            schedule.ScheduleId  = this.invisibleScheduleIdText.Text;
                            schedule.DeptTime    = this.dateTimePicker1.Text;
                            schedule.ArrivalTime = this.dateTimePicker2.Text;
                            schedule.RouteId     = this.disableBusIdText.Text;

                            bool updateScheduleSignal = ScheduleRepo.Update(schedule);
                            if (secondRouteId != null)
                            {
                                //MessageBox.Show("not null");
                                bool updateSecondRouteSignal = RouteRepo.UpdateSecondRoute(this.Route, secondRouteId);
                            }
                            if (updateRouteSignal && updateScheduleSignal)
                            {
                                MessageBox.Show("Route Updated Successuflly!!");

                                //Once the save button is clicked for edit, new Id, as primary key, will be generated for the route table.
                                this.disableBusIdText.Text = RouteRepo.GetId();
                                this.ClearRouteInput();
                                this.FillRouteDataGridView();
                            }
                        }
                        catch (Exception exception)
                        {
                            Console.WriteLine("Something went wrong in Update!\n" + exception);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Bus Number already Exists in different Route!\nCannot Update. Get a new Bus!");
                    }
                }
            }
            if (!idExist) //for insert purpose
            {
                if (!this.RouteFill())
                {
                    return;
                }
                else if (this.RouteFill())
                {
                    try
                    {
                        checkIfBusExistSignal = RouteRepo.CheckIfBusExistInRoute(this.cmbBus.Text);
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show("Something went wrong when check bus exist or not");
                        throw;
                    }

                    //we will check if the bus number exist in route table. If exist we will not insert, else will insert.
                    if (!checkIfBusExistSignal)//if return false we will insert, else not
                    {
                        bool insertSignal;
                        try
                        {
                            insertSignal = RouteRepo.Insert(this.Route); //inserting into the route table
                        }
                        catch (Exception exception)
                        {
                            MessageBox.Show("Something went wrong when inserting route");
                            throw;
                        }

                        //First we have to insert data into route table and then into the schedule table
                        Entity.Schedule schedule = new Entity.Schedule();
                        try
                        {
                            schedule.ScheduleId = ScheduleRepo.GetId();
                        }
                        catch (Exception exception)
                        {
                            MessageBox.Show("Something went wrong when getting schedule Id");
                        }

                        schedule.DeptTime    = this.dateTimePicker1.Text;
                        schedule.ArrivalTime = this.dateTimePicker2.Text;
                        schedule.RouteId     = this.disableBusIdText.Text; //In Schedule table route_id is a foreign key.
                        //this.Route.ScheduleId = schedule.ScheduleId; //In Route table schedule_id is a foreign key.

                        bool insertSignalSchedule;
                        try
                        {
                            insertSignalSchedule = ScheduleRepo.Insert(schedule); //inserting into schedule table
                        }
                        catch (Exception exception)
                        {
                            MessageBox.Show("Something went wrong when inserting schedule");
                            throw;
                        }

                        if (insertSignal && insertSignalSchedule)
                        {
                            MessageBox.Show("Route Created Successuflly!!");

                            //Once the save button is clicked, new Id, as primary key, will be generated for the route table.
                            try
                            {
                                this.disableBusIdText.Text = RouteRepo.GetId();
                            }
                            catch (Exception exception)
                            {
                                Console.WriteLine("Something went wrong in Create!\n" + exception);
                            }

                            this.ClearRouteInput();
                            this.FillRouteDataGridView();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Bus Number already Exists in different Route!\nCannot Insert. Get a new Bus!");
                    }
                }
            }
        }