Exemplo n.º 1
0
        /*
         * /// <summary>
         * /// 分页获取数据列表
         * /// </summary>
         * public DataSet GetList(int PageSize,int PageIndex,string strWhere)
         * {
         *  SqlParameter[] parameters = {
         *          new SqlParameter("@tblName", SqlDbType.VarChar, 255),
         *          new SqlParameter("@fldName", SqlDbType.VarChar, 255),
         *          new SqlParameter("@PageSize", SqlDbType.Int),
         *          new SqlParameter("@PageIndex", SqlDbType.Int),
         *          new SqlParameter("@IsReCount", SqlDbType.Bit),
         *          new SqlParameter("@OrderType", SqlDbType.Bit),
         *          new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
         *          };
         *  parameters[0].Value = "subject_detail";
         *  parameters[1].Value = "id";
         *  parameters[2].Value = PageSize;
         *  parameters[3].Value = PageIndex;
         *  parameters[4].Value = 0;
         *  parameters[5].Value = 0;
         *  parameters[6].Value = strWhere;
         *  return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
         * }*/

        /// <summary>
        /// 根据大类目,小类目获取信息
        /// </summary>
        public Model.subject_detail GetModel(int bSbuject, int sSubject)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from subject_detail");
            strSql.Append(" where b_subject=@b_subject ");
            strSql.Append(" and s_subject=@s_subject ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@b_subject", SqlDbType.Int, 4),
                new SqlParameter("@s_subject", SqlDbType.Int, 4)
            };
            parameters[0].Value = bSbuject;
            parameters[1].Value = sSubject;

            Model.subject_detail model = new Model.subject_detail();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
 private void ShowInfo(int _id)
 {
     BLL.subject_detail   bll   = new BLL.subject_detail();
     Model.subject_detail model = bll.GetModel(_id);
     ddlBSubject.SelectedValue = model.b_subject.ToString();
     ddlSSubject.SelectedValue = model.s_subject.ToString();
     txtAmount.Text            = model.amount.ToString();
 }
Exemplo n.º 3
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.subject_detail   bll   = new BLL.subject_detail();
            Model.subject_detail model = bll.GetModel(_id);
            model.b_subject = Utils.StrToInt(ddlBSubject.SelectedValue.ToString(), 0);
            model.s_subject = Utils.StrToInt(ddlSSubject.SelectedValue.ToString(), 0);
            model.amount    = Utils.StrToDecimal(Utils.ObjectToStr(txtAmount.Text.Trim()), 0);
            if (bll.Update(model))
            {
                //AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改科目明细"); //记录日志
                result = true;
            }
            return(result);
        }
Exemplo n.º 4
0
        private bool DoAdd()
        {
            bool result = false;

            Model.subject_detail model = new Model.subject_detail();
            BLL.subject_detail   bll   = new BLL.subject_detail();

            model.b_subject = Utils.StrToInt(ddlBSubject.SelectedValue.ToString(), 0);
            model.s_subject = Utils.StrToInt(ddlSSubject.SelectedValue.ToString(), 0);
            model.amount    = Utils.StrToDecimal(Utils.ObjectToStr(txtAmount.Text.Trim()), 0);

            if (bll.Add(model) > 0)
            {
                //AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加科目明细频道内容"); //记录日志
                result = true;
            }
            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.subject_detail model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        #region 修改主表数据==========================
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("update subject_detail set ");
                        strSql.Append("b_subject=@b_subject,");
                        strSql.Append("s_subject=@s_subject,");
                        strSql.Append("amount=@amount");
                        strSql.Append(" where id=@id ");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@b_subject", SqlDbType.Int,     4),
                            new SqlParameter("@s_subject", SqlDbType.Int,     4),
                            new SqlParameter("@amount",    SqlDbType.Decimal, 9),
                            new SqlParameter("@id",        SqlDbType.Int, 4)
                        };
                        parameters[0].Value = model.b_subject;
                        parameters[1].Value = model.s_subject;
                        parameters[2].Value = model.amount;
                        parameters[3].Value = model.id;
                        DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters);
                        #endregion

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(false);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.subject_detail model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        #region 添加主表数据====================
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into subject_detail(");
                        strSql.Append("b_subject,s_subject,amount)");
                        strSql.Append(" values (");
                        strSql.Append("@b_subject,@s_subject,@amount)");
                        strSql.Append(";select @@IDENTITY");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@b_subject", SqlDbType.Int,     4),
                            new SqlParameter("@s_subject", SqlDbType.Int,     4),
                            new SqlParameter("@amount",    SqlDbType.Decimal, 9)
                        };
                        parameters[0].Value = model.b_subject;
                        parameters[1].Value = model.s_subject;
                        parameters[2].Value = model.amount;
                        //添加主表数据
                        object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务
                        model.id = Convert.ToInt32(obj);
                        #endregion

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(0);
                    }
                }
            }
            return(model.id);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 查询记账明细
        /// </summary>
        public Model.subject_detail GetModel(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from subject_detail");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }

            Model.subject_detail model = new Model.subject_detail();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.subject_detail DataRowToModel(DataRow row)
 {
     Model.subject_detail model = new Model.subject_detail();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["b_subject"] != null && row["b_subject"].ToString() != "")
         {
             model.b_subject = int.Parse(row["b_subject"].ToString());
         }
         if (row["s_subject"] != null && row["s_subject"].ToString() != "")
         {
             model.s_subject = int.Parse(row["s_subject"].ToString());
         }
         if (row["amount"] != null && row["amount"].ToString() != "")
         {
             model.amount = decimal.Parse(row["amount"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 9
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.subject_detail GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,b_subject,s_subject,amount from subject_detail ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Model.subject_detail model = new Model.subject_detail();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.subject_detail model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 11
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.subject_detail model)
 {
     return(dal.Add(model));
 }