Пример #1
0
        private void lblUpdateServingTime_Click(object sender, EventArgs e)
        {
            if (!(sender is Button && (Button)sender == btnSetServingTime))
            {
                using (var form = new UpdateServingTime(scheduleID))
                {
                    form.ShowDialog();

                    if (scheduleID != form.scheduleID)
                    {
                        scheduleID = form.scheduleID;
                    }
                };
            }

            if (scheduleID == null)
            {
                return;
            }

            dgvScheduleMealSet.ColumnCount = 2;
            dgvScheduleMealSet.Columns[0].Name = "Mã suất";
            dgvScheduleMealSet.Columns[1].Name = "Tên suất";

            dgvScheduleMealSet.Columns[0].Width = 100;
            dgvScheduleMealSet.Columns[1].Width = 260;

            int labelChar = 65;

            try
            {
                MealSetInScheduleDetailTableAdapter mealSetInScheduleDetailTA = new MealSetInScheduleDetailTableAdapter();
                DataTable mealSetInScheduleDetailDT = mealSetInScheduleDetailTA.GetDataByScheduleID(scheduleID.Value);
                DataTable scheduleDT = new ScheduleTableAdapter().GetDataByID(scheduleID.Value);

                if (scheduleDT.Rows.Count != 0)
                {
                    lblDate.Text = scheduleDT.Rows[0].Field<DateTime>("Date").ToString("dd/MM/yyyy");

                    string servingTimeString = new ServingTimeTableAdapter().GetStringByID(scheduleDT.Rows[0].Field<int>("ServingTimeID"));
                    lblServingTime.Text = servingTimeString;
                }

                dgvScheduleMealSet.Rows.Clear();

                usingMealSetList = new List<KeyValuePair<int, string>>();

                if (mealSetInScheduleDetailDT.Rows.Count != 0)
                {
                    usingMealSetList.Add(new KeyValuePair<int, string>(0, "<<Không có>>"));

                    foreach (DataRow row in mealSetInScheduleDetailDT.Rows)
                    {
                        string name = row.Field<string>("Name");
                        int scheduleMealSetDetailID = row.Field<int>("ScheduleMealSetDetailID");
                        bool canEatMore = row.Field<bool>("CanEatMore");
                        string displayName = ((char)labelChar).ToString() + ": " + name + " " + (canEatMore ? "(Có ăn thêm)" : "");

                        string[] rowValue = new string[] {
                            ((char)labelChar).ToString(),
                            name
                        };
                        dgvScheduleMealSet.Rows.Add(rowValue);

                        usingMealSetList.Add(new KeyValuePair<int, string>(scheduleMealSetDetailID, displayName));

                        labelChar++;
                    }
                }

                RefreshDropDownList();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi khi lấy dữ liệu.");
                Log.ErrorLog(ex.Message);
            }
        }
Пример #2
0
        private void btnSetServingTime_Click(object sender, EventArgs e)
        {
            using (var form = new UpdateServingTime(scheduleID))
            {
                form.ShowDialog();

                if (scheduleID != form.scheduleID)
                {
                    scheduleID = form.scheduleID;
                }
            };

            if (scheduleID == null)
            {
                return;
            }

            lblUpdateServingTime_Click(btnSetServingTime, e);
            pnlHiddenEatingInfo.Dispose();
        }