public static bool SaveEvent(Event eventdata)
 {
     int r=0;
     if (eventdata != null)
     {
         EventBLL oEventBLL = new EventBLL();
         r= oEventBLL.InsertEvents(eventdata);
     }
     if(r>0)
         return true;
     else
         return false;
 }
 public static bool DelEvent(Int32 evid)
 {
     int r = 0;
     if (evid != null)
     {
         EventBLL oEventBLL = new EventBLL();
         r = oEventBLL.DelEvents(evid);
     }
     if (r > 0)
         return true;
     else
         return false;
 }
        public static Event[] ViewDetails(int evid)
        {
            DataTable dt = new DataTable();
            List<Event> details = new List<Event>();

            EventBLL oEventBLL = new EventBLL();
            dt = oEventBLL.GetEventDetails(evid);

            foreach (DataRow dtrow in dt.Rows)
            {
                Event eve = new Event();
                eve.eventID = Int32.Parse(dtrow["eventID"].ToString());
                eve.otherInfo = dtrow["otherInfo"].ToString();
                eve.backgroundColor = dtrow["backgroundColor"].ToString();
                details.Add(eve);
            }

            return details.ToArray();
        }
        protected void btnSave1_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (RepeaterItem rpItem in rpUpload.Items)
                {
                    Label lblPLT = rpItem.FindControl("lblPLT") as Label;
                    Label lblDEPT = rpItem.FindControl("lblDEPT") as Label;
                    Label lblMACH = rpItem.FindControl("lblMACH") as Label;
                    Label lblYEARX = rpItem.FindControl("lblYEARX") as Label;
                    Label lblNUMX = rpItem.FindControl("lblNUMX") as Label;
                    Label lblUPC = rpItem.FindControl("lblUPC") as Label;
                    Label lblPDTNM = rpItem.FindControl("lblPDTNM") as Label;
                    Label lblPPDT3 = rpItem.FindControl("lblPPDT3") as Label;
                    Label lblPPDT4 = rpItem.FindControl("lblPPDT4") as Label;
                    Label lblPPDT5 = rpItem.FindControl("lblPPDT5") as Label;
                    Label lblORDER = rpItem.FindControl("lblORDER") as Label;
                    Label lblRO = rpItem.FindControl("lblRO") as Label;
                    Label lblREPQTY = rpItem.FindControl("lblREPQTY") as Label;
                    Label lblSCHQTY = rpItem.FindControl("lblSCHQTY") as Label;
                    Label lblDLVQTY = rpItem.FindControl("lblDLVQTY") as Label;
                    Label lblAVGQTY = rpItem.FindControl("lblAVGQTY") as Label;
                    Label lblSTDATE = rpItem.FindControl("lblSTDATE") as Label;
                    Label lblTMDATE = rpItem.FindControl("lblTMDATE") as Label;
                    Label lblDLDATE = rpItem.FindControl("lblDLDATE") as Label;
                    Label lblLWDATE = rpItem.FindControl("lblLWDATE") as Label;
                    Label lblENDATE = rpItem.FindControl("lblENDATE") as Label;
                    Label lblMCHTYP = rpItem.FindControl("lblMCHTYP") as Label;
                    Label lblSRMK1 = rpItem.FindControl("lblSRMK1") as Label;
                    Label lblSRMK2 = rpItem.FindControl("lblSRMK2") as Label;
                    Label lblSRMK3 = rpItem.FindControl("lblSRMK3") as Label;
                    Label lblSRMK4 = rpItem.FindControl("lblSRMK4") as Label;
                    Label lblSRMK5 = rpItem.FindControl("lblSRMK5") as Label;
                    Label lblEOQ = rpItem.FindControl("lblEOQ") as Label;
                    Label lblROP = rpItem.FindControl("lblROP") as Label;
                    Label lblTOTBK = rpItem.FindControl("lblTOTBK") as Label;
                    Label lblACTAL = rpItem.FindControl("lblACTAL") as Label;
                    Label lblAVGSHP = rpItem.FindControl("lblAVGSHP") as Label;
                    Label lblINST1 = rpItem.FindControl("lblINST1") as Label;
                    Label lblINST2 = rpItem.FindControl("lblINST2") as Label;
                    Label lblINST3 = rpItem.FindControl("lblINST3") as Label;
                    Label lblSEQ = rpItem.FindControl("lblSEQ") as Label;
                    Label lblCTRMID = rpItem.FindControl("lblCTRMID") as Label;
                    Label lblCUSRID = rpItem.FindControl("lblCUSRID") as Label;
                    Label lblCCHGDT = rpItem.FindControl("lblCCHGDT") as Label;
                    Label lblCCHGTM = rpItem.FindControl("lblCCHGTM") as Label;
                    Label lblCSTS = rpItem.FindControl("lblCSTS") as Label;

                    if (lblTMDATE.CssClass != "error")
                    {

                        int sd, sm, sy, ed, em, ey;
                        int shh, smm, sss, ehh, emm, ess;
                        string starty = "20"+ lblSTDATE.Text.Substring(1, 2);
                        string endy = "20"+lblTMDATE.Text.Substring(1, 2);

                        sd = int.Parse(lblSTDATE.Text.Substring(5, 2));
                        sm = int.Parse(lblSTDATE.Text.Substring(3, 2));

                        ed = int.Parse(lblTMDATE.Text.Substring(5, 2));
                        em = int.Parse(lblTMDATE.Text.Substring(3, 2));

                        shh = 0;
                        smm = 0;
                        sss = 0;
                        ehh = 0;
                        emm = 0;
                        ess= 0;

                        #region [Save To Database]
                        Event eventdata = new Event();
                        eventdata.eventName = lblPLT.Text;
                        eventdata.startDay = sd.ToString();
                        eventdata.startMonth = sm.ToString();
                        eventdata.startYear = starty;
                        eventdata.startHour = shh.ToString();
                        eventdata.startMin = smm.ToString();

                        eventdata.endDay = ed.ToString();
                        eventdata.endMonth = em.ToString();
                        eventdata.endYear = endy;
                        eventdata.endHour = ehh.ToString();
                        eventdata.endMin = emm.ToString();

                        eventdata.otherInfo = "";
                        eventdata.backgroundColor = "#333333";
                        eventdata.foregroundColor = "#ffffff";
                         EventBLL oEventBLL = new EventBLL();
                         int r= oEventBLL.InsertEvents(eventdata);
                         #region [File Data]
                         if (r > 0)
                         {
                             eventdata.eventID = r;
                             eventdata.PLT = lblPLT.Text;
                             eventdata.DEPT = lblDEPT.Text;
                             eventdata.MACH = lblMACH.Text;
                             eventdata.YEARX = lblYEARX.Text;
                             eventdata.NUMX = lblNUMX.Text;
                             eventdata.UPC = lblUPC.Text;
                             eventdata.PDTNM = lblPDTNM.Text;
                             eventdata.PPDT3 = lblPPDT3.Text;
                             eventdata.PPDT4 = lblPPDT4.Text;
                             eventdata.PPDT5 = lblPPDT5.Text;
                             eventdata.ORDER = lblORDER.Text;
                             eventdata.RO = lblRO.Text;
                             eventdata.REPQTY = lblREPQTY.Text;
                             eventdata.SCHQTY = lblSCHQTY.Text;
                             eventdata.DLVQTY = lblDLVQTY.Text;
                             eventdata.AVGQTY = lblAVGQTY.Text;
                             eventdata.STDATE = lblSTDATE.Text;
                             eventdata.TMDATE = lblTMDATE.Text;
                             eventdata.DLDATE = lblDLDATE.Text;
                             eventdata.LWDATE = lblLWDATE.Text;
                             eventdata.ENDATE = lblENDATE.Text;
                             eventdata.MCHTYP = lblMCHTYP.Text;
                             eventdata.SRMK1 = lblSRMK1.Text;
                             eventdata.SRMK2 = lblSRMK2.Text;
                             eventdata.SRMK3 = lblSRMK3.Text;
                             eventdata.SRMK4 = lblSRMK4.Text;
                             eventdata.SRMK5 = lblSRMK5.Text;
                             eventdata.EOQ = lblEOQ.Text;
                             eventdata.ROP = lblROP.Text;
                             eventdata.TOTBK = lblTOTBK.Text;
                             eventdata.ACTAL = lblACTAL.Text;
                             eventdata.AVGSHP = lblAVGSHP.Text;
                             eventdata.INST1 = lblINST1.Text;
                             eventdata.INST2 = lblINST2.Text;
                             eventdata.INST3 = lblINST3.Text;
                             eventdata.SEQ = lblSEQ.Text;
                             eventdata.CTRMID = lblCTRMID.Text;
                             eventdata.CUSRID = lblCUSRID.Text;
                             eventdata.CCHGDT = lblCCHGDT.Text;
                             eventdata.CCHGTM = lblCCHGTM.Text;
                             eventdata.CSTS = lblCSTS.Text;

                             oEventBLL = new EventBLL();
                             r = oEventBLL.InsertFile(eventdata);
                         }
                         #endregion

                        #endregion
                    }
                }

                ClearResult();
            }
            catch(Exception ex)
            {

            }
        }
        public static Event[] ViewEvents()
        {
            DataTable dt = new DataTable();
            List<Event> details = new List<Event>();

            EventBLL oEventBLL = new EventBLL();
            dt = oEventBLL.GetEvents();

            foreach (DataRow dtrow in dt.Rows)
            {
                Event eve = new Event();
                eve.eventID = Int32.Parse(dtrow["eventID"].ToString());
                eve.eventName = dtrow["eventName"].ToString();

                eve.startYear = dtrow["starYear"].ToString();
                eve.startMonth = dtrow["startMonth"].ToString();
                eve.startDay = dtrow["startDay"].ToString();

                eve.startHour = dtrow["startHour"].ToString();
                eve.startMin = dtrow["startMin"].ToString();

                eve.endYear = dtrow["endYear"].ToString();
                eve.endMonth = dtrow["endMonth"].ToString();
                eve.endDay = dtrow["endDay"].ToString();

                eve.endHour = dtrow["endHour"].ToString();
                eve.endMin = dtrow["endMin"].ToString();

                eve.otherInfo = dtrow["otherInfo"].ToString();

                eve.backgroundColor = dtrow["backgroundColor"].ToString();
                eve.foregroundColor = dtrow["foregroundColor"].ToString();
                details.Add(eve);
            }

            return details.ToArray();
        }