protected void btnupdate_Click(object sender, EventArgs e) {///Add Exception handilng try catch change by vishal 21-05-2012 try { TextBox txtp1 = (TextBox)PlaceHolderParams.FindControl("txtparam1Id"); TextBox txtp2 = (TextBox)PlaceHolderParams.FindControl("txtparam2Id"); TextBox txtp3 = (TextBox)PlaceHolderParams.FindControl("txtparam3Id"); TextBox txtp4 = (TextBox)PlaceHolderParams.FindControl("txtparam4Id"); TextBox txtp5 = (TextBox)PlaceHolderParams.FindControl("txtparam5Id"); TextBox txtp6 = (TextBox)PlaceHolderParams.FindControl("txtparam6Id"); TextBox txtp7 = (TextBox)PlaceHolderParams.FindControl("txtparam7Id"); TextBox txtp8 = (TextBox)PlaceHolderParams.FindControl("txtparam8Id"); TextBox txtp9 = (TextBox)PlaceHolderParams.FindControl("txtparam9Id"); TextBox txtp10 = (TextBox)PlaceHolderParams.FindControl("txtparam10Id"); int Incidentidforchange = Convert.ToInt32(Session["Incidentidforchange"]); ObjIncidentochange = ObjIncidentochange.Get_By_Incidentid(Incidentidforchange); int changeid = Convert.ToInt32(ObjIncidentochange.Changeid); Objincludeasset = Objincludeasset.Get_By_Changeid(changeid); int Assetid = Convert.ToInt32(Objincludeasset.Assetid); ObjConfiguration = ObjConfiguration.Get_By_id(Assetid); int itemid = Convert.ToInt32(ObjConfiguration.Itemid); ObjConfigurableitem = ObjConfigurableitem.Get_By_id(itemid); ObjCMDB = ObjCMDB.Get_By_id(Assetid); //ObjCMDB.Assetid = ObjConfiguration.Assetid; CMDB objcmdb = new CMDB(); objcmdb.Assetid = ObjConfiguration.Assetid; if (ObjConfigurableitem.Param1 != "") { if (txtp1.Text == ObjCMDB.Param1) { objcmdb.Param1 = txtp1.Text.ToString(); } else { objcmdb.Param1 = txtp1.Text.ToString(); Objcmdbtrans.Currentvalue = txtp1.Text.ToString(); Objcmdbtrans.Previousvalue = ObjCMDB.Param1; Objcmdbtrans.Assetid = ObjConfiguration.Assetid; Objcmdbtrans.Parametername = ObjConfigurableitem.Param1; Objcmdbtrans.Insert(); } } else { objcmdb.Param1 = ObjCMDB.Param1; } if (ObjConfigurableitem.Param2 != "") { if (txtp2.Text == ObjCMDB.Param2) { objcmdb.Param2 = txtp2.Text.ToString(); } else { objcmdb.Param2 = txtp2.Text.ToString(); Objcmdbtrans.Currentvalue = txtp2.Text.ToString(); Objcmdbtrans.Previousvalue = ObjCMDB.Param2; Objcmdbtrans.Assetid = ObjConfiguration.Assetid; Objcmdbtrans.Parametername = ObjConfigurableitem.Param2; Objcmdbtrans.Insert(); } } else { objcmdb.Param2 = ObjCMDB.Param2; } if (ObjConfigurableitem.Param3 != "") { if (txtp3.Text == ObjCMDB.Param3) { objcmdb.Param3 = txtp3.Text.ToString(); } else { objcmdb.Param3 = txtp3.Text.ToString(); Objcmdbtrans.Currentvalue = txtp3.Text.ToString(); Objcmdbtrans.Previousvalue = ObjCMDB.Param3; Objcmdbtrans.Assetid = ObjConfiguration.Assetid; Objcmdbtrans.Parametername = ObjConfigurableitem.Param3; Objcmdbtrans.Insert(); } } else { objcmdb.Param3 = ObjCMDB.Param3; } if (ObjConfigurableitem.Param4 != "") { if (txtp4.Text == ObjCMDB.Param4) { objcmdb.Param4 = txtp4.Text.ToString(); } else { objcmdb.Param4 = txtp4.Text.ToString(); Objcmdbtrans.Currentvalue = txtp4.Text.ToString(); Objcmdbtrans.Previousvalue = ObjCMDB.Param4; Objcmdbtrans.Assetid = ObjConfiguration.Assetid; Objcmdbtrans.Parametername = ObjConfigurableitem.Param4; Objcmdbtrans.Insert(); } } else { objcmdb.Param4 = ObjCMDB.Param4; } if (ObjConfigurableitem.Param5 != "") { if (txtp5.Text == ObjCMDB.Param5) { objcmdb.Param5 = txtp5.Text.ToString(); } else { objcmdb.Param5 = txtp5.Text.ToString(); Objcmdbtrans.Currentvalue = txtp5.Text.ToString(); Objcmdbtrans.Previousvalue = ObjCMDB.Param5; Objcmdbtrans.Assetid = ObjConfiguration.Assetid; Objcmdbtrans.Parametername = ObjConfigurableitem.Param5; Objcmdbtrans.Insert(); } } else { objcmdb.Param5 = ObjCMDB.Param5; } if (ObjConfigurableitem.Param6 != "") { if (txtp6.Text == ObjCMDB.Param6) { objcmdb.Param6 = txtp6.Text.ToString(); } else { objcmdb.Param6 = txtp6.Text.ToString(); Objcmdbtrans.Currentvalue = txtp6.Text.ToString(); Objcmdbtrans.Previousvalue = ObjCMDB.Param6; Objcmdbtrans.Assetid = ObjConfiguration.Assetid; Objcmdbtrans.Parametername = ObjConfigurableitem.Param6; Objcmdbtrans.Insert(); } } else { objcmdb.Param6 = ObjCMDB.Param6; } if (ObjConfigurableitem.Param7 != "") { if (txtp7.Text == ObjCMDB.Param7) { objcmdb.Param7 = txtp7.Text.ToString(); } else { objcmdb.Param7 = txtp7.Text.ToString(); Objcmdbtrans.Currentvalue = txtp7.Text.ToString(); Objcmdbtrans.Previousvalue = ObjCMDB.Param7; Objcmdbtrans.Assetid = ObjConfiguration.Assetid; Objcmdbtrans.Parametername = ObjConfigurableitem.Param7; Objcmdbtrans.Insert(); } } else { objcmdb.Param7 = ObjCMDB.Param7; } if (ObjConfigurableitem.Param8 != "") { if (txtp8.Text == ObjCMDB.Param8) { objcmdb.Param8 = txtp8.Text.ToString(); } else { objcmdb.Param8 = txtp8.Text.ToString(); Objcmdbtrans.Currentvalue = txtp8.Text.ToString(); Objcmdbtrans.Previousvalue = ObjCMDB.Param8; Objcmdbtrans.Assetid = ObjConfiguration.Assetid; Objcmdbtrans.Parametername = ObjConfigurableitem.Param8; Objcmdbtrans.Insert(); } } else { objcmdb.Param8 = ObjCMDB.Param8; } if (ObjConfigurableitem.Param9 != "") { if (txtp8.Text == ObjCMDB.Param9) { objcmdb.Param9 = txtp9.Text.ToString(); } else { objcmdb.Param9 = txtp9.Text.ToString(); Objcmdbtrans.Currentvalue = txtp9.Text.ToString(); Objcmdbtrans.Previousvalue = ObjCMDB.Param9; Objcmdbtrans.Assetid = ObjConfiguration.Assetid; Objcmdbtrans.Parametername = ObjConfigurableitem.Param9; Objcmdbtrans.Insert(); } } else { objcmdb.Param9 = ObjCMDB.Param9; } if (ObjConfigurableitem.Param10 != "") { if (txtp10.Text == ObjCMDB.Param10) { objcmdb.Param10 = txtp10.Text.ToString(); } else { objcmdb.Param10 = txtp10.Text.ToString(); Objcmdbtrans.Currentvalue = txtp10.Text.ToString(); Objcmdbtrans.Previousvalue = ObjCMDB.Param10; Objcmdbtrans.Assetid = ObjConfiguration.Assetid; Objcmdbtrans.Parametername = ObjConfigurableitem.Param10; Objcmdbtrans.Insert(); } } else { objcmdb.Param10 = ObjCMDB.Param10; } objcmdb.Update(); Configuration_mst obj = new Configuration_mst(); obj.Assetid = ObjConfiguration.Assetid; obj.Vendorid = ObjConfiguration.Vendorid; obj.Itemid = ObjConfiguration.Itemid; obj.Serialno = ObjConfiguration.Serialno; int versionno = ObjConfiguration.Version; versionno = versionno + 1; obj.Version = versionno; obj.Siteid = ObjConfiguration.Siteid; obj.Severity = ObjConfiguration.Severity; obj.Purchasedate = ObjConfiguration.Purchasedate; obj.Update(); Session["CMDBUpdate"] = "true"; string myScript; //myScript = "<script language=javascript>javascript:window.close();</script>"; ScriptManager.RegisterStartupScript(this, this.GetType(), "refreshParent();", "refreshParent();", true); // Page.RegisterClientScriptBlock("MyScript", myScript); } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
protected void btnsave_Click(object sender, EventArgs e) {////Add Exception handilng try catch change by vishal 21-05-2012 try { int site = Convert.ToInt32(drpSites.SelectedValue); // string val =txtparam1.Text; // TextBox text = .FindControl("text" + i.ToString()) as TextBox; TextBox txtp1 = (TextBox)PlaceHolderParams.FindControl("txtparam1Id"); TextBox txtp2 = (TextBox)PlaceHolderParams.FindControl("txtparam2Id"); TextBox txtp3 = (TextBox)PlaceHolderParams.FindControl("txtparam3Id"); TextBox txtp4 = (TextBox)PlaceHolderParams.FindControl("txtparam4Id"); TextBox txtp5 = (TextBox)PlaceHolderParams.FindControl("txtparam5Id"); TextBox txtp6 = (TextBox)PlaceHolderParams.FindControl("txtparam6Id"); TextBox txtp7 = (TextBox)PlaceHolderParams.FindControl("txtparam7Id"); TextBox txtp8 = (TextBox)PlaceHolderParams.FindControl("txtparam8Id"); TextBox txtp9 = (TextBox)PlaceHolderParams.FindControl("txtparam9Id"); TextBox txtp10 = (TextBox)PlaceHolderParams.FindControl("txtparam10Id"); // Response.Write(test.Text); //string abc = txtparam1.Text; int itemid1 = Convert.ToInt32(drpitem.SelectedValue); string vardate2 = ""; string vardate; int vendorid = Convert.ToInt32(drpVendor.SelectedValue); int siteid = Convert.ToInt32(drpSites.SelectedValue); string severity = drpPriority.SelectedValue; string serilo = txtitemsrlno.Text.ToString(); ObjConfigurationmst.Itemid = itemid1; ObjConfigurationmst.Serialno = serilo; ObjConfigurationmst.Siteid = siteid; ObjConfigurationmst.Severity = severity; ObjConfigurationmst.Vendorid = vendorid; DateTime Date = new DateTime(); string[] tempdate = txtpdate.Text.ToString().Split(("/").ToCharArray()); vardate = tempdate[2] + "-" + tempdate[1] + "-" + tempdate[0]; vardate2 = vardate; //Date = Convert.ToDateTime(vardate2); ObjConfigurationmst.Purchasedate = vardate2.ToString(); ObjConfigurationmst.Insert(); int Assetid = ObjConfigurationmst.Get_Current_Assetid(); int itemid = Convert.ToInt32(drpitem.SelectedValue); ObjConfigurableitem = ObjConfigurableitem.Get_By_id(itemid); objcmdb.Assetid = Assetid; if (ObjConfigurableitem.Param1 != "") { objcmdb.Param1 = txtp1.Text.ToString(); } else { objcmdb.Param1 = ""; } if (ObjConfigurableitem.Param2 != "") { objcmdb.Param2 = txtp2.Text.ToString(); } else { objcmdb.Param2 = ""; } if (ObjConfigurableitem.Param3 != "") { objcmdb.Param3 = txtp3.Text.ToString(); } else { objcmdb.Param3 = ""; } if (ObjConfigurableitem.Param4 != "") { objcmdb.Param4 = txtp4.Text.ToString(); } else { objcmdb.Param4 = ""; } if (ObjConfigurableitem.Param5 != "") { objcmdb.Param5 = txtp5.Text.ToString(); } else { objcmdb.Param5 = ""; } if (ObjConfigurableitem.Param6 != "") { objcmdb.Param6 = txtp6.Text.ToString(); } else { objcmdb.Param6 = ""; } if (ObjConfigurableitem.Param7 != "") { objcmdb.Param7 = txtp7.Text.ToString(); } else { objcmdb.Param7 = ""; } if (ObjConfigurableitem.Param8 != "") { objcmdb.Param8 = txtp8.Text.ToString(); } else { objcmdb.Param8 = ""; } if (ObjConfigurableitem.Param9 != "") { objcmdb.Param9 = txtp9.Text.ToString(); } else { objcmdb.Param9 = ""; } if (ObjConfigurableitem.Param10 != "") { objcmdb.Param10 = txtp10.Text.ToString(); } else { objcmdb.Param10 = ""; } objcmdb.Param11 = ""; objcmdb.Param12 = ""; objcmdb.Param13 = ""; objcmdb.Param14 = ""; objcmdb.Param15 = ""; objcmdb.Insert(); lblmsg.Visible = true; lblmsg.Text = "Service Product Added Successfully"; drpCustomer.SelectedValue = "0"; drpSites.SelectedValue = "0"; drpVendor.SelectedValue = "0"; drpPriority.SelectedValue = "0"; drpitem.SelectedValue = "0"; txtpdate.Text = ""; txtparam1.Visible = false; lblparam1.Visible = false; txtparam2.Visible = false; lblparam2.Visible = false; txtparam3.Visible = false; lblparam3.Visible = false; txtparam4.Visible = false; lblparam4.Visible = false; txtparam5.Visible = false; lblparam5.Visible = false; txtparam6.Visible = false; lblparam6.Visible = false; txtparam7.Visible = false; lblparam7.Visible = false; txtparam8.Visible = false; lblparam8.Visible = false; txtparam9.Visible = false; lblparam9.Visible = false; txtparam10.Visible = false; lblparam10.Visible = false; } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }