/// <summary> /// Save exclusion rule /// </summary> private void Save() { //string containerTypeCode = ddlContainerType.SelectedValue; string msg = string.Empty; if (inputFormTypeCode != ' ') { for (int i = 0; i < dg.Rows.Count; i++) { TemplatedColumn col = (TemplatedColumn)dg.Rows[i].Cells.FromKey("Select").Column; CheckBox cb = (CheckBox)((CellItem)col.CellItems[i]).FindControl("g_sd"); string containerTypeCode = dg.Rows[i].Cells.FromKey("Code").ToString(); if (containerTypeCode.Length == 1 && cb.Checked) { InputFormTypeExclusionRule rule = new InputFormTypeExclusionRule(inputFormTypeCode, Convert.ToChar(containerTypeCode)); if (!rule.Save()) { msg = InputFormTypeExclusionRule.LastError + "\\n"; } } } } if (msg.Length == 0) { lbError.Text = "Data saved!"; lbError.CssClass = "hc_success"; lbError.Visible = true; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "update", "<script>UpdateParentWithClose();</script>"); } else { lbError.Text = msg; lbError.CssClass = "hc_error"; lbError.Visible = true; } }
private ContainerTypeList GetPossibleContainerTypes() { // result list of container type ContainerTypeList resultList = new ContainerTypeList(); // Get all container types using (ContainerTypeList containerTypes = ContainerType.GetAll()) { // Get all exclusion rules for this input form type (input form type code is not empty) string sqlFilter = "InputFormTypeCode = '" + inputFormTypeCode + "'"; using (InputFormTypeExclusionRuleList iftExclusionRules = InputFormTypeExclusionRule.GetAll(sqlFilter)) { // Delete container type already used if (containerTypes != null) { foreach (ContainerType ct in containerTypes) { bool isFound = false; if (iftExclusionRules != null) { foreach (InputFormTypeExclusionRule er in iftExclusionRules) { isFound = isFound || (er.ContainerTypeCode == ct.Code); } } if (!isFound) { resultList.Add(ct); } } } } } return(resultList); }