Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enter code here string strSelectedValue = string.Empty;
- string strObligationID = HttpContext.Current.Request.QueryString["ObligationId"];
- string strContractID = HttpContext.Current.Request.QueryString["ItemId"];
- string strSource = HttpContext.Current.Request.QueryString["Source"];
- enter code here private void bindValueToControls()
- {
- try
- {
- objObligation = new ObligationManager.ObligationManager();
- SPListItem oitem = objObligation.GetObligationByID(strObligationID);
- if (oitem != null)
- {
- txtObligationTitle.Text = Convert.ToString(oitem["Title"]);
- txtObligationDescription.Text = Convert.ToString(oitem["ObligationDescription"]);
- ddlObligationType.ClearSelection();
- if (!string.IsNullOrEmpty(Convert.ToString(oitem["ObligationType"])))
- ddlObligationType.Items.FindByText(Convert.ToString(oitem["ObligationType"]).Split('#')[1]).Selected = true;
- //txtObligationValue.Text = Convert.ToString(oitem["ObligationValue"]);
- strSelectedValue = Convert.ToString(oitem["RelatedToMilestoneYes"]);
- if (!string.IsNullOrEmpty(strSelectedValue))
- {
- if (strSelectedValue == "True")
- {
- cbMilestone.Checked = true;
- }
- else
- {
- cbMilestone.Checked = false;
- }
- }
- private void BindObligationType()
- {
- try
- {
- DataTable aDtblOblType = objObligation.GetObligationsType();
- if (aDtblOblType != null)
- {
- DataRow dataRow = aDtblOblType.NewRow();
- dataRow["Title"] = Convert.ToString(objutility.GetResourceString("Obligation_Type_Validation"));
- dataRow["ContentTypeName"] = "None";
- aDtblOblType.Rows.InsertAt(dataRow, 0);
- ddlObligationType.DataSource = aDtblOblType;
- ddlObligationType.DataValueField = "ContentTypeName";
- ddlObligationType.DataTextField = "Title";
- ddlObligationType.DataBind();
- }
- catch (Exception ex)
- {
- isPass = false;
- errorMessage = ex;
- IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent();
- ILogger logger = serviceLocator.GetInstance<ILogger>();
- }
- private void AddUpdateObligation()
- {
- try
- {
- SPFieldUserValue UserName = null;
- SPUser User = null;
- if ((rblRelatedMilestone.SelectedItem.Text == objutility.GetResourceString("Yes") && dtcObligationDate.IsDateEmpty != true && dtcObligationDate.IsValid == true) || (rblRelatedMilestone.SelectedItem.Text == objutility.GetResourceString("No")))
- {
- Hashtable ht = new Hashtable();
- //if (pnlContentType.HasControls())
- //ht = objutility.GetControlValueInHashTable(pnlContentType, objutility.GetListNameFromResource("Obligations_ListTitle"), ddlObligationType.SelectedItem.Value);
- if (pnlContentType.Controls.Count > 1)
- {
- ht = objutility.GetControlValueInHashTable(pnlContentType, objutility.GetListNameFromResource("Obligations_ListTitle"), ddlObligationType.SelectedItem.Value);
- }
- ht.Add("Title", txtObligationTitle.Text);
- ht.Add("ObligationDescription", txtObligationDescription.Text);
- ContractManager.ContractManager conMgr = new ContractManager.ContractManager();
- SPListItem obligationTypeItem = conMgr.GetIDByColumn("Obligation_Types_ListTitle", "Title", ddlObligationType.SelectedItem.Text);
- SPFieldLookupValue lookupField = new SPFieldLookupValue(obligationTypeItem.ID, ddlObligationType.SelectedItem.Text);
- ht.Add("ObligationType", lookupField);
- if (cbMilestone.Checked == true)
- {
- ht.Add("RelatedToMilestoneYes", true);
- }
- else
- {
- ht.Add("RelatedToMilestoneYes", false);
- }
- //ht.Add("RelatedToMilestoneYes", false);
- if (rbObligationOwner.SelectedItem.Text.ToLower() == "self")
- {
- //For SP2013
- var users = (List<string>)ViewState["ObligationOwner"];
- SPFieldUserValueCollection UserCollection = new SPFieldUserValueCollection();
- if (users != null)
- UserCollection = objutility.GetPeopleValueWithEnsureUser(peObligationOwner, users.ToArray());
- if (UserCollection.Count > 0)
- {
- ht.Add("ObligationOwner", UserCollection);
- }
- else
- {
- User = SPContext.Current.Web.CurrentUser;
- if (User != null)
- UserName = new SPFieldUserValue(SPContext.Current.Web, User.ID, User.LoginName);
- ht.Add("ObligationOwner", UserName);
- }
- ht.Add("ExternalOwner", "");
- }
- else
- {
- ht.Add("ObligationOwner", null);
- ht.Add("ExternalOwner", txtCounterParties.Text);
- }
- ht.Add("ObligationOwnership", rbObligationOwner.SelectedItem.Text);
- strSelectedValue = rblRelatedMilestone.SelectedValue;
- if (strSelectedValue == objutility.GetResourceString("Yes"))
- {
- ht.Add("ObligationDate", dtcObligationDate.SelectedDate);
- }
- else
- {
- ht.Add("ObligationDate", null);
- }
- strSelectedValue = rblObligationMet.SelectedValue;
- if (strSelectedValue == objutility.GetResourceString("Yes"))
- {
- ht.Add("ObligationMet", true);
- ht.Add("ObligationStatus", objutility.GetListNameFromResource("Completed"));
- }
- else
- {
- ht.Add("ObligationMet", false);
- ht.Add("ObligationStatus", objutility.GetListNameFromResource("InComplete"));
- }
- //ht.Add("ObligationValue", txtObligationValue.Text);
- ht.Add("ObligationNotes", txtObligationNote.Text);
- SPListItem oitem = objObligation.GetObligationByID(strObligationID);
- HttpContext context = HttpContext.Current;
- SPListItem oitemid = null;
- ContractManager.ContractManager objcontractmgr = new ContractManager.ContractManager();
- if (oitem != null)
- {
- strContractID = Convert.ToString(oitem["ContractID"]).Split(';').First();
- SPFieldLookupValue ofieldlokup = new SPFieldLookupValue(Convert.ToString(oitem["ContractID"]));
- if (ofieldlokup != null)
- {
- }
- else
- {
- IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent();
- ILogger logger = serviceLocator.GetInstance<ILogger>();
- logger.TraceToDeveloper("Webparts_Manage_ObligationUserControl::AddUpdateObligation_" + Convert.ToString(oitem["ContractID"]) + "_SPFieldLookupValue ofieldlokup not found", Error_Code.OBLIGATIONS_1702, TraceSeverity.High,
- string.Format("{0}/{1}", Error_Area_Category.AREA_COREVO, Error_Area_Category.CATEGORY_OBLIGATIONS));
- }
- }
- else
- {
- ht.Add("ContractID", strContractID);
- SPListItem ocontractitem = objcontractmgr.GetContractByContractID(strContractID);
- oitemid = objObligation.AddObligation(ht);
- }
- if (cbMilestone.Checked == true)
- {
- //if (HttpContext.Current.Request.QueryString["IsDlg"] != null)
- //{
- // Response.Redirect(strSource, false);
- //}
- //else
- //{
- if (oitemid != null)
- {
- string strUrl = string.Empty;
- if (objutility.IsBusinessUser())
- strUrl = SPContext.Current.Site.Url + "/BusinessUserPages/BUCreateMilestone.aspx?ObligationID=" + oitemid.ID + "&ItemId=" + strContractID + "&Source=" + strSource + "";
- else if (objcontractmgr.GetContentClassByContractID(strContractID) == "RFP")
- strUrl = SPContext.Current.Site.Url + "/SitePages/CreateRFPMilestone.aspx?ObligationID=" + oitemid.ID + "&ItemId=" + strContractID + "&Source=" + strSource + "";
- else if (Request.RawUrl.Contains("SetupCreateObligation.aspx"))
- strUrl = SPContext.Current.Site.Url + "/SitePages/SetupManageMilestones.aspx?ObligationID=" + oitemid.ID + "&ItemId=" + strContractID + "&Source=" + strSource + "";
- else
- strUrl = SPContext.Current.Site.Url + "/SitePages/CreateMilestone.aspx?ObligationID=" + oitemid.ID + "&ItemId=" + strContractID + "&Source=" + strSource + "";
- if (Request.RawUrl.Contains("SetupCreateObligation.aspx"))
- {
- hdnURL.Value = strUrl;
- ScriptManager.RegisterStartupScript(Update1, Update1.GetType(), "OpenConfirm", "ExecuteOrDelayUntilScriptLoaded(OpenConfirmMilestonePopup, 'sp.ui.dialog.js');", true);
- }
- else
- {
- if (!string.IsNullOrEmpty(strObligationID))
- Message("alert('" + objutility.GetResourceString("Update_Obligation_Msg") + "');window.location='" + strUrl + "';", Update1);
- else
- Message("alert('" + objutility.GetResourceString("Success_Obligation") + "');window.location='" + strUrl + "';", Update1);
- }
- }
- else
- {
- IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent();
- ILogger logger = serviceLocator.GetInstance<ILogger>();
- logger.TraceToDeveloper("Webparts_Manage_ObligationUserControl::AddUpdateObligation_" + "SPListItem oitemid not found", Error_Code.OBLIGATIONS_1702, TraceSeverity.High,
- string.Format("{0}/{1}", Error_Area_Category.AREA_COREVO, Error_Area_Category.CATEGORY_OBLIGATIONS));
- }
- //}
- }
- else
- {
- string strURL = "";
- string strContID = strContractID;
- if (objutility.IsBusinessUser())
- strURL = SPContext.Current.Web.Url + "/BusinessUserPages/BUObligationDetails.aspx?ItemID=" + strContID;
- else if (objcontractmgr.GetContentClassByContractID(strContID) == "RFP")
- strURL = SPContext.Current.Web.Url + "/SitePages/RFPObligationDetails.aspx?ItemID=" + strContID;
- else
- strURL = SPContext.Current.Web.Url + "/SitePages/ObligationDetails.aspx?ItemID=" + strContID;
- if (!string.IsNullOrEmpty(Convert.ToString(HttpContext.Current.Request.QueryString["IsDlg"])))
- {
- if (!string.IsNullOrEmpty(strObligationID))
- Message("alert('" + objutility.GetResourceString("Update_Obligation_Msg") + "');window.frameElement.commitPopup();window.location='" + strURL + "';", Update1);
- else
- Message("alert('" + objutility.GetResourceString("Success_Obligation") + "');window.frameElement.commitPopup();window.location='" + strURL + "';", Update1);
- }
- else
- Message("alert('" + objutility.GetResourceString("Success_Obligation") + "');window.location='" + strURL + "';", Update1);
- }
- }
- }
- catch (Exception ex)
- {
- isPass = false;
- errorMessage = ex;
- IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent();
- ILogger logger = serviceLocator.GetInstance<ILogger>();
- }
- /// <summary>
- protected void btnOk_Click(object sender, EventArgs e)
- {
- try
- {
- AddUpdateObligation();
- }
- catch (Exception ex)
- {
- isPass = false;
- errorMessage = ex;
- IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent();
- ILogger logger = serviceLocator.GetInstance<ILogger>();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement