예제 #1
0
        public Form1(int EmployeeID)
        {
            InitializeComponent();
            Turno.SetFirsUsage(DateTime.Now);
            Recordatorio.resetReminders();
            WindowState = FormWindowState.Maximized;
            timer();
            HourLbl.Visible    = true;
            MinutesLbl.Visible = true;
            Daylbl.Visible     = true;
            DateLbl.Visible    = true;
            employee           = new Empleado(EmployeeID);
            displayHideTabs();

            menu = new ContextMenu();
            menu.MenuItems.Add(new MenuItem("Abrir en nueva ventana"));
            menu.MenuItems[0].Click += new EventHandler(contextMenuClicked);

            VentasButton.ContextMenu   = menu;
            ProductsButton.ContextMenu = menu;

            threadID = Thread.CurrentThread.ManagedThreadId;

            //ProductsButton.ContextMenu.MenuItems[0].Click += new EventHandler(contextMenuClicked);


            //checking for unfinished sells

            /*  DataTable unfinishedSells = Venta.getUnfinishedSalesIDs();
             * foreach (DataRow row in unfinishedSells.Rows)
             * {
             *    Panel_Ventas panel = new Panel_Ventas(employee.ID, FormWindowState.Maximized, row);
             *    panel.Show();
             * }*/
        }
        private void fillReminder(Recordatorio reminder)
        {
            int minute1 = this.StartTimeCombo.SelectedIndex % 2 != 0 ? 30 : 0;

            this.date          = this.dateTimePicker.Value;
            reminder.StartTime = new DateTime(this.date.Year, this.date.Month, this.date.Day, this.StartTimeCombo.SelectedIndex / 2, minute1, 0);
            int minute2 = int.Parse(this.EndTimeCombo.Text.Substring(this.EndTimeCombo.Text.IndexOf(':') + 1, 2));
            int hour    = int.Parse(this.EndTimeCombo.Text.Substring(0, this.EndTimeCombo.Text.IndexOf(':')));

            if (this.EndTimeCombo.Text.IndexOf("P.M.") > 0)
            {
                if (hour != 12)
                {
                    hour += 12;
                }
                else if (hour == 24)
                {
                    hour = 0;
                }
            }
            else if (hour == 12)
            {
                hour = 0;
            }
            reminder.EndTime = new DateTime(this.date.Year, this.date.Month, this.date.Day, hour, minute2, 0);
            if (reminder.EndTime.Hour == 0 && reminder.EndTime.Minute == 0)
            {
                reminder.EndTime = reminder.EndTime.AddDays(1.0);
            }
            reminder.RepeatingDays = this.repetingDays;
            reminder.Message       = this.EventNameTxt.Text;
            reminder.RepeatingDays = this.repetingDays;
            reminder.Message       = this.EventNameTxt.Text;
            reminder.Erasable      = this.CanErase;
        }
 private void AddReminderToDataBase()
 {
     if (this.reminderID == -1)
     {
         Recordatorio reminder = new Recordatorio();
         reminder.ID_Supplier = this.SupplierID;
         this.fillReminder(reminder);
         try
         {
             reminder.addReminder();
             this.DialogResult = DialogResult.OK;
             this.Close();
         }
         catch (Exception ex)
         {
             int num = (int)MessageBox.Show(ex.ToString());
         }
     }
     else
     {
         Recordatorio reminder = new Recordatorio();
         reminder.ID_Supplier = this.SupplierID;
         reminder.ID          = this.reminderID;
         this.fillReminder(reminder);
         try
         {
             reminder.UpdateReminder();
             this.DialogResult = DialogResult.OK;
             if (!this.CanErase)
             {
                 Proveedor proveedor = new Proveedor();
                 proveedor.ID = this.SupplierID;
                 proveedor.GetSupplierData();
                 proveedor.diasVisita = this.repetingDays;
                 proveedor.UpdateVisitingDays();
             }
             this.Close();
         }
         catch (Exception ex)
         {
             int num = (int)MessageBox.Show(ex.ToString());
         }
     }
 }
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("¿Desea borrar este recordatorio?", "", MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }
            Recordatorio recordatorio = new Recordatorio();

            recordatorio.ID_Supplier = this.SupplierID;
            recordatorio.ID          = this.reminderID;
            try
            {
                recordatorio.delete();
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                int num = (int)MessageBox.Show("No se pudo eliminar el recordatorio.\n Eroor: " + ex.ToString(), "Error");
            }
        }