protected override bool SavePageData() { if (company == null) { return false; } try { icompany.Save(company); companyBakup = company.Clone() as Company; return true; } catch (BIZException be) { ShowErrorInfo("数据保存失败: " + be.Message); return false; } catch (DAOException de) { ShowErrorInfo("数据保存失败: " + de.Message); return false; } }
private void ReloadData() { try { company = icompany.getCompany(); taxTable = icompany.getTaxTable(); if (company != null) { companyBakup = company.Clone() as Company; } } catch (BIZException be) { ShowErrorInfo("公司信息读取失败: " + be.Message); company = null; companyBakup = null; } catch (DAOException de) { ShowErrorInfo("公司信息读取失败: " + de.Message); company = null; companyBakup = null; } }
protected override void RecoverData() { company = companyBakup.Clone() as Company; }
private SqlParameter[] CompanyToParam(Company comp, string curUser, bool isInsertOp) { List<SqlParameter> paras = new List<SqlParameter>(); paras.Add(new SqlParameter("@Name",SqlDbType.VarChar,100)); paras.Add(new SqlParameter("@TelNum",SqlDbType.VarChar,20)); paras.Add(new SqlParameter("@Legal",SqlDbType.VarChar,20)); paras.Add(new SqlParameter("@Addr",SqlDbType.VarChar,100)); paras.Add(new SqlParameter("@ZipCode",SqlDbType.VarChar,20)); paras.Add(new SqlParameter("@IndowRate",SqlDbType.Float)); paras.Add(new SqlParameter("@MedicalRate",SqlDbType.Float)); paras.Add(new SqlParameter("@UnEmpRate",SqlDbType.Float)); paras.Add(new SqlParameter("@EmpInjuryRate",SqlDbType.Float)); paras.Add(new SqlParameter("@HouseRate",SqlDbType.Float)); paras.Add(new SqlParameter("@TaxStart",SqlDbType.Float)); paras.Add(new SqlParameter("@UpdateUser", SqlDbType.VarChar, 20)); if (isInsertOp) { paras.Add(new SqlParameter("@CreateUser", SqlDbType.VarChar, 20)); } paras[0].Value = comp.Name; paras[1].Value = comp.TelNum; paras[2].Value = comp.Legal; paras[3].Value = comp.Address; paras[4].Value = comp.ZipCode; paras[5].Value = comp.IndowRate; paras[6].Value = comp.Medicalrate; paras[7].Value = comp.UnEmpRate; paras[8].Value = comp.EmpInjuryRate; paras[9].Value = comp.HouseRate; paras[10].Value = comp.TaxStart; paras[11].Value = curUser; if (isInsertOp) { paras[12].Value = curUser; } return paras.ToArray(); }
public int UpdateCompany(Company comp, string currentUser, SqlTransaction trans) { string sqlStr = dbUtil.getSqlStatement("SQL_COMP_UpdateCompany"); SqlParameter[] sqlParams = CompanyToParam(comp, currentUser, false); try { return (int)DAO.DBAccess.ExecuteNonQuery(trans, CommandType.Text, sqlStr, sqlParams); } catch (Exception ex) { throw new DAOException("E0001", ex); } }
public Company getCompany() { string sqlStr = dbUtil.getSqlStatement("SQL_COMP_GetCompany"); DataSet resultSet = null; try { Company comp = new Company(); resultSet = DAO.DBAccess.ExecuteAdapter(DAO.DBAccess.SQLConnectionString, CommandType.Text, sqlStr, null); UtilService utilService = new UtilService(); if (!utilService.isNullDataset(resultSet)) { DataRow dr = resultSet.Tables[0].Rows[0]; comp.Name = dr["Name"].ToString(); comp.TelNum = dr["TelNum"].ToString(); comp.Legal = dr["Legal"].ToString(); comp.Address = dr["Addr"].ToString(); comp.ZipCode = dr["ZipCode"].ToString(); comp.IndowRate = Convert.ToDouble(dr["IndowRate"]); comp.Medicalrate = Convert.ToDouble(dr["Medicalrate"]); comp.UnEmpRate = Convert.ToDouble(dr["UnEmpRate"]); comp.EmpInjuryRate = Convert.ToDouble(dr["EmpInjuryRate"]); comp.HouseRate = Convert.ToDouble(dr["HouseRate"]); comp.TaxStart = Convert.ToDouble(dr["TaxStart"]); } return comp; } catch (Exception ex) { throw new DAOException("E0001", ex); } }
public void Save(Company comp) { try { compDAO.UpdateCompany(comp, "N001"); } catch (DAOException) { throw; } }
public void getCompanyTest() { CompanyImpl target = new CompanyImpl(); // TODO: Initialize to an appropriate value Company expected = new Company(); // TODO: Initialize to an appropriate value Company actual; actual = target.getCompany(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }