public void AddFormula(object sender, EventArgs e) { IView view = ViewManager.GetInstance().GetView(TrendViewConst.AddFormulaData, m_View.ViewID); FormulaDataController ctl = (FormulaDataController)(view.getController()); ctl.SetFormType(FormType.Add); ((FormulaData)(view)).SetFormType(FormType.Add); List <string> FormulaNameList = new List <string>(); foreach (DataRow dataRow in m_FormulaTable.Rows) { FormulaNameList.Add(dataRow["DATA_PT_LBL_NAME"].ToString()); } ctl.InitFormulaData(FormulaNameList); view.ShowView(true); }
// this func is changed. public void EditFormula(string formulaName) { List <string> otherFormulaNameList = new List <string>(); foreach (DataRow Formula in m_FormulaTable.Select("DATA_PT_LBL_NAME <> '" + formulaName + "'")) { otherFormulaNameList.Add(Formula["DATA_PT_LBL_NAME"].ToString()); } foreach (DataRow dataRow in m_FormulaTable.Select("DATA_PT_LBL_NAME = '" + formulaName + "'")) //will only be one row, because we don't allow duplicate name { IView view = ViewManager.GetInstance().GetView(TrendViewConst.EditFormulaData, m_View.ViewID); ((FormulaData)view).SetFormType(FormType.Edit); FormulaDataController ctl = (FormulaDataController)(view.getController()); ctl.SetFormType(FormType.Edit); ctl.InitFormulaData(dataRow, otherFormulaNameList); view.ShowView(true); } }