示例#1
0
        private ContractBillModel _DataBind(int Code)
        {
            ContractBillModel model   = new ContractBillModel();
            StringBuilder     builder = new StringBuilder();

            builder.Append("select * from ContractBill ");
            builder.Append(" where Code=@Code");
            this._DataProcess.CommandText = builder.ToString();
            this._DataProcess.ProcessParametersAdd("@Code", SqlDbType.Int, 4, Code);
            SqlDataReader sqlDataReader = null;

            try
            {
                try
                {
                    sqlDataReader = this._DataProcess.GetSqlDataReader();
                    while (sqlDataReader.Read())
                    {
                        this.Initialize(sqlDataReader, model);
                    }
                }
                catch (SqlException exception)
                {
                    throw exception;
                }
            }
            finally
            {
                if (sqlDataReader != null)
                {
                    sqlDataReader.Close();
                }
            }
            return(model);
        }
示例#2
0
        private int _Update(ContractBillModel mObj)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update ContractBill set ");
            if (mObj.ProjectCode != null)
            {
                builder.Append("ProjectCode=@ProjectCode,");
                this._DataProcess.ProcessParametersAdd("@ProjectCode", SqlDbType.VarChar, 50, mObj.ProjectCode);
            }
            if (mObj.ContractCode != null)
            {
                builder.Append("ContractCode=@ContractCode,");
                this._DataProcess.ProcessParametersAdd("@ContractCode", SqlDbType.VarChar, 50, mObj.ContractCode);
            }
            if (mObj.BillNo != null)
            {
                builder.Append("BillNo=@BillNo,");
                this._DataProcess.ProcessParametersAdd("@BillNo", SqlDbType.VarChar, 50, mObj.BillNo);
            }
            if (mObj.BillMoney != 0M)
            {
                builder.Append("BillMoney=@BillMoney,");
                this._DataProcess.ProcessParametersAdd("@BillMoney", SqlDbType.Decimal, 9, mObj.BillMoney);
            }
            builder.Remove(builder.Length - 1, 1);
            builder.Append(" where Code=@Code");
            this._DataProcess.ProcessParametersAdd("@Code", SqlDbType.Int, 4, mObj.Code);
            this._DataProcess.CommandText = builder.ToString();
            return(this._DataProcess.RunSql());
        }
示例#3
0
        private List <ContractBillModel> _Select(ContractBillQueryModel qmObj)
        {
            List <ContractBillModel> list    = new List <ContractBillModel>();
            StringBuilder            builder = new StringBuilder();

            builder.Append("select * from ContractBill ");
            builder.Append(qmObj.QueryConditionStr);
            if (qmObj.SortColumns.Length == 0)
            {
                builder.Append(" ORDER BY Code desc");
            }
            else
            {
                builder.Append(" ORDER BY " + qmObj.SortColumns);
            }
            this._DataProcess.CommandText   = builder.ToString();
            this._DataProcess.SqlParameters = qmObj.Parameters;
            SqlDataReader sqlDataReader = null;
            int           num           = 0;

            try
            {
                try
                {
                    sqlDataReader = this._DataProcess.GetSqlDataReader();
                    while (sqlDataReader.Read())
                    {
                        if ((num >= qmObj.StartRecord) && ((list.Count < qmObj.MaxRecords) || (qmObj.MaxRecords == -1)))
                        {
                            ContractBillModel model = new ContractBillModel();
                            this.Initialize(sqlDataReader, model);
                            list.Add(model);
                        }
                        num++;
                    }
                }
                catch (SqlException exception)
                {
                    throw exception;
                }
            }
            finally
            {
                if (sqlDataReader != null)
                {
                    sqlDataReader.Close();
                }
            }
            return(list);
        }
示例#4
0
        private int _Insert(ContractBillModel mObj)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into ContractBill(");
            builder.Append("ProjectCode,ContractCode,BillNo,BillMoney)");
            builder.Append(" values (");
            builder.Append("@ProjectCode,@ContractCode,@BillNo,@BillMoney) ");
            builder.Append("SELECT @Code = SCOPE_IDENTITY()");
            this._DataProcess.CommandText = builder.ToString();
            this._DataProcess.ProcessParametersAdd("@ProjectCode", SqlDbType.VarChar, 50, mObj.ProjectCode);
            this._DataProcess.ProcessParametersAdd("@ContractCode", SqlDbType.VarChar, 50, mObj.ContractCode);
            this._DataProcess.ProcessParametersAdd("@BillNo", SqlDbType.VarChar, 50, mObj.BillNo);
            this._DataProcess.ProcessParametersAdd("@BillMoney", SqlDbType.Decimal, 9, mObj.BillMoney);
            SqlParameter parameter = this._DataProcess.ProcessParametersAdd("@Code", SqlDbType.Int, 4, null);

            parameter.Direction = ParameterDirection.Output;
            this._DataProcess.RunSql();
            mObj.Code = (int)parameter.Value;
            return(mObj.Code);
        }
示例#5
0
 private void Initialize(SqlDataReader reader, ContractBillModel obj)
 {
     if (reader.GetValue(0) != DBNull.Value)
     {
         obj.Code = reader.GetInt32(0);
     }
     if (reader.GetValue(1) != DBNull.Value)
     {
         obj.ProjectCode = reader.GetString(1);
     }
     if (reader.GetValue(2) != DBNull.Value)
     {
         obj.ContractCode = reader.GetString(2);
     }
     if (reader.GetValue(3) != DBNull.Value)
     {
         obj.BillNo = reader.GetString(3);
     }
     if (reader.GetValue(4) != DBNull.Value)
     {
         obj.BillMoney = reader.GetDecimal(4);
     }
 }
示例#6
0
 public int Update(ContractBillModel mObj)
 {
     return(this._Update(mObj));
 }
示例#7
0
 public int Insert(ContractBillModel mObj)
 {
     return(this._Insert(mObj));
 }
示例#8
0
 public int Delete(ContractBillModel mObj)
 {
     return(this._Delete(mObj.Code));
 }