Exemple #1
0
        private void bunifuFlatButton1_Click_1(object sender, EventArgs e)
        {
            try
            {
                string strict      = Strict.Checked == false ? "0" : "1";
                string eventAmount = freeSwitch.Value == false?ParseMultiPayment() : "0";

                string eventName  = txtEventName.Text.Trim().Length > 8 && txtEventName.Text.Trim().Length < 50 ? txtEventName.Text.Trim() : null;
                string ceventDate = eventDate.Value.ToString() != "" ? eventDate.Value.ToShortDateString() : null;
                string eventOpen  = "-1";
                string partial    = minimum.Text.Trim().Length <= 0 ? "0" : minimum.Text.Trim();

                DateTime date;

                if (TimePicker.selectedIndex == 0)
                {
                    date = eventDate.Value + new TimeSpan(Convert.ToInt32(DropTime.selectedValue), 0, 0);
                }
                else
                {
                    date = eventDate.Value - new TimeSpan(Convert.ToInt32(DropTime.selectedValue), 0, 0);
                }

                if (eventName == null)
                {
                    alert.Show("Invalid Name", alert.AlertType.info);
                }
                else if (LocationCombo.selectedIndex == -1)
                {
                    alert.Show("Invalid Location", alert.AlertType.info);
                }
                else if (date.CompareTo(DateTime.Now) == -1)
                {
                    alert.Show("Past date/hour not accepted", alert.AlertType.info);
                }
                else if (ValidateEvent())
                {
                    alert.Show("Time/Location already used.", alert.AlertType.info);
                }
                else if (ValidateEvent(1))
                {
                    var result = MessageBox.Show("The same event has already exist, would you still want to try to create this event?", "Confirmation", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {
                        if (ValidateEvent())
                        {
                            alert.Show("Time/Location already used.", alert.AlertType.info);
                        }
                        else
                        {
                            //string query = "insert into custom_event(event_name,event_location,event_stime,event_date,event_cost,event_open,event_registered,event_attended,sponsor,strict) values(@name,@loc,@time,@date,@cost,@open,@registered,@attended,@sponsor,@strict)";
                            //SqlUtils.ExecuteInsert(query, new string[] { "@name", "@loc", "@time", "@date", "@cost", "@open", "registered", "@attended", "@sponsor", "@strict" }, new string[] { eventName, LocationCombo.selectedValue.Trim(), DropTime.selectedValue + TimePicker.selectedValue, ceventDate, eventAmount, eventOpen, "0", "0", ParseMultiPayment(1), strict });
                            //alert.Show("Success", alert.AlertType.success);

                            //freeSwitch.Value = true;
                            //freeSwitch_OnValueChange(bunifuFlatButton1, EventArgs.Empty);
                            //PaymentCombo.selectedIndex = -1;
                            //LocationCombo.selectedIndex = -1;
                            //txtEventName.Text = "";
                            //Strict.Checked = false;

                            var sponsorsHelp = new SponsorsHelp();
                            sponsorsHelp.FetchData();
                            sponsorsHelp.SetUpEvent(txtEventName.Text.Trim(), LocationCombo.selectedValue.Trim(), DropTime.selectedValue.Trim() + TimePicker.selectedValue.Trim(), EndTime.selectedValue.Trim() + EndAM.selectedValue.Trim(), eventDate.Value.ToShortDateString().Trim(), eventAmount, partial, "-1", "0", "0", strict);

                            Panel1.Controls.Add(sponsorsHelp);
                            sponsorsHelp.Dock = DockStyle.Fill;
                            sponsorsHelp.BringToFront();
                        }
                    }
                }
                else
                {
                    //string query = "insert into custom_event(event_name,event_location,event_stime,event_date,event_cost,event_open,event_registered,event_attended,sponsor,strict) values(@name,@loc,@time,@date,@cost,@open,@registered,@attended,@sponsor,@strict)";
                    //SqlUtils.ExecuteInsert(query, new string[] { "@name", "@loc", "@time", "@date", "@cost", "@open", "registered", "@attended", "@sponsor", "@strict" }, new string[] { eventName, LocationCombo.selectedValue.Trim(), DropTime.selectedValue + TimePicker.selectedValue, ceventDate, eventAmount, eventOpen, "0", "0", ParseMultiPayment(1), strict });
                    //alert.Show("Success", alert.AlertType.success);

                    //freeSwitch.Value = true;
                    //freeSwitch_OnValueChange(bunifuFlatButton1, EventArgs.Empty);
                    //PaymentCombo.selectedIndex = -1;
                    //LocationCombo.selectedIndex = -1;
                    //txtEventName.Text = "";
                    //Strict.Checked = false;


                    //SqlUtils.ExecuteInsert(query, new string[] { "@name", "@loc", "@time","@endtime", "@date", "@cost", "@partial" ,"@open", "registered", "@attended", "@sponsor", "@strict" }, new string[] { eventName, LocationCombo.selectedValue.Trim(), DropTime.selectedValue + TimePicker.selectedValue, ceventDate, eventAmount, eventOpen, "0", "0", ParseMultiPayment(1), strict });
                    try
                    {
                        var sponsorsHelp = new SponsorsHelp();
                        sponsorsHelp.FetchData();

                        sponsorsHelp.SetUpEvent(txtEventName.Text.Trim(), LocationCombo.selectedValue.Trim(), DropTime.selectedValue.Trim() + TimePicker.selectedValue.Trim(), EndTime.selectedValue.Trim() + EndAM.selectedValue.Trim(), eventDate.Value.ToShortDateString().Trim(), eventAmount, partial, "-1", "0", "0", strict);
                        Panel1.Controls.Add(sponsorsHelp);
                        sponsorsHelp.Dock = DockStyle.Fill;
                        sponsorsHelp.BringToFront();
                    }
                    catch (Exception ex) { MessageBox.Show(ex.Message); }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
        private void UpdateBtn_Click(object sender, EventArgs e)
        {
            try
            {
                int strict = 0;
                if (Strict.Checked)
                {
                    strict = 1;
                }

                //int amount;
                //if (freeSwitch.Value == false)
                //    amount = Convert.ToInt32(Payment.selectedValue);
                //else
                //    amount = 0;
                string eventAmount = freeSwitch.Value == false?ParseMultiPayment() : "0";

                bool   invalid = false;
                string name    = txtEventName.Text.Trim();

                DateTime date;

                if (TimePicker.selectedIndex == 0)
                {
                    date = eventDate.Value + new TimeSpan(Convert.ToInt32(DropTime.selectedValue), 0, 0);
                }
                else
                {
                    date = eventDate.Value - new TimeSpan(Convert.ToInt32(DropTime.selectedValue), 0, 0);
                }



                if (name.Length > 50 || name.Length < 8)
                {
                    alert.Show("Invalid event name", alert.AlertType.info);
                    invalid = true;
                }

                if (LocationCombo.selectedIndex == -1)
                {
                    alert.Show("Invalid Location", alert.AlertType.warnig);
                    invalid = true;
                }

                if (date.CompareTo(DateTime.Now) == -1)
                {
                    alert.Show("Invalid date", alert.AlertType.info);
                    invalid = true;
                }

                if (invalid == false)
                {
                    var sponsorsHelp = new SponsorsHelp();
                    sponsorsHelp.FetchData();
                    sponsorsHelp.SetUpFromUpdate(txtEventName.Text.Trim(), LocationCombo.selectedValue, DropTime.selectedValue + TimePicker.selectedValue, EndTime.selectedValue + EndAM.selectedValue, eventDate.Value.ToShortDateString(), eventAmount, Strict.Checked == true ? "1" : "0", id.ToString());
                    panel1.Controls.Add(sponsorsHelp);
                    sponsorsHelp.Dock = DockStyle.Fill;
                    sponsorsHelp.BringToFront();
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
            //try
            //{
            //    SqlUtils.ExecuteQuery("update custom_event set event_name='" + name + "', sponsor='" + sponsor + "', event_location='" + location + "', event_stime='" + DropTime.selectedValue+ TimePicker.selectedValue + "', strict='" + strict + "', event_date='" +eventDate.Value+"' where eventid="+ id, false);
            //    RefreshNameList(0,"");
            //    alert.Show("Update Success",alert.AlertType.success);
            //}
            //catch (Exception ex)
            //{
            //    alert.Show("Unknown Error Occurs...", alert.AlertType.error);
            //}
        }