Beispiel #1
0
        private void SimpleButton62_Click(object sender, System.EventArgs e)
        {
            if (schedulerControl1.SelectedAppointments.Count > 0)
            {
                if (schedulerControl1.SelectedAppointments.Count == 1)
                {
                    DataRowView rowView = (DataRowView)schedulerControl1.SelectedAppointments[0].GetRow(schedulerControl1.Storage);
                    DataRow     row     = rowView.Row;

                    DialogResult result = MessageBox.Show(this, "Do you really want to delete the record with Member ID = '" + row["strMembershipID"].ToString() + "' and Service Code= '" + row["strServiceCode"].ToString() + "'",
                                                          "Delete?", MessageBoxButtons.YesNo);

                    if (result == DialogResult.Yes)
                    {
                        try
                        {
                            if (mySpaBooking.DeleteBooking(ACMS.Convert.ToInt32(row["nSessionID"])))
                            {
                                MessageBox.Show(this, "Record is successful deleted");
                            }
                            Init(true);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
                else
                {
                    DialogResult result = MessageBox.Show(this, "You have selected more than 1 record, are you really want to delete it?",
                                                          "Delete?", MessageBoxButtons.YesNo);

                    if (result == DialogResult.Yes)
                    {
                        try
                        {
                            foreach (DevExpress.XtraScheduler.Appointment app in
                                     schedulerControl1.SelectedAppointments)
                            {
                                DataRowView rowView = (DataRowView)app.GetRow(schedulerControl1.Storage);
                                DataRow     row     = rowView.Row;

                                mySpaBooking.DeleteBooking(ACMS.Convert.ToInt32(row["nSessionID"]));
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                        finally
                        {
                            Init(true);
                        }
                    }
                }
            }
        }