protected void btnOverwrite_Click(object sender, EventArgs e)
 {
     try
     {
         if (Session["SignatureExistingData"] != null)
         {
             List <SignatureComparisionData> list = null;
             for (int i = 0; i < lvExistingSignature.Items.Count; i++)
             {
                 if ((lvExistingSignature.Items[i].FindControl("chkSelect") as CheckBox).Checked)
                 {
                     list = Session["SignatureExistingData"] as List <SignatureComparisionData>;
                     string company     = (lvExistingSignature.Items[i].FindControl("hdnComany") as HiddenField).Value;
                     string plant       = (lvExistingSignature.Items[i].FindControl("hdnPlant") as HiddenField).Value;
                     string machine     = (lvExistingSignature.Items[i].FindControl("hdnMachine") as HiddenField).Value;
                     string paremeter   = (lvExistingSignature.Items[i].FindControl("lblParameter") as Label).Text;
                     string signatureid = (lvExistingSignature.Items[i].FindControl("lblSignatureID") as Label).Text;
                     MongoDBAccess.deleteSignatureMasterData(company, plant, machine, paremeter, signatureid);
                     var destiList = list.Where(k => k.Company == company && k.Plant == plant && k.MachineID == machine && k.SignatureID == signatureid && k.ParameterID == paremeter).Select(k => k.SignatureData).ToList();
                     List <SignatureComparisionDetails> finalList = new List <SignatureComparisionDetails>();
                     foreach (var data in destiList)
                     {
                         for (int j = 0; j < data.Count; j++)
                         {
                             SignatureComparisionDetails seqData = new SignatureComparisionDetails();
                             seqData.CompanyID      = company;
                             seqData.PlantID        = plant;
                             seqData.MachineID      = machine;
                             seqData.ParameterID    = paremeter;
                             seqData.SignatureID    = signatureid;
                             seqData.Frequency      = data[j].Frequency;
                             seqData.ParameterValue = data[j].ParameterValue;
                             finalList.Add(seqData);
                         }
                     }
                     list.RemoveAll(k => k.Company == company && k.Plant == plant && k.MachineID == machine && k.SignatureID == signatureid && k.ParameterID == paremeter);
                     Session["SignatureExistingData"] = list;
                     MongoDBAccess.insertSignatureComparisonMasterData(finalList);
                 }
             }
             if (list.Count > 0)
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), "openModal", "openExistingSignatureDataModal();", true);
                 btnChangeSave.Visible          = false;
                 btnChange.Visible              = true;
                 btnChangeCancel.Visible        = false;
                 lvExistingSignature.DataSource = list;
                 lvExistingSignature.DataBind();
             }
         }
         BindSignatureDetails();
     }
     catch (Exception ex)
     { }
 }