Advertisement
Guest User

Untitled

a guest
May 4th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.40 KB | None | 0 0
  1. enter code here string strSelectedValue = string.Empty;
  2. string strObligationID = HttpContext.Current.Request.QueryString["ObligationId"];
  3. string strContractID = HttpContext.Current.Request.QueryString["ItemId"];
  4. string strSource = HttpContext.Current.Request.QueryString["Source"];
  5. enter code here private void bindValueToControls()
  6. {
  7. try
  8. {
  9. objObligation = new ObligationManager.ObligationManager();
  10. SPListItem oitem = objObligation.GetObligationByID(strObligationID);
  11. if (oitem != null)
  12. {
  13.  
  14. txtObligationTitle.Text = Convert.ToString(oitem["Title"]);
  15. txtObligationDescription.Text = Convert.ToString(oitem["ObligationDescription"]);
  16. ddlObligationType.ClearSelection();
  17. if (!string.IsNullOrEmpty(Convert.ToString(oitem["ObligationType"])))
  18. ddlObligationType.Items.FindByText(Convert.ToString(oitem["ObligationType"]).Split('#')[1]).Selected = true;
  19. //txtObligationValue.Text = Convert.ToString(oitem["ObligationValue"]);
  20. strSelectedValue = Convert.ToString(oitem["RelatedToMilestoneYes"]);
  21.  
  22.  
  23. if (!string.IsNullOrEmpty(strSelectedValue))
  24. {
  25. if (strSelectedValue == "True")
  26. {
  27. cbMilestone.Checked = true;
  28. }
  29. else
  30. {
  31. cbMilestone.Checked = false;
  32. }
  33. }
  34.  
  35.  
  36.  
  37. private void BindObligationType()
  38. {
  39. try
  40. {
  41. DataTable aDtblOblType = objObligation.GetObligationsType();
  42.  
  43. if (aDtblOblType != null)
  44. {
  45. DataRow dataRow = aDtblOblType.NewRow();
  46. dataRow["Title"] = Convert.ToString(objutility.GetResourceString("Obligation_Type_Validation"));
  47. dataRow["ContentTypeName"] = "None";
  48. aDtblOblType.Rows.InsertAt(dataRow, 0);
  49.  
  50. ddlObligationType.DataSource = aDtblOblType;
  51. ddlObligationType.DataValueField = "ContentTypeName";
  52. ddlObligationType.DataTextField = "Title";
  53. ddlObligationType.DataBind();
  54. }
  55.  
  56.  
  57. catch (Exception ex)
  58. {
  59. isPass = false;
  60. errorMessage = ex;
  61. IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent();
  62. ILogger logger = serviceLocator.GetInstance<ILogger>();
  63. }
  64.  
  65.  
  66. private void AddUpdateObligation()
  67. {
  68. try
  69. {
  70. SPFieldUserValue UserName = null;
  71. SPUser User = null;
  72. if ((rblRelatedMilestone.SelectedItem.Text == objutility.GetResourceString("Yes") && dtcObligationDate.IsDateEmpty != true && dtcObligationDate.IsValid == true) || (rblRelatedMilestone.SelectedItem.Text == objutility.GetResourceString("No")))
  73. {
  74. Hashtable ht = new Hashtable();
  75.  
  76. //if (pnlContentType.HasControls())
  77. //ht = objutility.GetControlValueInHashTable(pnlContentType, objutility.GetListNameFromResource("Obligations_ListTitle"), ddlObligationType.SelectedItem.Value);
  78.  
  79. if (pnlContentType.Controls.Count > 1)
  80. {
  81. ht = objutility.GetControlValueInHashTable(pnlContentType, objutility.GetListNameFromResource("Obligations_ListTitle"), ddlObligationType.SelectedItem.Value);
  82. }
  83.  
  84. ht.Add("Title", txtObligationTitle.Text);
  85. ht.Add("ObligationDescription", txtObligationDescription.Text);
  86. ContractManager.ContractManager conMgr = new ContractManager.ContractManager();
  87. SPListItem obligationTypeItem = conMgr.GetIDByColumn("Obligation_Types_ListTitle", "Title", ddlObligationType.SelectedItem.Text);
  88. SPFieldLookupValue lookupField = new SPFieldLookupValue(obligationTypeItem.ID, ddlObligationType.SelectedItem.Text);
  89. ht.Add("ObligationType", lookupField);
  90.  
  91. if (cbMilestone.Checked == true)
  92. {
  93. ht.Add("RelatedToMilestoneYes", true);
  94. }
  95. else
  96. {
  97. ht.Add("RelatedToMilestoneYes", false);
  98. }
  99.  
  100.  
  101.  
  102. //ht.Add("RelatedToMilestoneYes", false);
  103. if (rbObligationOwner.SelectedItem.Text.ToLower() == "self")
  104. {
  105.  
  106.  
  107. //For SP2013
  108. var users = (List<string>)ViewState["ObligationOwner"];
  109. SPFieldUserValueCollection UserCollection = new SPFieldUserValueCollection();
  110. if (users != null)
  111. UserCollection = objutility.GetPeopleValueWithEnsureUser(peObligationOwner, users.ToArray());
  112.  
  113. if (UserCollection.Count > 0)
  114. {
  115. ht.Add("ObligationOwner", UserCollection);
  116. }
  117. else
  118. {
  119. User = SPContext.Current.Web.CurrentUser;
  120. if (User != null)
  121. UserName = new SPFieldUserValue(SPContext.Current.Web, User.ID, User.LoginName);
  122. ht.Add("ObligationOwner", UserName);
  123. }
  124.  
  125. ht.Add("ExternalOwner", "");
  126. }
  127. else
  128. {
  129. ht.Add("ObligationOwner", null);
  130. ht.Add("ExternalOwner", txtCounterParties.Text);
  131. }
  132.  
  133. ht.Add("ObligationOwnership", rbObligationOwner.SelectedItem.Text);
  134.  
  135. strSelectedValue = rblRelatedMilestone.SelectedValue;
  136. if (strSelectedValue == objutility.GetResourceString("Yes"))
  137. {
  138. ht.Add("ObligationDate", dtcObligationDate.SelectedDate);
  139. }
  140. else
  141. {
  142. ht.Add("ObligationDate", null);
  143. }
  144.  
  145. strSelectedValue = rblObligationMet.SelectedValue;
  146. if (strSelectedValue == objutility.GetResourceString("Yes"))
  147. {
  148. ht.Add("ObligationMet", true);
  149. ht.Add("ObligationStatus", objutility.GetListNameFromResource("Completed"));
  150. }
  151. else
  152. {
  153. ht.Add("ObligationMet", false);
  154. ht.Add("ObligationStatus", objutility.GetListNameFromResource("InComplete"));
  155. }
  156.  
  157. //ht.Add("ObligationValue", txtObligationValue.Text);
  158. ht.Add("ObligationNotes", txtObligationNote.Text);
  159. SPListItem oitem = objObligation.GetObligationByID(strObligationID);
  160.  
  161. HttpContext context = HttpContext.Current;
  162. SPListItem oitemid = null;
  163. ContractManager.ContractManager objcontractmgr = new ContractManager.ContractManager();
  164. if (oitem != null)
  165. {
  166. strContractID = Convert.ToString(oitem["ContractID"]).Split(';').First();
  167. SPFieldLookupValue ofieldlokup = new SPFieldLookupValue(Convert.ToString(oitem["ContractID"]));
  168. if (ofieldlokup != null)
  169. {
  170.  
  171. }
  172. else
  173. {
  174. IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent();
  175. ILogger logger = serviceLocator.GetInstance<ILogger>();
  176. logger.TraceToDeveloper("Webparts_Manage_ObligationUserControl::AddUpdateObligation_" + Convert.ToString(oitem["ContractID"]) + "_SPFieldLookupValue ofieldlokup not found", Error_Code.OBLIGATIONS_1702, TraceSeverity.High,
  177. string.Format("{0}/{1}", Error_Area_Category.AREA_COREVO, Error_Area_Category.CATEGORY_OBLIGATIONS));
  178. }
  179.  
  180. }
  181. else
  182. {
  183. ht.Add("ContractID", strContractID);
  184. SPListItem ocontractitem = objcontractmgr.GetContractByContractID(strContractID);
  185. oitemid = objObligation.AddObligation(ht);
  186. }
  187.  
  188. if (cbMilestone.Checked == true)
  189. {
  190. //if (HttpContext.Current.Request.QueryString["IsDlg"] != null)
  191. //{
  192. // Response.Redirect(strSource, false);
  193. //}
  194. //else
  195. //{
  196. if (oitemid != null)
  197. {
  198. string strUrl = string.Empty;
  199.  
  200. if (objutility.IsBusinessUser())
  201. strUrl = SPContext.Current.Site.Url + "/BusinessUserPages/BUCreateMilestone.aspx?ObligationID=" + oitemid.ID + "&ItemId=" + strContractID + "&Source=" + strSource + "";
  202. else if (objcontractmgr.GetContentClassByContractID(strContractID) == "RFP")
  203. strUrl = SPContext.Current.Site.Url + "/SitePages/CreateRFPMilestone.aspx?ObligationID=" + oitemid.ID + "&ItemId=" + strContractID + "&Source=" + strSource + "";
  204. else if (Request.RawUrl.Contains("SetupCreateObligation.aspx"))
  205. strUrl = SPContext.Current.Site.Url + "/SitePages/SetupManageMilestones.aspx?ObligationID=" + oitemid.ID + "&ItemId=" + strContractID + "&Source=" + strSource + "";
  206. else
  207. strUrl = SPContext.Current.Site.Url + "/SitePages/CreateMilestone.aspx?ObligationID=" + oitemid.ID + "&ItemId=" + strContractID + "&Source=" + strSource + "";
  208.  
  209. if (Request.RawUrl.Contains("SetupCreateObligation.aspx"))
  210. {
  211. hdnURL.Value = strUrl;
  212. ScriptManager.RegisterStartupScript(Update1, Update1.GetType(), "OpenConfirm", "ExecuteOrDelayUntilScriptLoaded(OpenConfirmMilestonePopup, 'sp.ui.dialog.js');", true);
  213. }
  214. else
  215. {
  216. if (!string.IsNullOrEmpty(strObligationID))
  217. Message("alert('" + objutility.GetResourceString("Update_Obligation_Msg") + "');window.location='" + strUrl + "';", Update1);
  218. else
  219. Message("alert('" + objutility.GetResourceString("Success_Obligation") + "');window.location='" + strUrl + "';", Update1);
  220. }
  221.  
  222. }
  223. else
  224. {
  225. IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent();
  226. ILogger logger = serviceLocator.GetInstance<ILogger>();
  227. logger.TraceToDeveloper("Webparts_Manage_ObligationUserControl::AddUpdateObligation_" + "SPListItem oitemid not found", Error_Code.OBLIGATIONS_1702, TraceSeverity.High,
  228. string.Format("{0}/{1}", Error_Area_Category.AREA_COREVO, Error_Area_Category.CATEGORY_OBLIGATIONS));
  229. }
  230. //}
  231. }
  232. else
  233. {
  234. string strURL = "";
  235. string strContID = strContractID;
  236. if (objutility.IsBusinessUser())
  237. strURL = SPContext.Current.Web.Url + "/BusinessUserPages/BUObligationDetails.aspx?ItemID=" + strContID;
  238. else if (objcontractmgr.GetContentClassByContractID(strContID) == "RFP")
  239. strURL = SPContext.Current.Web.Url + "/SitePages/RFPObligationDetails.aspx?ItemID=" + strContID;
  240. else
  241. strURL = SPContext.Current.Web.Url + "/SitePages/ObligationDetails.aspx?ItemID=" + strContID;
  242.  
  243. if (!string.IsNullOrEmpty(Convert.ToString(HttpContext.Current.Request.QueryString["IsDlg"])))
  244. {
  245. if (!string.IsNullOrEmpty(strObligationID))
  246. Message("alert('" + objutility.GetResourceString("Update_Obligation_Msg") + "');window.frameElement.commitPopup();window.location='" + strURL + "';", Update1);
  247. else
  248. Message("alert('" + objutility.GetResourceString("Success_Obligation") + "');window.frameElement.commitPopup();window.location='" + strURL + "';", Update1);
  249. }
  250. else
  251. Message("alert('" + objutility.GetResourceString("Success_Obligation") + "');window.location='" + strURL + "';", Update1);
  252.  
  253. }
  254.  
  255. }
  256. }
  257. catch (Exception ex)
  258. {
  259. isPass = false;
  260. errorMessage = ex;
  261. IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent();
  262. ILogger logger = serviceLocator.GetInstance<ILogger>();
  263. }
  264.  
  265.  
  266. /// <summary>
  267.  
  268. protected void btnOk_Click(object sender, EventArgs e)
  269. {
  270. try
  271. {
  272. AddUpdateObligation();
  273. }
  274. catch (Exception ex)
  275. {
  276. isPass = false;
  277. errorMessage = ex;
  278. IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent();
  279. ILogger logger = serviceLocator.GetInstance<ILogger>();
  280.  
  281. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement