Beispiel #1
0
        public PlanWeeks GetByID(int Year, string Month, int WeekID)
        {
            try
            {
                SqlParameter[] paramList = new SqlParameter[] {
                    new SqlParameter("@Year", Year),
                    new SqlParameter("@Month", Month),
                    new SqlParameter("@WeekID", WeekID)
                };


                DataTable dt = Execute.RunSP_DataTable(Connection, "SPGET_PlanWeeks", paramList);

                PlanWeeks obj = new PlanWeeks();

                if (dt.Rows.Count > 0)
                {
                    obj.State    = Convert.ToInt32(dt.Rows[0]["State"]);
                    obj.FromDate = Convert.ToDateTime(dt.Rows[0]["FromDate"]);
                    obj.ToDate   = Convert.ToDateTime(dt.Rows[0]["ToDate"]);
                    obj.WeekID   = Convert.ToInt32(dt.Rows[0]["WeekID"]);
                    obj.Month    = Convert.ToString(dt.Rows[0]["Month"]);
                    obj.Year     = Convert.ToInt32(dt.Rows[0]["Year"]);
                }

                return(obj);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Beispiel #2
0
        //---------------------ADD REGION------------------------------
        public int Add(PlanWeeks objPlanWeeks)
        {
            try
            {
                SqlParameter[] paramList = new SqlParameter[] {
                    new SqlParameter("@Year", objPlanWeeks.Year),
                    new SqlParameter("@Month", objPlanWeeks.Month),
                    new SqlParameter("@WeekID", objPlanWeeks.WeekID),
                    new SqlParameter("@FromDate", objPlanWeeks.FromDate),
                    new SqlParameter("@ToDate", objPlanWeeks.ToDate),
                    new SqlParameter("@State", objPlanWeeks.State)
                };


                return(Execute.RunSP_RowsEffected(Connection, "SPADD_PlanWeeks", paramList));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Beispiel #3
0
        private void CreatePlanningWeeks()
        {
            PlanWeeks objPlanWeeks = new PlanWeeks();

            objPlanWeeks.Year     = Convert.ToInt32(cmbYear.Text);
            objPlanWeeks.Month    = cmbMonth.Text;
            objPlanWeeks.WeekID   = Convert.ToInt32(cmbWeekID.Text);
            objPlanWeeks.FromDate = dtpFirstWeekStart.Value;
            objPlanWeeks.ToDate   = dtpFirstWeekStop.Value;
            objPlanWeeks.State    = 0;

            bool y = Validate();

            if (y == true)
            {
                objPlanWeek_DL.Add(objPlanWeeks);
            }
            else
            {
                MessageBox.Show(this, "Incorrect Selections", "Incorrect Attempt", MessageBoxButtons.OK);
            }
        }
Beispiel #4
0
        public PlanWeeksCollec GetByMonth(int Year, string Month)
        {
            try
            {
                SqlParameter[] paramList = new SqlParameter[] {
                    new SqlParameter("@Year", Year),
                    new SqlParameter("@Month", Month)
                };


                DataTable dt = Execute.RunSP_DataTable(Connection, "SPGET_PlanWeeks_ByMonth", paramList);

                PlanWeeksCollec objCollec = new PlanWeeksCollec();

                if (dt.Rows.Count > 0)
                {
                    PlanWeeks obj = new PlanWeeks();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        obj.State    = Convert.ToInt32(dt.Rows[i]["State"]);
                        obj.FromDate = Convert.ToDateTime(dt.Rows[i]["FromDate"]);
                        obj.ToDate   = Convert.ToDateTime(dt.Rows[i]["ToDate"]);
                        obj.WeekID   = Convert.ToInt32(dt.Rows[i]["WeekID"]);
                        obj.Month    = Convert.ToString(dt.Rows[i]["Month"]);
                        obj.Year     = Convert.ToInt32(dt.Rows[i]["Year"]);
                    }

                    objCollec.Add(obj);
                }

                return(objCollec);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }