예제 #1
0
        protected void gvCallAttendance_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                Business.Service.ServiceBook objServiceBook = new Business.Service.ServiceBook();

                if (e.CommandName == "E")
                {
                    Entity.Service.ServiceCallAttendance serviceCallAttendance = new Entity.Service.ServiceCallAttendance();

                    GridViewRow gvCallAttendanceRow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);

                    TextBox      txtInDate           = (TextBox)gvCallAttendanceRow.FindControl("txtInDate");
                    DropDownList ddlInTimeHH         = (DropDownList)gvCallAttendanceRow.FindControl("ddlInTimeHH");
                    DropDownList ddlInTimeMM         = (DropDownList)gvCallAttendanceRow.FindControl("ddlInTimeMM");
                    DropDownList ddlInTimeTT         = (DropDownList)gvCallAttendanceRow.FindControl("ddlInTimeTT");
                    TextBox      txtOutDate          = (TextBox)gvCallAttendanceRow.FindControl("txtOutDate");
                    DropDownList ddlOutTimeHH        = (DropDownList)gvCallAttendanceRow.FindControl("ddlOutTimeHH");
                    DropDownList ddlOutTimeMM        = (DropDownList)gvCallAttendanceRow.FindControl("ddlOutTimeMM");
                    DropDownList ddlOutTimeTT        = (DropDownList)gvCallAttendanceRow.FindControl("ddlOutTimeTT");
                    DropDownList ddlDocketCallStatus = (DropDownList)gvCallAttendanceRow.FindControl("ddlDocketCallStatus");

                    serviceCallAttendance.ServiceCallAttendanceId = int.Parse(e.CommandArgument.ToString());
                    serviceCallAttendance.CallStatusId            = int.Parse(ddlDocketCallStatus.SelectedValue);
                    serviceCallAttendance.InTime = Convert.ToDateTime(txtInDate.Text + " " + ddlInTimeHH.SelectedValue + ":" + ddlInTimeMM.SelectedValue + ":00" + " " + ddlInTimeTT.SelectedValue);
                    if (!string.IsNullOrEmpty(txtOutDate.Text.Trim()) && ddlOutTimeHH.SelectedIndex != 0 && ddlOutTimeMM.SelectedIndex != 0)
                    {
                        serviceCallAttendance.OutTime = (Request.QueryString["action"] != null && Request.QueryString["action"].Equals("callin")) ? DateTime.MinValue : Convert.ToDateTime(txtOutDate.Text + " " + ddlOutTimeHH.SelectedValue + ":" + ddlOutTimeMM.SelectedValue + ":00" + " " + ddlOutTimeTT.SelectedValue);
                    }

                    int response = objServiceBook.Service_CallAttendance_Edit(serviceCallAttendance);
                    if (response > 0)
                    {
                        ClearControls();
                        Message.IsSuccess = true;
                        Message.Text      = "Call attendance record is updated.";
                    }
                    else
                    {
                        Message.IsSuccess = false;
                        Message.Text      = "Sorry! Call attendance record is not updated.";
                    }
                    Message.Show = true;
                }
                else if (e.CommandName == "D")
                {
                    int response = objServiceBook.Service_CallAttendance_Delete(int.Parse(e.CommandArgument.ToString()));
                    if (response > 0)
                    {
                        Service_ServiceCallAttendance_GetAll();
                        Message.IsSuccess = true;
                        Message.Text      = "Call attendance record is deleted.";
                    }
                    else
                    {
                        Message.IsSuccess = false;
                        Message.Text      = "Sorry! Call attendance record is not deleted.";
                    }
                    Message.Show = true;
                }
            }
            catch (Exception ex)
            {
                ex.WriteException();

                Message.IsSuccess = false;
                Message.Text      = ex.Message;
                Message.Show      = true;
            }
        }