/// <summary> /// 添加按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e)//添加按钮 { buttonchange1(); buttonchange(); txtModelTitle.Text = ""; txtModelContent.Text = ""; txtModelID.Text = ""; oper = operate.add; }
private void frmTemplateAdd_Load(object sender, EventArgs e) { ucGridviewX1.fg.ReadOnly = true; ucGridviewX1.fg.SelectionMode = DataGridViewSelectionMode.FullRowSelect; ucGridviewX1.fg.Click += new EventHandler(ClickGrid); cboType.SelectedIndex = 0; cboCondiction.SelectedIndex = 0; txtModelContent.Text = T_Content; oper = operate.add; ShowAllModel(); buttonchange(); buttonchange1(); }
/// <summary> /// 修改按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdate_Click(object sender, EventArgs e)//修改按钮 { buttonchange1(); buttonchange(); oper = operate.update; }
public void SetAddCallBack(operate opt) { this.opt = opt; }
private string parseMenuData(bool OnlyCheck, operate operatit, string companycode, string menucode, string menuname, string menunameEN, string menucodefather, string menulevel, string menuindex, string leafflag, string programcode) { //COMPANY_CODE,MENU_CODE, MENU_NAME,MENU_NAME_EN, MENU_CODE_FATHER, MENU_LEVEL, MENU_INDEX, LEAF_FLAG,PROGRAM_CODE //进行菜单数据CRUD之前的检查。 companycode = companycode == null ? "" : companycode.Trim(); menucode = menucode == null ? "" : menucode.Trim(); menuname = menuname == null ? "" : menuname.Trim(); menunameEN = menunameEN == null ? "" : menunameEN.Trim(); menucodefather = menucodefather == null ? "" : menucodefather.Trim(); menulevel = menulevel == null ? "" : menulevel.Trim(); menuindex = menuindex == null ? "" : menuindex.Trim(); programcode = programcode == null ? "" : programcode.Trim(); leafflag = programcode.Equals("") ? "N" : "Y"; if (string.Empty.Equals(companycode)) { return("公司代码为空,您的Session可能已经过期,请重新登录"); } if (string.Empty.Equals(menucode)) { return("菜单代码为空,请重新输入"); } if (string.Empty.Equals(menuname)) { return("菜单标题为空,请重新输入"); } if (string.Empty.Equals(menunameEN)) { return("菜单英文标题为空,请重新输入"); } if (string.Empty.Equals(menuindex)) { return("菜单索引为空,请重新输入"); } //if (string.Empty.Equals(menucodefather)) return "上级菜单为空,请重新输入"; //if (string.Empty.Equals(menulevel)) return "菜单层级为空,请重新输入"; //if (string.Empty.Equals(programcode)) return "为空,请重新输入"; string sql = ""; if (operatit == operate.AddNew) { sql = "select count(*) from CODE_MENU where MENU_CODE='" + menucode + "' and COMPANY_CODE='" + companycode + "'"; DataTable dt = conn.GetTable(sql); if (Convert.ToInt32(dt.Rows[0][0]) > 0) { return("已有相同的菜单编码\"" + menucode + "\",请重新输入。"); } } //CRUD if (!OnlyCheck)//如果不仅仅是检查数据,则进行CRUD操作,否则只执行上面的语句,进行数据检查。 { if (string.Empty.Equals(menulevel)) { menulevel = ASPxTreeList1.FocusedNode.HasChildren ? (ASPxTreeList1.FocusedNode.Level + 1).ToString() : ASPxTreeList1.FocusedNode.Level.ToString(); } if (string.Empty.Equals(menuindex)) { menuindex = "99"; } MenuItemEntity menu1 = new MenuItemEntity() { COMPANY_CODE = companycode, MENU_CODE = menucode, MENU_CODE_FATHER = menucodefather, LEAF_FLAG = leafflag, MENU_INDEX = Convert.ToInt32(menuindex), MENU_LEVEL = Convert.ToInt32(menulevel), MENU_NAME = menuname, MENU_NAME_EN = menunameEN, PROGRAM_CODE = programcode }; int ret = 0; object obj = null; string strReturn = "未知操作!"; switch (operatit) { case operate.AddNew: obj = MenuItemFactory.AddNew(menu1); if (obj != null) { strReturn = ""; } else { strReturn = "添加失败!"; } //sql = "INSERT INTO CODE_MENU (COMPANY_CODE, MENU_CODE, MENU_NAME, MENU_NAME_EN, MENU_CODE_FATHER, MENU_LEVEL,MENU_INDEX, LEAF_FLAG, PROGRAM_CODE) VALUES (:COMPANY_CODE, :MENU_CODE, :MENU_NAME, :MENU_NAME_EN, :MENU_CODE_FATHER, :MENU_LEVEL, :MENU_INDEX, :LEAF_FLAG, :PROGRAM_CODE)"; break; case operate.Update: ret = MenuItemFactory.Update(menu1); if (ret == 1) { strReturn = ""; } else { strReturn = "修改失败!"; } //sql = "UPDATE CODE_MENU SET MENU_NAME = :MENU_NAME, MENU_NAME_EN = :MENU_NAME_EN, MENU_CODE_FATHER = :MENU_CODE_FATHER, MENU_LEVEL = :MENU_LEVEL, MENU_INDEX = :MENU_INDEX, LEAF_FLAG = :LEAF_FLAG, PROGRAM_CODE = :PROGRAM_CODE WHERE COMPANY_CODE = :COMPANY_CODE AND MENU_CODE = :MENU_CODE"; break; case operate.Delete: ret = MenuItemFactory.Remove(menu1); if (ret == 1) { strReturn = ""; } else { strReturn = "移除失败!"; } //sql = "DELETE FROM CODE_MENU WHERE COMPANY_CODE = :COMPANY_CODE AND MENU_CODE = :MENU_CODE"; break; default: sql = ""; strReturn = "无效的操作"; break; } return(strReturn); ///以前用的是下面的sql方式,现在改为上面的Entity方式。 //if (sql == "") return "错误的SQL语句。"; //if (conn.theComd.Connection.State == ConnectionState.Closed) conn.theComd.Connection.Open(); //conn.theComd.CommandText = sql; //conn.theComd.Parameters.Clear(); //conn.theComd.Parameters.Add("COMPANY_CODE", Oracle.DataAccess.Client.OracleDbType.Varchar2).Value = companycode; //conn.theComd.Parameters.Add("MENU_CODE", Oracle.DataAccess.Client.OracleDbType.Varchar2).Value = menucode; //if (operatit != operate.Delete) //{ // conn.theComd.Parameters.Add("MENU_NAME", Oracle.DataAccess.Client.OracleDbType.Varchar2).Value = menuname; // conn.theComd.Parameters.Add("MENU_NAME_EN", Oracle.DataAccess.Client.OracleDbType.Varchar2).Value = menunameEN; // conn.theComd.Parameters.Add("MENU_CODE_FATHER", Oracle.DataAccess.Client.OracleDbType.Varchar2).Value = menucodefather; // conn.theComd.Parameters.Add("MENU_LEVEL", Oracle.DataAccess.Client.OracleDbType.Int32).Value = menulevel; // conn.theComd.Parameters.Add("MENU_INDEX", Oracle.DataAccess.Client.OracleDbType.Int32).Value = menuindex; // conn.theComd.Parameters.Add("LEAF_FLAG", Oracle.DataAccess.Client.OracleDbType.Varchar2).Value = leafflag; // conn.theComd.Parameters.Add("PROGRAM_CODE", Oracle.DataAccess.Client.OracleDbType.Varchar2).Value = programcode; //} //if (conn.theComd.ExecuteNonQuery() == 1) //{ // conn.theComd.Parameters.Clear(); // conn.theComd.Connection.Close(); // return ""; //} //else //{ // conn.theComd.Parameters.Clear(); // conn.theComd.Connection.Close(); // return "执行SQL出错!!"; //} } return(""); }