protected void btnBindResource_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.hfldResourceId.Value)) { ISerializable serializable = new JsonSerializer(); string[] array = serializable.Deserialize <string[]>(this.hfldResourceId.Value); List <string> list = new List <string>(); if (array != null) { this.UpdateSelectResources(); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string item = array2[i]; list.Add(item); } List <ConstructResource> all = ConstructResource.GetAll(this.consTaskId, list); List <ConstructResource> list2 = this.ViewState["ResourcesList"] as List <ConstructResource>; foreach (ConstructResource current in all) { if (!list2.Contains(current)) { list2.Add(current); } } this.ViewState["ResourcesList"] = list2; this.gvResource.DataSource = list2; this.gvResource.DataBind(); } } this.hfldResourceId.Value = string.Empty; }
protected void BindGv() { this.GetCBS(); DataTable resInfo = ConstructResource.GetResInfo(this.consTaskId); this.gvResource.DataSource = resInfo; this.gvResource.DataBind(); }
protected void BindGv() { List <string> resourceIds = ConstructResource.GetResourceIds(this.consTaskId); List <ConstructResource> all = ConstructResource.GetAll(this.consTaskId, resourceIds); this.ViewState["ResourcesList"] = all; this.gvResource.DataSource = all; this.gvResource.DataBind(); }
public static bool Del(List <string> ids) { bool flag = false; CostAccounting accounting = new CostAccounting(); if (accounting.IsDelAll(ids)) { using (pm2Entities entities = new pm2Entities()) { using (List <string> .Enumerator enumerator = ids.GetEnumerator()) { string id; while (enumerator.MoveNext()) { id = enumerator.Current; Bud_CostAccounting entity = (from m in entities.Bud_CostAccounting where (m.Id == id) && (m.CBSCode.Length >= 6) select m).FirstOrDefault <Bud_CostAccounting>(); if (entity != null) { bool flag3 = true; string cBSCode = entity.CBSCode; if (entity.Type == "D") { flag3 = ConstructResource.IsExistCBSCode(cBSCode); } else { flag3 = IndirectBudget.IsExistCBSCode(cBSCode) || OrganizationBudget.IsExistCBSCode(cBSCode); } if (!flag3) { entities.DeleteObject(entity); entities.SaveChanges(); flag = true; } } } } } } return(flag); }
protected void btnSave_ServerClick(object sender, EventArgs e) { try { ConstructTask byId = ConstructTask.GetById(this.consTaskId); IList <ConstructResource> list = new List <ConstructResource>(); byId.ResourceList = list; foreach (GridViewRow gridViewRow in this.gvResource.Rows) { string resourceId = this.gvResource.DataKeys[gridViewRow.RowIndex].Value.ToString(); decimal quantity = Convert.ToDecimal(((TextBox)gridViewRow.FindControl("txtNumber")).Text); decimal unitPrice = Convert.ToDecimal(((TextBox)gridViewRow.FindControl("txtPrice")).Text); ConstructResource item = ConstructResource.Create(Guid.NewGuid().ToString(), this.consTaskId, resourceId, quantity, unitPrice); list.Add(item); } byId.ResourceList = list; ConstructTask.AddResource(byId); base.RegisterScript("winclose()"); } catch (Exception) { } }
protected bool IsDelAll(List <string> ids) { bool flag = true; using (pm2Entities entities = new pm2Entities()) { using (List <string> .Enumerator enumerator = ids.GetEnumerator()) { string id; while (enumerator.MoveNext()) { id = enumerator.Current; Bud_CostAccounting accounting = (from m in entities.Bud_CostAccounting where (m.Id == id) && (m.CBSCode.Length >= 6) select m).FirstOrDefault <Bud_CostAccounting>(); if (accounting != null) { bool flag2 = true; string cBSCode = accounting.CBSCode; if (accounting.Type == "D") { flag2 = ConstructResource.IsExistCBSCode(cBSCode); } else { flag2 = IndirectBudget.IsExistCBSCode(cBSCode) || OrganizationBudget.IsExistCBSCode(cBSCode); } if (flag2) { return(false); } } } return(flag); } } }
protected void gvTask_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex > -1) { string text = this.gvTask.DataKeys[e.Row.RowIndex].Value.ToString(); string text2 = this.gvTask.DataKeys[e.Row.RowIndex].Values[1].ToString(); e.Row.Attributes["id"] = text; e.Row.Attributes["onclick"] = string.Concat(new string[] { "displayRes('", text, "','", text2, "')" }); e.Row.Style.Add("cursor", "pointer"); HiddenField expr_E2 = this.hfldResInfo; expr_E2.Value = expr_E2.Value + "{\"Code\": \"" + text + "\",\"resources\": ["; DataTable resInfo = ConstructResource.GetResInfo(text); foreach (DataRow dataRow in resInfo.Rows) { HiddenField expr_129 = this.hfldResInfo; object value = expr_129.Value; expr_129.Value = string.Concat(new object[] { value, "{\"resCode\":\" ", dataRow["ResourceCode"], "\"," }); HiddenField expr_172 = this.hfldResInfo; object value2 = expr_172.Value; expr_172.Value = string.Concat(new object[] { value2, "\"consTaskResId\":\" ", dataRow["Id"], "\"," }); HiddenField expr_1BB = this.hfldResInfo; expr_1BB.Value = expr_1BB.Value + "\"num\":\" " + System.Convert.ToDecimal(dataRow["AccountingQuantity"]).ToString("0.000") + "\","; HiddenField expr_1F9 = this.hfldResInfo; object value3 = expr_1F9.Value; expr_1F9.Value = string.Concat(new object[] { value3, "\"cbsCode\":\" ", dataRow["CBSCode"], "\"}," }); } this.hfldResInfo.Value = this.hfldResInfo.Value.Remove(this.hfldResInfo.Value.LastIndexOf(',')); if (resInfo.Rows.Count > 0) { HiddenField expr_2A0 = this.hfldResInfo; expr_2A0.Value += "]},"; return; } HiddenField expr_2BC = this.hfldResInfo; expr_2BC.Value += "},"; } }