public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { FunctionDeptVo inVo = (FunctionDeptVo)vo; StringBuilder sql = new StringBuilder(); sql.Append("update vcb_functiondept set vcb_functiondept_cd =:vcb_functiondept_cd, vcb_functiondept_name =:vcb_functiondept_name, user_name =:user_name, vcb_department_id =:vcb_department_id"); sql.Append(" where vcb_functiondept_id =:vcb_functiondept_id"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("vcb_functiondept_cd", inVo.FunctionDeptCode); sqlParameter.AddParameterString("vcb_functiondept_name", inVo.FunctionDeptName); sqlParameter.AddParameterString("user_name", inVo.UserName); sqlParameter.AddParameterInteger("vcb_department_id", inVo.DepartmentId); sqlParameter.AddParameterInteger("vcb_functiondept_id", inVo.FunctionDeptId); //execute SQL FunctionDeptVo outVo = new FunctionDeptVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { FunctionDeptVo inVo = (FunctionDeptVo)vo; StringBuilder sql = new StringBuilder(); ValueObjectList <FunctionDeptVo> voList = new ValueObjectList <FunctionDeptVo>(); DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, string.Empty); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append(@"select distinct user_name from m_mes_user order by user_name"); //create command //DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (dataReader.Read()) { FunctionDeptVo outVo = new FunctionDeptVo { UserName = dataReader["user_name"].ToString() }; voList.add(outVo); } dataReader.Close(); return(voList); }
private void Delete_btn_Click(object sender, EventArgs e) { if (FunctionDeptDetails_dgv.Rows.Count > 0 && FunctionDeptDetails_dgv.DataSource != null) { try { if (MessageBox.Show("Do you want to delete this rows !", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { FunctionDeptVo selectedvo = (FunctionDeptVo)FunctionDeptDetails_dgv.CurrentRow.DataBoundItem; FunctionDeptVo outVo = new FunctionDeptVo(); outVo = (FunctionDeptVo)DefaultCbmInvoker.Invoke(new Cbm.DeleteFunctionDeptVCBCbm(), selectedvo); if (outVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, functioncode_lbl + " : " + FunctionCode_txt.Text); logger.Info(messageData); popUpMessage.Information(messageData, Text); } GridBind(); } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { FunctionDeptVo inVo = (FunctionDeptVo)vo; StringBuilder sql = new StringBuilder(); DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, string.Empty); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append("delete from vcb_functiondept Where 1=1 "); if (inVo.FunctionDeptId > 0) { sql.Append(" and vcb_functiondept_id = :vcb_functiondept_id "); sqlParameter.AddParameterInteger("vcb_functiondept_id", inVo.FunctionDeptId); } //create command sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL FunctionDeptVo outVo = new FunctionDeptVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { FunctionDeptVo inVo = (FunctionDeptVo)vo; StringBuilder sql = new StringBuilder(); sql.Append("insert into vcb_functiondept(vcb_department_id, vcb_functiondept_cd, vcb_functiondept_name, user_name, registration_user_cd, registration_date_time, factory_cd) "); sql.Append("values(:vcb_department_id, :vcb_functiondept_cd, :vcb_functiondept_name, :user_name, :registration_user_cd, now(), :factory_cd)"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("vcb_department_id", inVo.DepartmentId); sqlParameter.AddParameterString("vcb_functiondept_cd", inVo.FunctionDeptCode); sqlParameter.AddParameterString("vcb_functiondept_name", inVo.FunctionDeptName); sqlParameter.AddParameterString("user_name", inVo.UserName); sqlParameter.AddParameterString("factory_cd", inVo.FactoryCode); sqlParameter.AddParameterString("registration_user_cd", inVo.RegistrationUserCode); //execute SQL FunctionDeptVo outVo = new FunctionDeptVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
private void Update_btn_Click(object sender, EventArgs e) { if (FunctionDeptDetails_dgv.DataSource != null) { FunctionDeptVo selectedvo = (FunctionDeptVo)FunctionDeptDetails_dgv.CurrentRow.DataBoundItem; if (new AddFuntionDepartmentForm { functiondeptvo = selectedvo }.ShowDialog() == DialogResult.OK) { GridBind(); } } }
private void Ok_btn_Click(object sender, EventArgs e) { if (checkdata()) { FunctionDeptVo outvo = new FunctionDeptVo(); FunctionDeptVo invo = new FunctionDeptVo() { FunctionDeptId = functiondeptvo.FunctionDeptId, DepartmentId = ((DepartmentVo)this.DeptCode_cmb.SelectedItem).DepartmentId, FunctionDeptCode = FunctionCode_txt.Text, FunctionDeptName = FunctionName_txt.Text, UserName = UserName_cmb.Text, FactoryCode = UserData.GetUserData().FactoryCode, RegistrationUserCode = UserData.GetUserData().UserCode }; try { if (invo.FunctionDeptId > 0) { outvo = (FunctionDeptVo)DefaultCbmInvoker.Invoke(new Cbm.UpdateFunctionDeptVCBCbm(), invo); } else { outvo = (FunctionDeptVo)DefaultCbmInvoker.Invoke(new Cbm.AddFunctionDeptVCBCbm(), invo); } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } if (outvo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, functioncode_lbl.Text + " : " + FunctionCode_txt.Text); logger.Info(messageData); popUpMessage.Information(messageData, Text); return; } } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { FunctionDeptVo inVo = (FunctionDeptVo)vo; StringBuilder sql = new StringBuilder(); DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, string.Empty); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append("Select Count(*) as FunctionCount "); sql.Append(" from vcb_functiondept"); sql.Append(" Where 1=1 "); if (!string.IsNullOrEmpty(inVo.FunctionDeptCode)) { sql.Append(" and UPPER(vcb_functiondept_cd) = UPPER(:vcb_functiondept_cd) "); sqlParameter.AddParameterString("vcb_functiondept_cd", inVo.FunctionDeptCode); } if (inVo.FunctionDeptId > 0) { sql.Append(" and vcb_department_id != :vcb_department_id "); ///????? sqlParameter.AddParameterInteger("vcb_department_id", inVo.FunctionDeptId); } sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); FunctionDeptVo outVo = new FunctionDeptVo(); while (dataReader.Read()) { outVo.CheckRow = Convert.ToInt32(dataReader["FunctionCount"].ToString()); } dataReader.Close(); return(outVo); }
private void add_btn_Click(object sender, EventArgs e) { if (DeptCode_cmb.Text != "" && FunctionCode_cmb.Text != "" && UserName_cmb.Text != "") { FunctionDeptVo idvo = new FunctionDeptVo() { FunctionDeptId = ((FunctionDeptVo)this.UserName_cmb.SelectedItem).FunctionDeptId }; int id = idvo.FunctionDeptId; if (To_radio.Checked == true) { ListUser_dgv.Rows.Add(id, DeptCode_cmb.Text, FunctionCode_cmb.Text, UserName_cmb.Text, To_radio.Text); } else if (CC_radio.Checked == true) { ListUser_dgv.Rows.Add(id, DeptCode_cmb.Text, FunctionCode_cmb.Text, UserName_cmb.Text, CC_radio.Text); } } else { messageData = new MessageData("mmcc00005", Properties.Resources.mmcc00005, "Other avariable is null, pls, fill data"); popUpMessage.Warning(messageData, Text); } }
private void GridBind() { try { FunctionDeptVo invo = new FunctionDeptVo() { DepartmentCode = DeptCode_cmb.Text, FunctionDeptCode = FunctionCode_txt.Text, FunctionDeptName = FunctionName_txt.Text, UserName = UserName_cmb.Text, //AssetNo = }; ValueObjectList <FunctionDeptVo> listvo = (ValueObjectList <FunctionDeptVo>)DefaultCbmInvoker.Invoke(new Cbm.SearchFunctionDeptVCBCbm(), invo); FunctionDeptDetails_dgv.DataSource = listvo.GetList(); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { FunctionDeptVo inVo = (FunctionDeptVo)vo; StringBuilder sql = new StringBuilder(); ValueObjectList <FunctionDeptVo> voList = new ValueObjectList <FunctionDeptVo>(); DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, string.Empty); DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sql.Append(@"select c.vcb_functiondept_id, c.vcb_functiondept_cd, c.vcb_functiondept_name, c.user_name, c.registration_user_cd, c.registration_date_time, c.factory_cd, b.vcb_department_cd, b.vcb_department_name from vcb_functiondept c left join vcb_department b on c.vcb_department_id = b.vcb_department_id Where 1=1 "); if (!string.IsNullOrEmpty(inVo.FunctionDeptCode)) { sql.Append(" and c.vcb_functiondept_cd = :vcb_functiondept_cd "); sqlParameter.AddParameterString("vcb_functiondept_cd", inVo.FunctionDeptCode); } if (!string.IsNullOrEmpty(inVo.FunctionDeptName)) { sql.Append(" and c.vcb_functiondept_name = :vcb_functiondept_name "); sqlParameter.AddParameterString("vcb_functiondept_name", inVo.FunctionDeptName); } if (!string.IsNullOrEmpty(inVo.DepartmentCode)) { sql.Append(" and b.vcb_department_cd = :vcb_department_cd "); sqlParameter.AddParameterString("vcb_department_cd", inVo.DepartmentCode); } //if (!string.IsNullOrEmpty(inVo.UserName)) //{ // sql.Append(" and c.user_name = :user_name "); // sqlParameter.AddParameterString("user_name", inVo.UserName); //} if (inVo.HienThi == 1) { sql.Append(" and c.user_name != :tenhienthi"); sqlParameter.AddParameter("tenhienthi", inVo.TenHienThi); } //create command //DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString()); //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); while (dataReader.Read()) { FunctionDeptVo outVo = new FunctionDeptVo { DepartmentCode = dataReader["vcb_department_cd"].ToString(), DepartmentName = dataReader["vcb_department_name"].ToString(), FunctionDeptId = int.Parse(dataReader["vcb_functiondept_id"].ToString()), FunctionDeptCode = dataReader["vcb_functiondept_cd"].ToString(), FunctionDeptName = dataReader["vcb_functiondept_name"].ToString(), UserName = dataReader["user_name"].ToString(), RegistrationUserCode = dataReader["registration_user_cd"].ToString(), RegistrationDateTime = DateTime.Parse(dataReader["registration_date_time"].ToString()), FactoryCode = dataReader["factory_cd"].ToString() }; voList.add(outVo); } dataReader.Close(); return(voList); }