예제 #1
0
        protected void AddSalaryStandardValue_Click(object source, EventArgs e)
        {
            SalaryStandardValue standardValue = new SalaryStandardValue();
            standardValue.SalaryItemId = int.Parse(this.hf_SalaryItemId.Value.Trim());
            standardValue.SalaryItemValue = CommonUtility.ConvertFormatedFloat("{0:F2}", this.SalaryStandardValue.Text.Trim());

            dalssv.AddStandardValue(standardValue);

            Javascript.Alert("添加标准金额成功!", Page);
            BindStandardValueList(int.Parse(this.hf_SalaryItemId.Value.Trim()));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="standardValue"></param>
        public void AddStandardValue(SalaryStandardValue standardValue)
        {
            try
            {
                string commandString = "INSERT INTO usta_SalaryStandardValue(salaryItemId, salaryItemValue, createdTime) VALUES(@salaryItemId, @salaryItemValue, @createdTime)";

                SqlParameter[] parameters = new SqlParameter[]{
              new SqlParameter("@salaryItemId", standardValue.SalaryItemId),
              new SqlParameter("@salaryItemValue", standardValue.SalaryItemValue),
              new SqlParameter("@createdTime", DateTime.Now)
            };

                SqlHelper.ExecuteNonQuery(conn, CommandType.Text, commandString, parameters);
            }
            catch (Exception ex)
            {
                MongoDBLog.LogRecord(ex);
                CommonUtility.RedirectUrl();
            }
            finally
            {
                conn.Close();
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="standardValueList"></param>
        private void BuildSalaryStandardValue(IDataReader reader, List<SalaryStandardValue> standardValueList)
        {
            SalaryStandardValue standardValue;
            while (reader.Read()) {

                standardValue = new SalaryStandardValue();
                standardValue.SalaryStandardValueId = int.Parse(reader["SalaryStandardValueId"].ToString().Trim());
                standardValue.SalaryItemId = int.Parse(reader["SalaryItemId"].ToString().Trim());
                standardValue.SalaryItemValue = float.Parse(reader["salaryItemValue"].ToString().Trim());
                standardValue.CreatedTime = DateTime.Parse(reader["createdTime"].ToString().Trim());

                standardValueList.Add(standardValue);
            }
        }