Esempio n. 1
0
        private void EditToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lv.SelectedItems.Count > 0)
            {
                pnlops.Controls.Clear();

                String dateoftheyear = lv.SelectedItems[0].SubItems[1].Text;

                Day_Marker dm = new Day_Marker();

                day_marker_update c = new day_marker_update();

               // MessageBox.Show(dateoftheyear);

                c.dm = dm.SELECT_BY_DATE(dateoftheyear);

                c.Width = pnlops.Width;
                pnlops.Height = c.Height;

                pnlops.Controls.Add(c);
            }
            else {
                MessageBox.Show("Nothing Selected");
            }
        }
Esempio n. 2
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            Cutoff c = new Cutoff();
            txtcutoff_id.Text = dtfrom_date.Value.ToString("MMddyyyy") + dtto_date.Value.ToString("MMddyyyy");
            c.cutoff_id = txtcutoff_id.Text;
            c.from_date = dtfrom_date.Value;
            c.to_date = dtto_date.Value;

            TimeSpan numofdays = c.to_date.Subtract(c.from_date);

            if (c.save())
            {

                for (int x = 0; x <= numofdays.Days; x++) {

                    Cutoff_Details cd = new Cutoff_Details();
                    Day_Marker dm, dm1 = new Day_Marker();

                    DateTime thisdate = c.from_date.AddDays(x);

                    //MessageBox.Show(thisdate.ToString("MMMM-d"));
                    //CHECK FOR HOLIDAYS IN THE DAY MARKER TABLE
                    dm= dm1.SELECT_BY_DATE(thisdate.ToString("MMMM-d"));

                     String day_type="";
                     String holiday_name="";

                     if (thisdate.ToString("dddd") == "Sunday")
                    {
                        day_type = "REST_DAY";

                    }
                    else {
                        day_type = (dm != null) ? dm.type_ : "REGULAR_DAY";
                        holiday_name = (dm != null) ? dm.name_of_holiday : "";
                    }

                    cd.cutoff_id = c.cutoff_id;
                    cd.date_ = thisdate;
                    cd.day_type = day_type;
                    cd.holiday_name = holiday_name;

                    cd.save();

                    //MessageBox.Show(day_type + "-" + holiday_name);

                }

                MessageBox.Show("Successful.", "Saving Cutoff");
            }
            else
            {
                MessageBox.Show("There was a problem saving this cutoff.\n\n Message :" + db.err.Message, "Saving Cutoff");
            }
        }
Esempio n. 3
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (txtdescription.Text != "" && cbotype.Text != "") {

                Day_Marker dm = new Day_Marker();
                dm.dateoftheyear = dtdateoftheyear.Value;
                dm.type_ = cbotype.Text;
                dm.name_of_holiday = txtdescription.Text;

                if (dm.save())
                {
                    MessageBox.Show("Successful", "Save");
                }
                else {
                    MessageBox.Show("There was a problem saving this holiday.");

                }

            }
        }
Esempio n. 4
0
        public void LoadInListView(ListView lv)
        {
            Day_Marker a = new Day_Marker();
              DataTable dt = new DataTable();

              dt = a.SELECT_ALL();
              if (dt != null)
              {
                  int ctr = 1;
                  foreach (DataRow r in dt.Rows)
                  {
                      ListViewItem li = new ListViewItem();
                      li.Text = ctr.ToString();
                      li.SubItems.Add(Convert.ToDateTime(r["dateoftheyear"].ToString()).ToString("MMMM-d"));
                      li.SubItems.Add(r["name_of_holiday"].ToString());
                      li.SubItems.Add(r["type_"].ToString());

                      lv.Items.Add(li);
                      ctr++;
                  }
              }
        }
Esempio n. 5
0
        }  //end select all

        public void LoadInListView(ListView lv)
        {
            Day_Marker a  = new Day_Marker();
            DataTable  dt = new DataTable();

            dt = a.SELECT_ALL();
            if (dt != null)
            {
                int ctr = 1;
                foreach (DataRow r in dt.Rows)
                {
                    ListViewItem li = new ListViewItem();
                    li.Text = ctr.ToString();
                    li.SubItems.Add(Convert.ToDateTime(r["dateoftheyear"].ToString()).ToString("MMMM-d"));
                    li.SubItems.Add(r["name_of_holiday"].ToString());
                    li.SubItems.Add(r["type_"].ToString());

                    lv.Items.Add(li);
                    ctr++;
                }
            }
        }  //end load in listview
Esempio n. 6
0
        private void DeleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lv.SelectedItems.Count > 0)
            {

                Day_Marker dm = new Day_Marker();
                String dateoftheyear = lv.SelectedItems[0].SubItems[1].Text;
              if(MessageBox.Show("Please confirm delete of this item. ","Delete?", MessageBoxButtons.YesNo)== DialogResult.Yes)
              {
                if(dm.delete(dateoftheyear)){
                        MessageBox.Show("Successful","Delete");
                 }else{
                 MessageBox.Show("There was a problem deleting this item.");
                }
              }

            }
            else
            {
                MessageBox.Show("Nothing Selected");
            }
        }
Esempio n. 7
0
        }//end select all

        public Day_Marker SELECT_BY_DATE(string thisdate)
        {
            DataTable    dt  = new DataTable();
            MySqlCommand cmd = new MySqlCommand();

            db.SET_COMMAND_PARAMS(cmd, "DAY_MARKER_SELECT_BYDATE");
            cmd.Parameters.AddWithValue("_dateoftheyear", thisdate);


            MySqlDataAdapter da = new MySqlDataAdapter(cmd);

            try
            {
                Day_Marker dm = new Day_Marker();
                da.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    DataRow r = dt.Rows[0];

                    dm.dateoftheyear   = Convert.ToDateTime(r["dateoftheyear"].ToString());
                    dm.name_of_holiday = r["name_of_holiday"].ToString();
                    dm.type_           = r["type_"].ToString();

                    return(dm);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.WriteErrorLog("DAY MARKER SELECT_ALL MODULE :" + e.Message);
                return(null);
            }
        }  //end select all
Esempio n. 8
0
        public Day_Marker SELECT_BY_DATE(string thisdate)
        {
            DataTable dt = new DataTable();
              MySqlCommand cmd = new MySqlCommand();
              db.SET_COMMAND_PARAMS(cmd, "DAY_MARKER_SELECT_BYDATE");
              cmd.Parameters.AddWithValue("_dateoftheyear", thisdate);

              MySqlDataAdapter da = new MySqlDataAdapter(cmd);

              try
              {
                  Day_Marker dm = new Day_Marker();
                  da.Fill(dt);

                  if (dt.Rows.Count > 0)
                  {
                      DataRow r = dt.Rows[0];

                      dm.dateoftheyear = Convert.ToDateTime(r["dateoftheyear"].ToString());
                      dm.name_of_holiday = r["name_of_holiday"].ToString();
                      dm.type_ = r["type_"].ToString();

                      return dm;
                  }
                  else {
                      return null;
                  }

              }
              catch (Exception e)
              {
                  Logger.WriteErrorLog("DAY MARKER SELECT_ALL MODULE :" + e.Message);
                  return null;
              }
        }
Esempio n. 9
0
 private void day_marker_ctrl_Load(object sender, EventArgs e)
 {
     Day_Marker dm = new Day_Marker();
     dm.LoadInListView(lv);
 }