Ejemplo n.º 1
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 public List<Model.BillingInfo> CostContractDataTableToList(DataTable dt)
 {
     var modelList = new List<Model.BillingInfo>();
     int rowsCount = dt.Rows.Count;
     if (rowsCount > 0)
     {
         Model.BillingInfo model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new Model.BillingInfo();
             if (dt.Rows[n]["B_ID"] != null && dt.Rows[n]["B_ID"].ToString() != "")
             {
                 model.B_ID = decimal.Parse(dt.Rows[n]["B_ID"].ToString());
             }
             if (dt.Rows[n]["B_CID"] != null && dt.Rows[n]["B_CID"].ToString() != "")
             {
                 model.B_CID = decimal.Parse(dt.Rows[n]["B_CID"].ToString());
             }
             if (dt.Rows[n]["B_Type"] != null && dt.Rows[n]["B_Type"].ToString() != "")
             {
                 model.B_Type = int.Parse(dt.Rows[n]["B_Type"].ToString());
             }
             if (dt.Rows[n]["B_Limit"] != null && dt.Rows[n]["B_Limit"].ToString() != "")
             {
                 model.B_Limit = int.Parse(dt.Rows[n]["B_Limit"].ToString());
             }
             if (dt.Rows[n]["B_No"] != null && dt.Rows[n]["B_No"].ToString() != "")
             {
                 model.B_No = dt.Rows[n]["B_No"].ToString();
             }
             if (dt.Rows[n]["B_Amount"] != null && dt.Rows[n]["B_Amount"].ToString() != "")
             {
                 model.B_Amount = decimal.Parse(dt.Rows[n]["B_Amount"].ToString());
             }
             if (dt.Rows[n]["B_Date"] != null && dt.Rows[n]["B_Date"].ToString() != "")
             {
                 model.B_Date = DateTime.Parse(dt.Rows[n]["B_Date"].ToString());
                 model.Date = DateTime.Parse(dt.Rows[n]["B_Date"].ToString()).ToShortDateString();
             }
             if (dt.Rows[n]["B_Remark"] != null && dt.Rows[n]["B_Remark"].ToString() != "")
             {
                 model.B_Remark = dt.Rows[n]["B_Remark"].ToString();
             }
             if (dt.Rows[n]["B_Inputer"] != null && dt.Rows[n]["B_Inputer"].ToString() != "")
             {
                 model.B_Inputer = decimal.Parse(dt.Rows[n]["B_Inputer"].ToString());
             }
             if (dt.Rows[n]["B_Inputdate"] != null && dt.Rows[n]["B_Inputdate"].ToString() != "")
             {
                 model.B_Inputdate = DateTime.Parse(dt.Rows[n]["B_Inputdate"].ToString());
                 model.Inputdate = DateTime.Parse(dt.Rows[n]["B_Inputdate"].ToString()).ToShortDateString();
             }
             if (dt.Rows[n]["B_Editer"] != null && dt.Rows[n]["B_Editer"].ToString() != "")
             {
                 model.B_Editer = decimal.Parse(dt.Rows[n]["B_Editer"].ToString());
             }
             if (dt.Rows[n]["B_Editdate"] != null && dt.Rows[n]["B_Editdate"].ToString() != "")
             {
                 model.B_Editdate = DateTime.Parse(dt.Rows[n]["B_Editdate"].ToString());
                 model.Editdate = DateTime.Parse(dt.Rows[n]["B_Editdate"].ToString()).ToShortDateString();
             }
             if (dt.Rows[n]["B_State"] != null && dt.Rows[n]["B_State"].ToString() != "")
             {
                 model.B_State = int.Parse(dt.Rows[n]["B_State"].ToString());
             }
             if (dt.Rows[n]["Cc_Sco"] != null && dt.Rows[n]["Cc_Sco"].ToString() != "")
             {
                 model.Cc_Sco = dt.Rows[n]["Cc_Sco"].ToString();
             }
             if (dt.Rows[n]["U_RealName"] != null && dt.Rows[n]["U_RealName"].ToString() != "")
             {
                 model.U_RealName = dt.Rows[n]["U_RealName"].ToString();
             }
             if (dt.Rows[n]["Cc_Name"] != null && dt.Rows[n]["Cc_Name"].ToString() != "")
             {
                 model.Cc_Name = dt.Rows[n]["Cc_Name"].ToString();
             }
             if (dt.Rows[n]["Cc_No"] != null && dt.Rows[n]["Cc_No"].ToString() != "")
             {
                 model.Cc_No = dt.Rows[n]["Cc_No"].ToString();
             }
             if (dt.Rows[n]["Cc_State"] != null && dt.Rows[n]["Cc_State"].ToString() != "")
             {
                 model.Cc_State = int.Parse(dt.Rows[n]["Cc_State"].ToString());
             }
             modelList.Add(model);
         }
     }
     return modelList;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.BillingInfo GetModel(decimal B_ID)
        {
            var strSql = new StringBuilder();
            strSql.Append("select  top 1 B_ID,B_CID,B_Type,B_Limit,B_State,B_No,B_Amount,B_Date,B_Remark,B_Inputer,B_Inputdate,B_Editer,B_Editdate from tbl_BillingInfo ");
            strSql.Append(" where B_ID=@B_ID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@B_ID", SqlDbType.Decimal,9)			};
            parameters[0].Value = B_ID;

            Model.BillingInfo model = new Model.BillingInfo();
            DataSet ds = SqlHelper.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["B_ID"] != null && ds.Tables[0].Rows[0]["B_ID"].ToString() != "")
                {
                    model.B_ID = decimal.Parse(ds.Tables[0].Rows[0]["B_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["B_CID"] != null && ds.Tables[0].Rows[0]["B_CID"].ToString() != "")
                {
                    model.B_CID = decimal.Parse(ds.Tables[0].Rows[0]["B_CID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["B_Type"] != null && ds.Tables[0].Rows[0]["B_Type"].ToString() != "")
                {
                    model.B_Type = int.Parse(ds.Tables[0].Rows[0]["B_Type"].ToString());
                }
                if (ds.Tables[0].Rows[0]["B_Limit"] != null && ds.Tables[0].Rows[0]["B_Limit"].ToString() != "")
                {
                    model.B_Limit = int.Parse(ds.Tables[0].Rows[0]["B_Limit"].ToString());
                }
                if (ds.Tables[0].Rows[0]["B_No"] != null && ds.Tables[0].Rows[0]["B_No"].ToString() != "")
                {
                    model.B_No = ds.Tables[0].Rows[0]["B_No"].ToString();
                }
                if (ds.Tables[0].Rows[0]["B_Amount"] != null && ds.Tables[0].Rows[0]["B_Amount"].ToString() != "")
                {
                    model.B_Amount = decimal.Parse(ds.Tables[0].Rows[0]["B_Amount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["B_Date"] != null && ds.Tables[0].Rows[0]["B_Date"].ToString() != "")
                {
                    model.B_Date = DateTime.Parse(ds.Tables[0].Rows[0]["B_Date"].ToString());
                    model.Date = DateTime.Parse(ds.Tables[0].Rows[0]["B_Date"].ToString()).ToShortDateString();
                }
                if (ds.Tables[0].Rows[0]["B_Remark"] != null && ds.Tables[0].Rows[0]["B_Remark"].ToString() != "")
                {
                    model.B_Remark = ds.Tables[0].Rows[0]["B_Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["B_Inputer"] != null && ds.Tables[0].Rows[0]["B_Inputer"].ToString() != "")
                {
                    model.B_Inputer = decimal.Parse(ds.Tables[0].Rows[0]["B_Inputer"].ToString());
                }
                if (ds.Tables[0].Rows[0]["B_Inputdate"] != null && ds.Tables[0].Rows[0]["B_Inputdate"].ToString() != "")
                {
                    model.B_Inputdate = DateTime.Parse(ds.Tables[0].Rows[0]["B_Inputdate"].ToString());
                    model.Inputdate = DateTime.Parse(ds.Tables[0].Rows[0]["B_Inputdate"].ToString()).ToShortDateString();
                }
                if (ds.Tables[0].Rows[0]["B_Editer"] != null && ds.Tables[0].Rows[0]["B_Editer"].ToString() != "")
                {
                    model.B_Editer = decimal.Parse(ds.Tables[0].Rows[0]["B_Editer"].ToString());
                }
                if (ds.Tables[0].Rows[0]["B_Editdate"] != null && ds.Tables[0].Rows[0]["B_Editdate"].ToString() != "")
                {
                    model.B_Editdate = DateTime.Parse(ds.Tables[0].Rows[0]["B_Editdate"].ToString());
                    model.Editdate = DateTime.Parse(ds.Tables[0].Rows[0]["B_Editdate"].ToString()).ToShortDateString();
                }
                if (ds.Tables[0].Rows[0]["B_State"] != null && ds.Tables[0].Rows[0]["B_State"].ToString() != "")
                {
                    model.B_State = int.Parse(ds.Tables[0].Rows[0]["B_State"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }