public void bindScheduleDetails(int engagemetnid)
 {
     string nextdate = "";
     ScheduleData objsch = new ScheduleData();
     DataTable dt = objsch.GetScheduleDetails(engagemetnid);
     if (dt.Rows.Count > 0)
     {
         nextdate = dt.Compute("Max(Schedule_Date)", "").ToString();
         hdfPerf.Value = dt.Rows[dt.Rows.Count - 1]["SCHEDULE_TYPE"].ToString().Trim();
     }
     else
     {
         hdfPerf.Value = "0";
     }
     hdn_schnextdate.Value = nextdate;
     HiddenField hdn_schedulecount = (HiddenField)this.Page.Form.FindControl("hdn_schedulecount");
     hdn_schedulecount.Value = dt.Rows.Count.ToString();
     RepDetails.DataSource = dt;
     RepDetails.DataBind();
 }
        protected void lnkbtnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                string msg = "";
                foreach (RepeaterItem gr in RepDetails.Items)
                {
                    CheckBox chkdelete = (CheckBox)gr.FindControl("chkdelete");
                    HiddenField hdnscheduleid = (HiddenField)gr.FindControl("hdnscheduleid");

                    if (chkdelete.Checked == true)
                    {
                        if (hdnscheduleid.Value != "0")
                        {
                            ScheduleData objsch = new ScheduleData();
                            msg = objsch.Engagementschedule_Delete(Convert.ToInt32(hdnscheduleid.Value));
                        }
                    }
                }
                bindScheduleDetails(engagementid);
                trfooter.Visible = false;
                lbl_msg.Text = msg;
                lbl_msg.ForeColor = System.Drawing.Color.Red;
            }
            catch (Exception ex)
            {
                lbl_msg.Text = "Error: " + ex.Message.ToString();
                lbl_msg.ForeColor = System.Drawing.Color.Red;
            }
        }
        public void Save_EngagementSchedule(string type, int schedule_engid)
        {
            SaveTempScheduleDetails();
            DataTable dt = (DataTable)ViewState["temptable"];
            string schedule_type, schedule_days, schedule_stime, schedule_endtime, notes;
            Nullable<DateTime> schedulde_date;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                schedulde_date = Convert.ToDateTime(dt.Rows[i]["schedule_date"]);
                schedule_type = dt.Rows[i]["schedule_type"].ToString();
                schedule_days = dt.Rows[i]["schedule_day"].ToString();
                schedule_stime = dt.Rows[i]["schedule_st_time"].ToString();
                schedule_endtime = dt.Rows[i]["schedule_end_time"].ToString();
                notes = dt.Rows[i]["schedule_notes"].ToString();
                ScheduleData objsch = new ScheduleData();
                if (Convert.ToInt32(dt.Rows[i]["schedule_id"]) == 0)
                {
                    objsch.Engagementschedule_Insert(schedule_engid, schedule_type, schedulde_date, schedule_days, schedule_stime, schedule_endtime, notes);
                }

                //    objsch.Engagementschedule_Update(schedule_id, schedule_engid, schedule_type, schedulde_date, schedule_days, schedule_stime, schedule_endtime, notes);

            }
            //Response.Redirect("~/Engagement.aspx?engmtid=" + schedule_engid.ToString() + "&status=1");
        }
 public void UpdateSchedule(RepeaterItem ri)
 {
     CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
     TextInfo textInfo = cultureInfo.TextInfo;
     DropDownList drp_scheduletype = (DropDownList)ri.FindControl("ddlscheduletypeE");
     Label lblscheduleday = (Label)ri.FindControl("lblscheduledayE");
     TextBox txtscheduedate = (TextBox)ri.FindControl("txtscheduedateE");
     //if (checkedit_scheduledate(txtscheduedate.Text) == true)
     //{
     TextBox txtschedule_sttime = (TextBox)ri.FindControl("txtschedule_sttimeE");
     TextBox txtschedule_endtime = (TextBox)ri.FindControl("txtschedule_endtimeE");
     TextBox txtschedulenotes = (TextBox)ri.FindControl("txtschedulenotesE");
     HiddenField hdnscheduleid = (HiddenField)ri.FindControl("hdnscheduleid");
     string schedule_type, schedule_days, schedule_stime, schedule_endtime, notes;
     Nullable<DateTime> schedulde_date;
     schedulde_date = Convert.ToDateTime(txtscheduedate.Text);
     schedule_type = drp_scheduletype.SelectedItem.Text;
     schedule_days = textInfo.ToTitleCase(Convert.ToDateTime(txtscheduedate.Text).DayOfWeek.ToString().Substring(0, 3));
     schedule_stime = Convert.ToString(txtschedule_sttime.Text);
     schedule_endtime = Convert.ToString(txtschedule_endtime.Text);
     notes = txtschedulenotes.Text;
     ScheduleData objsch = new ScheduleData();
     string msg = objsch.Engagementschedule_Update(engagementid, Convert.ToInt32(hdnscheduleid.Value), schedule_type, schedulde_date, schedule_days, schedule_stime, schedule_endtime, notes);
     if (msg == "")
     {
         lbl_msg.Text = "Schedule updated successfully!";
         lbl_msg.ForeColor = System.Drawing.Color.Green;
         bindScheduleDetails(Convert.ToInt32(engagementid));
     }
     else
     {
         lbl_msg.Text = msg;
         lbl_msg.ForeColor = System.Drawing.Color.Orange;
     }
     // }
 }
        public void SaveTempScheduleDetails()
        {
            CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
            TextInfo textInfo = cultureInfo.TextInfo;
            if (trfooter.Visible == true)
            {
                string schedule_type, schedule_days, schedule_stime, schedule_endtime, notes;
                Nullable<DateTime> schedulde_date;
                schedulde_date = Convert.ToDateTime(txtscheduedate.Text);
                schedule_type = ddlscheduletype.SelectedItem.Text;
                schedule_days = textInfo.ToTitleCase(Convert.ToDateTime(txtscheduedate.Text).DayOfWeek.ToString().Substring(0, 3));
                schedule_stime = Convert.ToString(txtschedule_sttime.Text);
                schedule_endtime = Convert.ToString(txtschedule_endtime.Text);
                notes = txtschedulenotes.Text;
                ScheduleData objsch = new ScheduleData();
                string msg = objsch.Engagementschedule_Insert(engagementid, schedule_type, schedulde_date, schedule_days, schedule_stime, schedule_endtime, notes);
                if (msg == "")
                {
                    bindScheduleDetails(Convert.ToInt32(engagementid));
                }
                else
                {
                    lbl_msg.Text = msg;
                    lbl_msg.ForeColor = System.Drawing.Color.Orange;
                }

            }
        }