Exemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.CostContractInfo GetModel(decimal Cc_ID)
        {
            var strSql = new StringBuilder();
            strSql.Append("select  top 1 Cc_ID,Cc_PID,Cc_No,Cc_Name,Cc_Type,Cc_Fco,Cc_Sco,Cc_Date,Cc_Price,Cc_Pi,Cc_NoPi,Cc_Pm,Cc_NoPm,Cc_SDate,Cc_EDate,Cc_BidNo,Cc_Audit,Cc_UseCount,Cc_File,Cc_State,Cc_Remark,Cc_Inputer,Cc_InputDate,Cc_Editer,Cc_Editdate from tbl_CostContractInfo ");
            strSql.Append(" where Cc_ID=@Cc_ID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@Cc_ID", SqlDbType.Decimal,9)			};
            parameters[0].Value = Cc_ID;

            Model.CostContractInfo model = new Model.CostContractInfo();
            DataSet ds = SqlHelper.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Cc_ID"] != null && ds.Tables[0].Rows[0]["Cc_ID"].ToString() != "")
                {
                    model.Cc_ID = decimal.Parse(ds.Tables[0].Rows[0]["Cc_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cc_PID"] != null && ds.Tables[0].Rows[0]["Cc_PID"].ToString() != "")
                {
                    model.Cc_PID = decimal.Parse(ds.Tables[0].Rows[0]["Cc_PID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cc_No"] != null && ds.Tables[0].Rows[0]["Cc_No"].ToString() != "")
                {
                    model.Cc_No = ds.Tables[0].Rows[0]["Cc_No"].ToString();
                    if (model.Cc_No.Contains("-"))
                    {
                        model.No = ds.Tables[0].Rows[0]["Cc_No"].ToString().Split('-').LastOrDefault();
                    }
                }
                if (ds.Tables[0].Rows[0]["Cc_Name"] != null && ds.Tables[0].Rows[0]["Cc_Name"].ToString() != "")
                {
                    model.Cc_Name = ds.Tables[0].Rows[0]["Cc_Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Cc_Type"] != null && ds.Tables[0].Rows[0]["Cc_Type"].ToString() != "")
                {
                    model.Cc_Type = int.Parse(ds.Tables[0].Rows[0]["Cc_Type"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cc_Fco"] != null && ds.Tables[0].Rows[0]["Cc_Fco"].ToString() != "")
                {
                    model.Cc_Fco = ds.Tables[0].Rows[0]["Cc_Fco"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Cc_Sco"] != null && ds.Tables[0].Rows[0]["Cc_Sco"].ToString() != "")
                {
                    model.Cc_Sco = ds.Tables[0].Rows[0]["Cc_Sco"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Cc_Date"] != null && ds.Tables[0].Rows[0]["Cc_Date"].ToString() != "")
                {
                    model.Cc_Date = DateTime.Parse(ds.Tables[0].Rows[0]["Cc_Date"].ToString());
                    model.Date = DateTime.Parse(ds.Tables[0].Rows[0]["Cc_Date"].ToString()).ToShortDateString();
                }
                if (ds.Tables[0].Rows[0]["Cc_Price"] != null && ds.Tables[0].Rows[0]["Cc_Price"].ToString() != "")
                {
                    model.Cc_Price = decimal.Parse(ds.Tables[0].Rows[0]["Cc_Price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cc_Pi"] != null && ds.Tables[0].Rows[0]["Cc_Pi"].ToString() != "")
                {
                    model.Cc_Pi = decimal.Parse(ds.Tables[0].Rows[0]["Cc_Pi"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cc_NoPi"] != null && ds.Tables[0].Rows[0]["Cc_NoPi"].ToString() != "")
                {
                    model.Cc_NoPi = decimal.Parse(ds.Tables[0].Rows[0]["Cc_NoPi"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cc_Pm"] != null && ds.Tables[0].Rows[0]["Cc_Pm"].ToString() != "")
                {
                    model.Cc_Pm = decimal.Parse(ds.Tables[0].Rows[0]["Cc_Pm"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cc_NoPm"] != null && ds.Tables[0].Rows[0]["Cc_NoPm"].ToString() != "")
                {
                    model.Cc_NoPm = decimal.Parse(ds.Tables[0].Rows[0]["Cc_NoPm"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cc_SDate"] != null && ds.Tables[0].Rows[0]["Cc_SDate"].ToString() != "")
                {
                    model.Cc_SDate = DateTime.Parse(ds.Tables[0].Rows[0]["Cc_SDate"].ToString());
                    model.SDate = DateTime.Parse(ds.Tables[0].Rows[0]["Cc_SDate"].ToString()).ToShortDateString();
                }
                if (ds.Tables[0].Rows[0]["Cc_EDate"] != null && ds.Tables[0].Rows[0]["Cc_EDate"].ToString() != "")
                {
                    model.Cc_EDate = DateTime.Parse(ds.Tables[0].Rows[0]["Cc_EDate"].ToString());
                    model.EDate = DateTime.Parse(ds.Tables[0].Rows[0]["Cc_EDate"].ToString()).ToShortDateString();
                }
                if (ds.Tables[0].Rows[0]["Cc_BidNo"] != null && ds.Tables[0].Rows[0]["Cc_BidNo"].ToString() != "")
                {
                    model.Cc_BidNo = ds.Tables[0].Rows[0]["Cc_BidNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Cc_Audit"] != null && ds.Tables[0].Rows[0]["Cc_Audit"].ToString() != "")
                {
                    model.Cc_Audit = ds.Tables[0].Rows[0]["Cc_Audit"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Cc_UseCount"] != null && ds.Tables[0].Rows[0]["Cc_UseCount"].ToString() != "")
                {
                    model.Cc_UseCount = ds.Tables[0].Rows[0]["Cc_UseCount"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Cc_File"] != null && ds.Tables[0].Rows[0]["Cc_File"].ToString() != "")
                {
                    model.Cc_File = ds.Tables[0].Rows[0]["Cc_File"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Cc_State"] != null && ds.Tables[0].Rows[0]["Cc_State"].ToString() != "")
                {
                    model.Cc_State = int.Parse(ds.Tables[0].Rows[0]["Cc_State"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cc_Remark"] != null && ds.Tables[0].Rows[0]["Cc_Remark"].ToString() != "")
                {
                    model.Cc_Remark = ds.Tables[0].Rows[0]["Cc_Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Cc_Inputer"] != null && ds.Tables[0].Rows[0]["Cc_Inputer"].ToString() != "")
                {
                    model.Cc_Inputer = decimal.Parse(ds.Tables[0].Rows[0]["Cc_Inputer"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cc_InputDate"] != null && ds.Tables[0].Rows[0]["Cc_InputDate"].ToString() != "")
                {
                    model.Cc_InputDate = DateTime.Parse(ds.Tables[0].Rows[0]["Cc_InputDate"].ToString());
                    model.InputDate = DateTime.Parse(ds.Tables[0].Rows[0]["Cc_InputDate"].ToString()).ToShortDateString();
                }
                if (ds.Tables[0].Rows[0]["Cc_Editer"] != null && ds.Tables[0].Rows[0]["Cc_Editer"].ToString() != "")
                {
                    model.Cc_Editer = decimal.Parse(ds.Tables[0].Rows[0]["Cc_Editer"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cc_Editdate"] != null && ds.Tables[0].Rows[0]["Cc_Editdate"].ToString() != "")
                {
                    model.Cc_Editdate = DateTime.Parse(ds.Tables[0].Rows[0]["Cc_Editdate"].ToString());
                    model.Editdate = DateTime.Parse(ds.Tables[0].Rows[0]["Cc_Editdate"].ToString()).ToShortDateString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 public List<Model.CostContractInfo> DataTableToList(DataTable dt)
 {
     List<Model.CostContractInfo> modelList = new List<Model.CostContractInfo>();
     int rowsCount = dt.Rows.Count;
     if (rowsCount > 0)
     {
         Model.CostContractInfo model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new Model.CostContractInfo();
             if(dt.Rows[n]["Cc_ID"]!=null && dt.Rows[n]["Cc_ID"].ToString()!="")
             {
                 model.Cc_ID=decimal.Parse(dt.Rows[n]["Cc_ID"].ToString());
             }
             if(dt.Rows[n]["Cc_PID"]!=null && dt.Rows[n]["Cc_PID"].ToString()!="")
             {
                 model.Cc_PID=decimal.Parse(dt.Rows[n]["Cc_PID"].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_Name"]!=null && dt.Rows[n]["Cc_Name"].ToString()!="")
             {
             model.Cc_Name=dt.Rows[n]["Cc_Name"].ToString();
             }
             if(dt.Rows[n]["Cc_Type"]!=null && dt.Rows[n]["Cc_Type"].ToString()!="")
             {
                 model.Cc_Type = int.Parse(dt.Rows[n]["Cc_Type"].ToString());
             }
             if(dt.Rows[n]["Cc_Fco"]!=null && dt.Rows[n]["Cc_Fco"].ToString()!="")
             {
             model.Cc_Fco=dt.Rows[n]["Cc_Fco"].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]["Cc_Date"]!=null && dt.Rows[n]["Cc_Date"].ToString()!="")
             {
                 model.Cc_Date = DateTime.Parse(dt.Rows[n]["Cc_Date"].ToString());
                 model.Date = DateTime.Parse(dt.Rows[n]["Cc_Date"].ToString()).ToShortDateString();
             }
             if(dt.Rows[n]["Cc_Price"]!=null && dt.Rows[n]["Cc_Price"].ToString()!="")
             {
                 model.Cc_Price=decimal.Parse(dt.Rows[n]["Cc_Price"].ToString());
             }
             if(dt.Rows[n]["Cc_Pi"]!=null && dt.Rows[n]["Cc_Pi"].ToString()!="")
             {
                 model.Cc_Pi=decimal.Parse(dt.Rows[n]["Cc_Pi"].ToString());
             }
             if(dt.Rows[n]["Cc_NoPi"]!=null && dt.Rows[n]["Cc_NoPi"].ToString()!="")
             {
                 model.Cc_NoPi=decimal.Parse(dt.Rows[n]["Cc_NoPi"].ToString());
             }
             if(dt.Rows[n]["Cc_Pm"]!=null && dt.Rows[n]["Cc_Pm"].ToString()!="")
             {
                 model.Cc_Pm=decimal.Parse(dt.Rows[n]["Cc_Pm"].ToString());
             }
             if(dt.Rows[n]["Cc_NoPm"]!=null && dt.Rows[n]["Cc_NoPm"].ToString()!="")
             {
                 model.Cc_NoPm=decimal.Parse(dt.Rows[n]["Cc_NoPm"].ToString());
             }
             if(dt.Rows[n]["Cc_SDate"]!=null && dt.Rows[n]["Cc_SDate"].ToString()!="")
             {
                 model.Cc_SDate = DateTime.Parse(dt.Rows[n]["Cc_SDate"].ToString());
                 model.SDate = DateTime.Parse(dt.Rows[n]["Cc_SDate"].ToString()).ToShortDateString();
             }
             if(dt.Rows[n]["Cc_EDate"]!=null && dt.Rows[n]["Cc_EDate"].ToString()!="")
             {
                 model.Cc_EDate=DateTime.Parse(dt.Rows[n]["Cc_EDate"].ToString());
                 model.EDate = DateTime.Parse(dt.Rows[n]["Cc_EDate"].ToString()).ToShortDateString();
             }
             if(dt.Rows[n]["Cc_BidNo"]!=null && dt.Rows[n]["Cc_BidNo"].ToString()!="")
             {
             model.Cc_BidNo=dt.Rows[n]["Cc_BidNo"].ToString();
             }
             if(dt.Rows[n]["Cc_Audit"]!=null && dt.Rows[n]["Cc_Audit"].ToString()!="")
             {
             model.Cc_Audit=dt.Rows[n]["Cc_Audit"].ToString();
             }
             if(dt.Rows[n]["Cc_UseCount"]!=null && dt.Rows[n]["Cc_UseCount"].ToString()!="")
             {
             model.Cc_UseCount=dt.Rows[n]["Cc_UseCount"].ToString();
             }
             if(dt.Rows[n]["Cc_File"]!=null && dt.Rows[n]["Cc_File"].ToString()!="")
             {
             model.Cc_File=dt.Rows[n]["Cc_File"].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());
             }
             if(dt.Rows[n]["Cc_Remark"]!=null && dt.Rows[n]["Cc_Remark"].ToString()!="")
             {
             model.Cc_Remark=dt.Rows[n]["Cc_Remark"].ToString();
             }
             if(dt.Rows[n]["Cc_Inputer"]!=null && dt.Rows[n]["Cc_Inputer"].ToString()!="")
             {
                 model.Cc_Inputer=decimal.Parse(dt.Rows[n]["Cc_Inputer"].ToString());
             }
             if(dt.Rows[n]["Cc_InputDate"]!=null && dt.Rows[n]["Cc_InputDate"].ToString()!="")
             {
                 model.Cc_InputDate = DateTime.Parse(dt.Rows[n]["Cc_InputDate"].ToString());
                 model.InputDate = DateTime.Parse(dt.Rows[n]["Cc_InputDate"].ToString()).ToShortDateString();
             }
             if(dt.Rows[n]["Cc_Editer"]!=null && dt.Rows[n]["Cc_Editer"].ToString()!="")
             {
                 model.Cc_Editer=decimal.Parse(dt.Rows[n]["Cc_Editer"].ToString());
             }
             if(dt.Rows[n]["Cc_Editdate"]!=null && dt.Rows[n]["Cc_Editdate"].ToString()!="")
             {
                 model.Cc_Editdate=DateTime.Parse(dt.Rows[n]["Cc_Editdate"].ToString());
                 model.Editdate = DateTime.Parse(dt.Rows[n]["Cc_Editdate"].ToString()).ToShortDateString();
             }
             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]["P_No"] != null && dt.Rows[n]["P_No"].ToString() != "")
             {
                 model.P_No = dt.Rows[n]["P_No"].ToString();
             }
             if (dt.Rows[n]["P_BidSDate"] != null && dt.Rows[n]["P_BidSDate"].ToString() != "")
             {
                 model.P_BidSDate = Convert.ToDateTime(dt.Rows[n]["P_BidSDate"]);
                 model.BidSDate = Convert.ToDateTime(dt.Rows[n]["P_BidSDate"]).ToShortDateString();
             }
             if (dt.Rows[n]["P_Number"] != null && dt.Rows[n]["P_Number"].ToString() != "")
             {
                 model.P_Number = dt.Rows[n]["P_Number"].ToString();
             }
             if (dt.Rows[n]["P_CDate"] != null && dt.Rows[n]["P_CDate"].ToString() != "")
             {
                 model.P_CDate = Convert.ToDateTime(dt.Rows[n]["P_CDate"]);
                 model.CDate = Convert.ToDateTime(dt.Rows[n]["P_CDate"]).ToShortDateString();
             }
             if (dt.Rows[n]["P_Header"] != null && dt.Rows[n]["P_Header"].ToString() != "")
             {
                 model.P_Header = dt.Rows[n]["P_Header"].ToString();
             }
             if (dt.Rows[n]["P_Name"] != null && dt.Rows[n]["P_Name"].ToString() != "")
             {
                 model.P_Name = dt.Rows[n]["P_Name"].ToString();
             }
             if (dt.Rows[n]["P_Type"] != null && dt.Rows[n]["P_Type"].ToString() != "")
             {
                 model.P_Type = Convert.ToInt32(dt.Rows[n]["P_Type"]);
             }
             modelList.Add(model);
         }
     }
     return modelList;
 }