private void insert_schedule(string staffName, string strJob, DateTime strtTime, DateTime endTime, string strShift) { Shift shift = new Shift(); shift.Name = staffName; shift.Job = strJob; shift.ShiftName = strShift; shift.Start = strtTime; shift.End = endTime; shift.PostDate = DateTime.Now; sqlController sqc = new sqlController(); try { if (sqc.Check_Shift(shift.Name, shift.Start, shift.ShiftName) > 0) { lblStrtTimeEdit.Text = "*Shift is unavailable."; lblStrtTimeEdit.ForeColor = System.Drawing.Color.Red; lstStartHours.BorderStyle = BorderStyle.Dotted; lstStartHours.BorderColor = System.Drawing.Color.Red; lstStartMinutes.BorderStyle = BorderStyle.Dotted; lstStartMinutes.BorderColor = System.Drawing.Color.Red; return; } if (sqc.InsertShift(shift) > 0) { ScriptManager.RegisterStartupScript(this, GetType(), "showSuccessMessage", "showSuccessMessage();", true); lblMessage.Text = "Shift was added successfully."; lstStaffType.Text = " "; lstStaff.Items.Clear(); lstShift.Text = "Lunch"; lstStartMinutes.Text = " "; lstStartHours.Text = " "; lstEndHours.Text = " "; lstEndMinutes.Text = " "; lblStrtTimeEdit.Text = ""; lblStaffTypeEdit.Text = ""; lblStaffEdit.Text = ""; lblShiftEdit.Text = ""; lstStaffType.BorderStyle = BorderStyle.NotSet; lstStartMinutes.BorderStyle = BorderStyle.NotSet; lstStartHours.BorderStyle = BorderStyle.NotSet; lstEndHours.BorderStyle = BorderStyle.NotSet; lstEndMinutes.BorderStyle = BorderStyle.NotSet; lstStaffType.BorderColor = System.Drawing.Color.Empty; lstStartMinutes.BorderColor = System.Drawing.Color.Empty; lstStartHours.BorderColor = System.Drawing.Color.Empty; lstEndHours.BorderColor = System.Drawing.Color.Empty; lstEndMinutes.BorderColor = System.Drawing.Color.Empty; lstStartHours.DataSource = strtLunchHours; lstStartHours.DataBind(); lstEndHours.DataSource = strtLunchHours; lstEndHours.DataBind(); GetShifts(); } } catch (Exception ex) { Logger.Log(ex); ScriptManager.RegisterStartupScript(this, GetType(), "showErrorMessage", "showErrorMessage();", true); } sqc = null; }