Ejemplo n.º 1
0
    public string GetResolutionTimeInHours(int slaid)
    {
        int    varDays    = 0;
        int    varHours   = 0;
        int    VarMins    = 0;
        int    TotalHours = 0;
        string total      = "";

        objSlaPriority = objSlaPriority.Get_By_id(slaid);
        if (objSlaPriority.Slaid != 0)
        {
            varDays  = objSlaPriority.Resolutiondays;
            varHours = objSlaPriority.Resolutionhours;
            VarMins  = objSlaPriority.Resolutionmin;
            if (VarMins <= 0)
            {
                TotalHours = (varDays * 24) + (varHours);
                total      = TotalHours.ToString() + " " + "Hours";
            }
            else
            {
                TotalHours = (varDays * 24) + (varHours);
                total      = TotalHours.ToString() + " " + "Hours" + VarMins + " " + "Minutes";
            }
        }

        return(total);
    }
    public string GetResolutionTimeInHours(int slaid)
    {
        int varDays = 0;
        int varHours = 0;
        int VarMins = 0;
        int TotalHours = 0;
        string total="";
        objSlaPriority = objSlaPriority.Get_By_id(slaid);
        if (objSlaPriority.Slaid != 0)
        {
            varDays = objSlaPriority.Resolutiondays;
            varHours = objSlaPriority.Resolutionhours;
            VarMins = objSlaPriority.Resolutionmin;
            if (VarMins <= 0)
            {
                TotalHours = (varDays * 24) + (varHours);
                total = TotalHours.ToString()+" "+"Hours";
            }
            else
            {
                TotalHours = (varDays * 24) + (varHours);
                total = TotalHours.ToString() + " " + "Hours" + VarMins + " " +"Minutes";
            }
        }

        return total;
    }
    protected void Update()
    {
        int Slaid = Convert.ToInt32(Request.QueryString[0]);

        objSla = objSla.Get_By_id(Slaid);
        if (objSla.Slaid != 0)
        {
            int siteid = objSla.Siteid;
            objSite = objSite.Get_By_id(siteid);
            if (objSite.Siteid != 0)
            {
                lblSite.Text = objSite.Sitename;
            }
            txtSlaName.Text     = objSla.Slaname.ToString().Trim();
            txtDescription.Text = objSla.Description.ToString().Trim();
            objSlaPriority      = objSlaPriority.Get_By_id(objSla.Slaid);
            if (objSlaPriority.Priorityid != 0)
            {
                objPriority = objPriority.Get_By_id(objSlaPriority.Priorityid);
                if (objPriority.Priorityid != 0)
                {
                    lblPriority.Text     = objPriority.Name.ToString().Trim();
                    drphr.SelectedValue  = Convert.ToString(objSlaPriority.Resolutionhours);
                    drpMin.SelectedValue = Convert.ToString(objSlaPriority.Resolutionmin);
                    txtDays.Text         = Convert.ToString(objSlaPriority.Resolutiondays);
                }
            }
        }
    }
    public int GetResolutionTimeInMins(int slaid)
    {
        int varDays   = 0;
        int varHours  = 0;
        int VarMins   = 0;
        int TotalMins = 0;

        objSlaPriority = objSlaPriority.Get_By_id(slaid);
        if (objSlaPriority.Slaid != 0)
        {
            varDays   = objSlaPriority.Resolutiondays;
            varHours  = objSlaPriority.Resolutionhours;
            VarMins   = objSlaPriority.Resolutionmin;
            TotalMins = (varDays * 24 * 60) + (varHours * 60) + VarMins;
        }

        return(TotalMins);
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        bool FlagEscalateLevel1 = true;
        bool FlagEscalateLevel2 = true;
        bool FlagEscalateLevel3 = true;

        lblErrorTimeSelect.Text = "";
        if (txtDays.Text == "0" && drphr.SelectedValue == "0" && drpMin.SelectedValue == "0")
        {
            lblErrorTimeSelect.Text = Resources.MessageResource.errResTime.ToString();
        }
        else
        {
            if (chkLevel1.Checked == true)
            {
                if (radio1Level1.Checked == true)
                {
                    int varTotalTime       = calculateTotalminutes();
                    int varTotalTimeLevel1 = calculateTotalminutesLevel1();
                    if (varTotalTimeLevel1 > varTotalTime)
                    {
                        FlagEscalateLevel1 = false;
                    }
                }
                if (radio2Level1.Checked == true)
                {
                    int varTotalTime       = calculateTotalminutes();
                    int varTotalTimeLevel1 = calculateTotalminutesLevel1();
                    //if (varTotalTimeLevel1 < varTotalTime)
                    //{
                    //    FlagEscalateLevel1 = false;
                    //}
                }
            }
            if (chkLevel2.Checked == true)
            {
                if (radio1Level2.Checked == true)
                {
                    int varTotalTime       = calculateTotalminutes();
                    int varTotalTimeLevel2 = calculateTotalminutesLevel2();
                    if (varTotalTimeLevel2 > varTotalTime)
                    {
                        FlagEscalateLevel2 = false;
                    }
                }
                if (radio2Level2.Checked == true)
                {
                    int varTotalTime       = calculateTotalminutes();
                    int varTotalTimeLevel2 = calculateTotalminutesLevel2();
                    //if (varTotalTimeLevel2 < varTotalTime)
                    //{
                    //    FlagEscalateLevel2 = false;
                    //}
                }
            }
            if (chkLevel3.Checked == true)
            {
                if (radio1Level3.Checked == true)
                {
                    int varTotalTime       = calculateTotalminutes();
                    int varTotalTimeLevel3 = calculateTotalminutesLevel3();
                    if (varTotalTimeLevel3 > varTotalTime)
                    {
                        FlagEscalateLevel3 = false;
                    }
                }
                if (radio2Level3.Checked == true)
                {
                    int varTotalTime       = calculateTotalminutes();
                    int varTotalTimeLevel3 = calculateTotalminutesLevel3();
                    //if (varTotalTimeLevel3 < varTotalTime)
                    //{
                    //    FlagEscalateLevel3 = false;
                    //}
                }
            }
            int Slaid = Convert.ToInt32(Request.QueryString[0]);
            objSla = objSla.Get_By_id(Slaid);
            if (objSla.Slaid != 0)
            {
                if (FlagEscalateLevel1 == true && FlagEscalateLevel2 == true && FlagEscalateLevel3 == true)
                {
                    if (chkLevel1.Checked == true)
                    {
                        UpdateLevel1Escalate(Slaid);
                    }
                    else
                    {
                        UncheckedLevel1Escalate(Slaid);
                    }
                    if (chkLevel2.Checked == true)
                    {
                        UpdateLevel2Escalate(Slaid);
                    }
                    else
                    {
                        UncheckedLevel2Escalate(Slaid);
                    }
                    if (chkLevel3.Checked == true)
                    {
                        UpdateLevel3Escalate(Slaid);
                    }
                    else
                    {
                        UncheckedLevel3Escalate(Slaid);
                    }
                    if (objSla.Slaname == txtSlaName.Text.ToString().Trim())
                    {
                        objSla.Description = txtDescription.Text.ToString().Trim();
                        objSlaPriority     = objSlaPriority.Get_By_id(objSla.Slaid);
                        if (objSlaPriority.Slaid != 0)
                        {
                            objSlaPriority.Resolutiondays  = Convert.ToInt32(txtDays.Text);
                            objSlaPriority.Resolutionhours = Convert.ToInt32(drphr.SelectedValue);
                            objSlaPriority.Resolutionmin   = Convert.ToInt32(drpMin.SelectedValue);
                            objSla.Update();
                            objSlaPriority.Update();
                            Response.Redirect("~/admin/ViewSla.aspx");
                        }
                    }
                    else
                    {
                        SLA_mst objSLa1 = new SLA_mst();
                        objSLa1 = objSla.Get_By_SLAName(txtSlaName.Text.ToString().Trim(), objSla.Siteid);
                        if (objSLa1.Slaid == 0)
                        {
                            objSla.Slaname     = txtSlaName.Text.ToString().Trim();
                            objSla.Description = txtDescription.Text.ToString().Trim();
                            objSlaPriority     = objSlaPriority.Get_By_id(objSla.Slaid);
                            if (objSlaPriority.Slaid != 0)
                            {
                                objSlaPriority.Resolutiondays  = Convert.ToInt32(txtDays.Text);
                                objSlaPriority.Resolutionhours = Convert.ToInt32(drphr.SelectedValue);
                                objSlaPriority.Resolutionmin   = Convert.ToInt32(drpMin.SelectedValue);
                                objSla.Update();
                                objSlaPriority.Update();
                                Response.Redirect("~/admin/ViewSla.aspx");
                            }
                        }
                        else
                        {
                            lblErrorMsg.Text = Resources.MessageResource.errSLAExist.ToString();
                        }
                    }
                }
                else
                {
                    if (FlagEscalateLevel1 == false)
                    {
                        lblErrorMsg.Text = Resources.MessageResource.strLevel1.ToString();
                    }
                    if (FlagEscalateLevel2 == false)
                    {
                        lblErrorMsg.Text = Resources.MessageResource.strLevel2.ToString();
                    }
                    if (FlagEscalateLevel3 == false)
                    {
                        lblErrorMsg.Text = Resources.MessageResource.strLevel3.ToString();
                    }
                }
            }
            else
            {
                lblErrorMsg.Text = Resources.MessageResource.errOccured.ToString();
            }
        }
    }
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     bool FlagEscalateLevel1 = true;
     bool FlagEscalateLevel2 = true;
     bool FlagEscalateLevel3 = true;
     lblErrorTimeSelect.Text = "";
     if (txtDays.Text == "0" && drphr.SelectedValue == "0" && drpMin.SelectedValue == "0")
     {
         lblErrorTimeSelect.Text = Resources.MessageResource.errResTime.ToString();
     }
     else
     {
         if (chkLevel1.Checked == true)
         {
             if (radio1Level1.Checked == true)
             {
                 int varTotalTime = calculateTotalminutes();
                 int varTotalTimeLevel1 = calculateTotalminutesLevel1();
                 if (varTotalTimeLevel1 > varTotalTime)
                 {
                     FlagEscalateLevel1 = false;
                 }
             }
             if (radio2Level1.Checked == true)
             {
                 int varTotalTime = calculateTotalminutes();
                 int varTotalTimeLevel1 = calculateTotalminutesLevel1();
                 //if (varTotalTimeLevel1 < varTotalTime)
                 //{
                 //    FlagEscalateLevel1 = false;
                 //}
             }
         }
         if (chkLevel2.Checked == true)
         {
             if (radio1Level2.Checked == true)
             {
                 int varTotalTime = calculateTotalminutes();
                 int varTotalTimeLevel2 = calculateTotalminutesLevel2();
                 if (varTotalTimeLevel2 > varTotalTime)
                 { FlagEscalateLevel2 = false; }
             }
             if (radio2Level2.Checked == true)
             {
                 int varTotalTime = calculateTotalminutes();
                 int varTotalTimeLevel2 = calculateTotalminutesLevel2();
                 //if (varTotalTimeLevel2 < varTotalTime)
                 //{
                 //    FlagEscalateLevel2 = false;
                 //}
             }
         }
         if (chkLevel3.Checked == true)
         {
             if (radio1Level3.Checked == true)
             {
                 int varTotalTime = calculateTotalminutes();
                 int varTotalTimeLevel3 = calculateTotalminutesLevel3();
                 if (varTotalTimeLevel3 > varTotalTime)
                 { FlagEscalateLevel3 = false; }
             }
             if (radio2Level3.Checked == true)
             {
                 int varTotalTime = calculateTotalminutes();
                 int varTotalTimeLevel3 = calculateTotalminutesLevel3();
                 //if (varTotalTimeLevel3 < varTotalTime)
                 //{
                 //    FlagEscalateLevel3 = false;
                 //}
             }
         }
         int Slaid = Convert.ToInt32(Request.QueryString[0]);
         objSla = objSla.Get_By_id(Slaid);
         if (objSla.Slaid != 0)
         {
             if (FlagEscalateLevel1 == true && FlagEscalateLevel2 == true && FlagEscalateLevel3 == true)
             {
                 if (chkLevel1.Checked == true)
                 {
                     UpdateLevel1Escalate(Slaid);
                 }
                 else
                 {
                     UncheckedLevel1Escalate(Slaid);
                 }
                 if (chkLevel2.Checked == true)
                 {
                     UpdateLevel2Escalate(Slaid);
                 }
                 else
                 {
                     UncheckedLevel2Escalate(Slaid);
                 }
                 if (chkLevel3.Checked == true)
                 {
                     UpdateLevel3Escalate(Slaid);
                 }
                 else
                 {
                     UncheckedLevel3Escalate(Slaid);
                 }
                 if (objSla.Slaname == txtSlaName.Text.ToString().Trim())
                 {
                     objSla.Description = txtDescription.Text.ToString().Trim();
                     objSlaPriority = objSlaPriority.Get_By_id(objSla.Slaid);
                     if (objSlaPriority.Slaid != 0)
                     {
                         objSlaPriority.Resolutiondays = Convert.ToInt32(txtDays.Text);
                         objSlaPriority.Resolutionhours = Convert.ToInt32(drphr.SelectedValue);
                         objSlaPriority.Resolutionmin = Convert.ToInt32(drpMin.SelectedValue);
                         objSla.Update();
                         objSlaPriority.Update();
                         Response.Redirect("~/admin/ViewSla.aspx");
                     }
                 }
                 else
                 {
                     SLA_mst objSLa1 = new SLA_mst();
                     objSLa1 = objSla.Get_By_SLAName(txtSlaName.Text.ToString().Trim(), objSla.Siteid);
                     if (objSLa1.Slaid == 0)
                     {
                         objSla.Slaname = txtSlaName.Text.ToString().Trim();
                         objSla.Description = txtDescription.Text.ToString().Trim();
                         objSlaPriority = objSlaPriority.Get_By_id(objSla.Slaid);
                         if (objSlaPriority.Slaid != 0)
                         {
                             objSlaPriority.Resolutiondays = Convert.ToInt32(txtDays.Text);
                             objSlaPriority.Resolutionhours = Convert.ToInt32(drphr.SelectedValue);
                             objSlaPriority.Resolutionmin = Convert.ToInt32(drpMin.SelectedValue);
                             objSla.Update();
                             objSlaPriority.Update();
                             Response.Redirect("~/admin/ViewSla.aspx");
                         }
                     }
                     else
                     {
                         lblErrorMsg.Text = Resources.MessageResource.errSLAExist.ToString();
                     }
                 }
             }
             else
             {
                 if (FlagEscalateLevel1 == false)
                 {
                     lblErrorMsg.Text = Resources.MessageResource.strLevel1.ToString();
                 }
                 if (FlagEscalateLevel2 == false)
                 {
                     lblErrorMsg.Text = Resources.MessageResource.strLevel2.ToString();
                 }
                 if (FlagEscalateLevel3 == false)
                 {
                     lblErrorMsg.Text = Resources.MessageResource.strLevel3.ToString();
                 }
             }
         }
         else
         {
             lblErrorMsg.Text = Resources.MessageResource.errOccured.ToString();
         }
     }
 }
 protected void Update()
 {
     int Slaid = Convert.ToInt32(Request.QueryString[0]);
     objSla = objSla.Get_By_id(Slaid);
     if (objSla.Slaid!=0)
     {
         int siteid = objSla.Siteid;
         objSite = objSite.Get_By_id(siteid);
         if (objSite.Siteid !=0)
         {
             lblSite.Text = objSite.Sitename;
         }
         txtSlaName.Text = objSla.Slaname.ToString().Trim();
         txtDescription.Text = objSla.Description.ToString().Trim();
         objSlaPriority = objSlaPriority.Get_By_id(objSla.Slaid);
         if (objSlaPriority.Priorityid!=0)
         {
            objPriority= objPriority.Get_By_id(objSlaPriority.Priorityid);
            if (objPriority.Priorityid!=0)
             {
                 lblPriority.Text = objPriority.Name.ToString().Trim();
                 drphr.SelectedValue = Convert.ToString(objSlaPriority.Resolutionhours);
                 drpMin.SelectedValue = Convert.ToString(objSlaPriority.Resolutionmin);
                 txtDays.Text = Convert.ToString(objSlaPriority.Resolutiondays);
             }
         }
     }
 }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        // Declare local variable varsiteid,FlagInsertSla and FlagStatus
        int varsiteid;
        ServiceWindow_mst objservicewindow = new ServiceWindow_mst();

        varsiteid = Convert.ToInt16(drpSites.SelectedValue);
        int count = objservicewindow.Get_ServiceWindow_By_Siteid(varsiteid);

        if (count >= 1)
        {
            int  FlagInsertSla;
            int  FlagStatus;
            bool FlagEscalateLevel1 = true;
            bool FlagEscalateLevel2 = true;
            bool FlagEscalateLevel3 = true;
            lblErrorTimeSelect.Text = "";
            if (txtDays.Text == "0" && drphr.SelectedValue == "0" && drpMin.SelectedValue == "0")
            {
                lblErrorTimeSelect.Text = Resources.MessageResource.errResTime.ToString();
            }
            else
            {
                if (chkLevel1.Checked == true)
                {
                    if (radio1Level1.Checked == true)
                    {
                        int varTotalTime       = calculateTotalminutes();
                        int varTotalTimeLevel1 = calculateTotalminutesLevel1();
                        if (varTotalTimeLevel1 > varTotalTime)
                        {
                            FlagEscalateLevel1 = false;
                        }
                    }
                    if (radio2Level1.Checked == true)
                    {
                        int varTotalTime       = calculateTotalminutes();
                        int varTotalTimeLevel1 = calculateTotalminutesLevel1();
                        if (varTotalTimeLevel1 == 0)
                        {
                            FlagEscalateLevel1 = false;
                        }
                    }
                }
                if (chkLevel2.Checked == true)
                {
                    if (radio1Level2.Checked == true)
                    {
                        int varTotalTime       = calculateTotalminutes();
                        int varTotalTimeLevel2 = calculateTotalminutesLevel2();
                        if (varTotalTimeLevel2 > varTotalTime)
                        {
                            FlagEscalateLevel2 = false;
                        }
                    }
                    if (radio2Level2.Checked == true)
                    {
                        int varTotalTime       = calculateTotalminutes();
                        int varTotalTimeLevel2 = calculateTotalminutesLevel2();
                        if (varTotalTimeLevel2 == 0)
                        {
                            FlagEscalateLevel2 = false;
                        }
                    }
                }

                if (chkLevel3.Checked == true)
                {
                    if (radio1Level3.Checked == true)
                    {
                        int varTotalTime       = calculateTotalminutes();
                        int varTotalTimeLevel3 = calculateTotalminutesLevel3();
                        if (varTotalTimeLevel3 > varTotalTime)
                        {
                            FlagEscalateLevel3 = false;
                        }
                    }

                    if (radio2Level3.Checked == true)
                    {
                        int varTotalTime       = calculateTotalminutes();
                        int varTotalTimeLevel3 = calculateTotalminutesLevel3();
                        if (varTotalTimeLevel3 == 0)
                        {
                            FlagEscalateLevel3 = false;
                        }
                    }
                }

                // get sitetd from dropdown to variable varsiteid

                // Check SLA Definition is exist in database with same name and site
                objSla = objSla.Get_By_SLAName(txtSlaName.Text.ToString().Trim(), varsiteid);
                // Check SLA Priority definition is exist in databse with siteid and priorityid
                objSlaPriority = objSlaPriority.Get_By_Siteid(varsiteid, Convert.ToInt16(drpPriority.SelectedValue));
                // if both objSla.Siteid and objSlaPriority.Slaid is zero then,No SLA Definition is exist in database
                if (objSla.Siteid == 0 && objSlaPriority.Slaid == 0)
                {
                    if (FlagEscalateLevel1 == true && FlagEscalateLevel2 == true && FlagEscalateLevel3 == true)
                    {
                        objSla.Siteid         = varsiteid;
                        objSla.Slaname        = txtSlaName.Text.ToString().Trim();
                        objSla.Createdatetime = DateTime.Now.ToString();
                        objSla.Enable         = true;
                        objSla.Description    = txtDescription.Text.ToString().Trim();
                        // Call objSla.Insert() to insert records in database
                        FlagInsertSla = objSla.Insert();
                        // If FlagInsertSla is 1 then record insert in database successfully
                        if (FlagInsertSla == 1)
                        {
                            // Call Function objSla.Get_By_SLAName() to get Slaid of created sla
                            objSla = objSla.Get_By_SLAName(txtSlaName.Text.ToString().Trim(), varsiteid);

                            if (objSla.Siteid != 0)
                            {
                                // declare local variable FlagInsertPriority
                                int FlagInsertPriority;
                                objSlaPriority.Slaid           = objSla.Slaid;
                                objSlaPriority.Siteid          = varsiteid;
                                objSlaPriority.Priorityid      = Convert.ToInt16(drpPriority.SelectedValue);
                                objSlaPriority.Resolutiondays  = Convert.ToInt16(txtDays.Text);
                                objSlaPriority.Resolutionhours = Convert.ToInt16(drphr.SelectedValue);
                                objSlaPriority.Resolutionmin   = Convert.ToInt16(drpMin.SelectedValue);
                                // Call function objSlaPriority.Insert() to insert records in SLA_Priority_mst
                                FlagInsertPriority = objSlaPriority.Insert();
                                // if FlagInsertPriority is not zero then records insert successfully
                                if (FlagInsertPriority != 0)
                                {
                                    //lblErrorMsg.Text = Resources.MessageResource.errSLADef.ToString();



                                    if (chkLevel1.Checked == true)
                                    {
                                        InsertIntoLevel1(objSla.Slaid);
                                    }
                                    if (chkLevel2.Checked == true)
                                    {
                                        InsertIntoLevel2(objSla.Slaid);
                                    }
                                    if (chkLevel3.Checked == true)
                                    {
                                        InsertIntoLevel3(objSla.Slaid);
                                    }

                                    Clear();
                                    Response.Redirect("~/admin/viewsla.aspx");
                                    //CheckDefaultValueForEscalation();
                                }
                                else
                                {
                                    // Call objSla.Delete to delete record from SLA_mst to delete sla definition,because some error occurred in SLA_Priority_mst
                                    objSla.Delete(objSla.Slaid);
                                    // Display Error message some error occurred
                                    lblErrorMsg.Text = Resources.MessageResource.errOccured.ToString();
                                }
                            }
                        }
                    }
                    else
                    {
                        if (FlagEscalateLevel1 == false)
                        {
                            lblErrorMsg.Text = Resources.MessageResource.strLevel1.ToString();
                        }
                        if (FlagEscalateLevel2 == false)
                        {
                            lblErrorMsg.Text = Resources.MessageResource.strLevel2.ToString();
                        }
                        if (FlagEscalateLevel3 == false)
                        {
                            lblErrorMsg.Text = Resources.MessageResource.strLevel3.ToString();
                        }
                    }
                }
                else
                {
                    lblErrorMsg.Text = Resources.MessageResource.errSLAExist.ToString();
                }
            }
        }
        else
        {
            lblErrorMsg.Text = "Service Window not set for this Site,Set the Service Window for this Site";
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        // Declare local variable varsiteid,FlagInsertSla and FlagStatus
        int varsiteid;
        ServiceWindow_mst objservicewindow = new ServiceWindow_mst();
        varsiteid = Convert.ToInt16(drpSites.SelectedValue);
        int count = objservicewindow.Get_ServiceWindow_By_Siteid(varsiteid);
        if (count >= 1)
        {
            int FlagInsertSla;
            int FlagStatus;
            bool FlagEscalateLevel1 = true;
            bool FlagEscalateLevel2 = true;
            bool FlagEscalateLevel3 = true;
            lblErrorTimeSelect.Text = "";
            if (txtDays.Text == "0" && drphr.SelectedValue == "0" && drpMin.SelectedValue == "0")
            {
                lblErrorTimeSelect.Text = Resources.MessageResource.errResTime.ToString();
            }
            else
            {

                if (chkLevel1.Checked == true)
                {
                    if (radio1Level1.Checked == true)
                    {
                        int varTotalTime = calculateTotalminutes();
                        int varTotalTimeLevel1 = calculateTotalminutesLevel1();
                        if (varTotalTimeLevel1 > varTotalTime)
                        { FlagEscalateLevel1 = false; }
                    }
                    if (radio2Level1.Checked == true)
                    {
                        int varTotalTime = calculateTotalminutes();
                        int varTotalTimeLevel1 = calculateTotalminutesLevel1();
                        if (varTotalTimeLevel1 ==0)
                        { FlagEscalateLevel1 = false; }
                    }

                }
                if (chkLevel2.Checked == true)
                {
                    if (radio1Level2.Checked == true)
                    {
                        int varTotalTime = calculateTotalminutes();
                        int varTotalTimeLevel2 = calculateTotalminutesLevel2();
                        if (varTotalTimeLevel2 > varTotalTime)
                        { FlagEscalateLevel2 = false; }
                    }
                    if (radio2Level2.Checked == true)
                    {
                        int varTotalTime = calculateTotalminutes();
                        int varTotalTimeLevel2 = calculateTotalminutesLevel2();
                        if (varTotalTimeLevel2 == 0)
                        { FlagEscalateLevel2 = false; }
                    }

                }

                if (chkLevel3.Checked == true)
                {
                    if (radio1Level3.Checked == true)
                    {
                        int varTotalTime = calculateTotalminutes();
                        int varTotalTimeLevel3 = calculateTotalminutesLevel3();
                        if (varTotalTimeLevel3 > varTotalTime)
                        { FlagEscalateLevel3 = false; }
                    }

                    if (radio2Level3.Checked == true)
                    {
                        int varTotalTime = calculateTotalminutes();
                        int varTotalTimeLevel3 = calculateTotalminutesLevel3();
                        if (varTotalTimeLevel3 == 0)
                        { FlagEscalateLevel3 = false; }
                    }

                }

                // get sitetd from dropdown to variable varsiteid

                // Check SLA Definition is exist in database with same name and site
                objSla = objSla.Get_By_SLAName(txtSlaName.Text.ToString().Trim(), varsiteid);
                // Check SLA Priority definition is exist in databse with siteid and priorityid
                objSlaPriority = objSlaPriority.Get_By_Siteid(varsiteid, Convert.ToInt16(drpPriority.SelectedValue));
                // if both objSla.Siteid and objSlaPriority.Slaid is zero then,No SLA Definition is exist in database
                if (objSla.Siteid == 0 && objSlaPriority.Slaid == 0)
                {

                    if (FlagEscalateLevel1 == true && FlagEscalateLevel2 == true && FlagEscalateLevel3 == true)
                    {

                        objSla.Siteid = varsiteid;
                        objSla.Slaname = txtSlaName.Text.ToString().Trim();
                        objSla.Createdatetime = DateTime.Now.ToString();
                        objSla.Enable = true;
                        objSla.Description = txtDescription.Text.ToString().Trim();
                        // Call objSla.Insert() to insert records in database
                        FlagInsertSla = objSla.Insert();
                        // If FlagInsertSla is 1 then record insert in database successfully
                        if (FlagInsertSla == 1)
                        {
                            // Call Function objSla.Get_By_SLAName() to get Slaid of created sla
                            objSla = objSla.Get_By_SLAName(txtSlaName.Text.ToString().Trim(), varsiteid);

                            if (objSla.Siteid != 0)
                            {
                                // declare local variable FlagInsertPriority
                                int FlagInsertPriority;
                                objSlaPriority.Slaid = objSla.Slaid;
                                objSlaPriority.Siteid = varsiteid;
                                objSlaPriority.Priorityid = Convert.ToInt16(drpPriority.SelectedValue);
                                objSlaPriority.Resolutiondays = Convert.ToInt16(txtDays.Text);
                                objSlaPriority.Resolutionhours = Convert.ToInt16(drphr.SelectedValue);
                                objSlaPriority.Resolutionmin = Convert.ToInt16(drpMin.SelectedValue);
                                // Call function objSlaPriority.Insert() to insert records in SLA_Priority_mst
                                FlagInsertPriority = objSlaPriority.Insert();
                                // if FlagInsertPriority is not zero then records insert successfully
                                if (FlagInsertPriority != 0)
                                {
                                    //lblErrorMsg.Text = Resources.MessageResource.errSLADef.ToString();

                                    if (chkLevel1.Checked == true)
                                    {
                                        InsertIntoLevel1(objSla.Slaid);
                                    }
                                    if (chkLevel2.Checked == true)
                                    {
                                        InsertIntoLevel2(objSla.Slaid);
                                    }
                                    if (chkLevel3.Checked == true)
                                    {
                                        InsertIntoLevel3(objSla.Slaid);
                                    }

                                    Clear();
                                    Response.Redirect("~/admin/viewsla.aspx");
                                    //CheckDefaultValueForEscalation();
                                }
                                else
                                {
                                    // Call objSla.Delete to delete record from SLA_mst to delete sla definition,because some error occurred in SLA_Priority_mst
                                    objSla.Delete(objSla.Slaid);
                                    // Display Error message some error occurred
                                    lblErrorMsg.Text = Resources.MessageResource.errOccured.ToString();
                                }

                            }

                        }
                    }
                    else
                    {
                        if (FlagEscalateLevel1 == false)
                        {
                            lblErrorMsg.Text = Resources.MessageResource.strLevel1.ToString();

                        }
                        if (FlagEscalateLevel2 == false)
                        {
                            lblErrorMsg.Text = Resources.MessageResource.strLevel2.ToString();

                        }
                        if (FlagEscalateLevel3 == false)
                        {
                            lblErrorMsg.Text = Resources.MessageResource.strLevel3.ToString();

                        }

                    }
                }
                else
                {

                    lblErrorMsg.Text = Resources.MessageResource.errSLAExist.ToString();
                }
            }
        }
        else
        {
            lblErrorMsg.Text = "Service Window not set for this Site,Set the Service Window for this Site";
        }
    }
    public int GetResolutionTimeInMins(int slaid)
    {
        int varDays=0;
        int varHours=0;
        int VarMins=0;
        int TotalMins=0;
        objSlaPriority = objSlaPriority.Get_By_id(slaid);
        if (objSlaPriority.Slaid != 0)
        {
            varDays = objSlaPriority.Resolutiondays;
            varHours = objSlaPriority.Resolutionhours;
            VarMins = objSlaPriority.Resolutionmin;
            TotalMins = (varDays * 24 * 60) + (varHours * 60) + VarMins;
        }

        return TotalMins;
    }
 public int Update_SLA_Priority_mst_By_id(SLA_Priority_mst objSLAPriority)
 {
     return (int)ExecuteNonQuery(Sp_SLA_Priority_Update, new object[] { objSLAPriority.Slaid, objSLAPriority.Responsemin, objSLAPriority.Responsehours, objSLAPriority.Responsedays, objSLAPriority.Resolutionmin, objSLAPriority.Resolutionhours, objSLAPriority.Resolutiondays, objSLAPriority.Priorityid, objSLAPriority.Siteid });
 }
    public object GenerateSLAPriority_mstObject(ref IDataReader returnData)
    {
        SLA_Priority_mst obj = new SLA_Priority_mst();
        while (returnData.Read())
        {

            obj.Slaid = (int)returnData["Slaid"];
            obj.Siteid = (int)returnData["Siteid"];
            obj.Priorityid = (int)returnData["Priorityid"];
            obj.Resolutiondays = (int)returnData["Resolutiondays"];
            obj.Resolutionhours = (int)returnData["Resolutionhours"];
            obj.Resolutionmin = (int)returnData["Resolutionmin"];
            obj.Responsedays = (int)returnData["Responsedays"];
            obj.Responsehours = (int)returnData["Responsehours"];
            obj.Responsemin = (int)returnData["Responsemin"];
        }
        returnData.Close();
        returnData.Dispose();
        return obj;
    }