/// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Contract_Model GetModel(int ContractID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ContractID,ContractNo,Party,B,DemoName,Money,Payment,Schedule,Cost,EmpName,InvoiceNo,Signedtime,Addtime,OperPerson,Remark from Stale_Contract ");
            strSql.Append(" where ContractID=@ContractID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ContractID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ContractID;

            Model.Contract_Model model = new Model.Contract_Model();
            DataTable            dt    = DbHelperSQL.GetDateSet(strSql.ToString(), parameters);

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["ContractID"].ToString() != "")
                {
                    model.ContractID = int.Parse(dt.Rows[0]["ContractID"].ToString());
                }
                model.ContractNo = dt.Rows[0]["ContractNo"].ToString();
                model.Party      = dt.Rows[0]["Party"].ToString();
                model.B          = dt.Rows[0]["B"].ToString();
                model.DemoName   = dt.Rows[0]["DemoName"].ToString();
                if (dt.Rows[0]["Money"].ToString() != "")
                {
                    model.Money = decimal.Parse(dt.Rows[0]["Money"].ToString());
                }
                model.Payment  = dt.Rows[0]["Payment"].ToString();
                model.Schedule = dt.Rows[0]["Schedule"].ToString();
                if (dt.Rows[0]["Cost"].ToString() != "")
                {
                    model.Cost = decimal.Parse(dt.Rows[0]["Cost"].ToString());
                }

                model.EmpName = dt.Rows[0]["EmpName"].ToString();

                model.InvoiceNo = dt.Rows[0]["InvoiceNo"].ToString();
                if (dt.Rows[0]["Signedtime"].ToString() != "")
                {
                    model.Signedtime = DateTime.Parse(dt.Rows[0]["Signedtime"].ToString());
                }
                if (dt.Rows[0]["Addtime"].ToString() != "")
                {
                    model.Addtime = DateTime.Parse(dt.Rows[0]["Addtime"].ToString());
                }
                model.OperPerson = dt.Rows[0]["OperPerson"].ToString();
                model.Remark     = dt.Rows[0]["Remark"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(Model.Contract_Model model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Stale_Contract set ");
            strSql.Append("ContractNo=@ContractNo,");
            strSql.Append("Party=@Party,");
            strSql.Append("B=@B,");
            strSql.Append("DemoName=@DemoName,");
            strSql.Append("Money=@Money,");
            strSql.Append("Payment=@Payment,");
            strSql.Append("Schedule=@Schedule,");
            strSql.Append("Cost=@Cost,");
            strSql.Append("EmpName=@EmpName,");
            strSql.Append("InvoiceNo=@InvoiceNo,");
            strSql.Append("Signedtime=@Signedtime,");
            strSql.Append("Addtime=@Addtime,");
            strSql.Append("OperPerson=@OperPerson,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where ContractID=@ContractID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ContractID", SqlDbType.Int,         4),
                new SqlParameter("@ContractNo", SqlDbType.NVarChar,  100),
                new SqlParameter("@Party",      SqlDbType.NVarChar,  100),
                new SqlParameter("@B",          SqlDbType.NVarChar,  100),
                new SqlParameter("@DemoName",   SqlDbType.NVarChar,  100),
                new SqlParameter("@Money",      SqlDbType.Decimal,     9),
                new SqlParameter("@Payment",    SqlDbType.NVarChar,   20),
                new SqlParameter("@Schedule",   SqlDbType.NVarChar,   20),
                new SqlParameter("@Cost",       SqlDbType.Decimal,     9),
                new SqlParameter("@EmpName",    SqlDbType.NVarChar,  100),
                new SqlParameter("@InvoiceNo",  SqlDbType.NVarChar,  100),
                new SqlParameter("@Signedtime", SqlDbType.DateTime),
                new SqlParameter("@Addtime",    SqlDbType.DateTime),
                new SqlParameter("@OperPerson", SqlDbType.NVarChar,   30),
                new SqlParameter("@Remark",     SqlDbType.NVarChar, 1000)
            };
            parameters[0].Value  = model.ContractID;
            parameters[1].Value  = model.ContractNo;
            parameters[2].Value  = model.Party;
            parameters[3].Value  = model.B;
            parameters[4].Value  = model.DemoName;
            parameters[5].Value  = model.Money;
            parameters[6].Value  = model.Payment;
            parameters[7].Value  = model.Schedule;
            parameters[8].Value  = model.Cost;
            parameters[9].Value  = model.EmpName;
            parameters[10].Value = model.InvoiceNo;
            parameters[11].Value = model.Signedtime;
            parameters[12].Value = model.Addtime;
            parameters[13].Value = model.OperPerson;
            parameters[14].Value = model.Remark;

            return(DbHelperSQL.ExecuteCommand(strSql.ToString(), parameters));
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.Contract_Model model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Stale_Contract(");
            strSql.Append("ContractNo,Party,B,DemoName,Money,Payment,Schedule,Cost,EmpName,InvoiceNo,Signedtime,Addtime,OperPerson,Remark)");
            strSql.Append(" values (");
            strSql.Append("@ContractNo,@Party,@B,@DemoName,@Money,@Payment,@Schedule,@Cost,@EmpName,@InvoiceNo,@Signedtime,@Addtime,@OperPerson,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ContractNo", SqlDbType.NVarChar,  100),
                new SqlParameter("@Party",      SqlDbType.NVarChar,  100),
                new SqlParameter("@B",          SqlDbType.NVarChar,  100),
                new SqlParameter("@DemoName",   SqlDbType.NVarChar,  100),
                new SqlParameter("@Money",      SqlDbType.Decimal,     9),
                new SqlParameter("@Payment",    SqlDbType.NVarChar,   20),
                new SqlParameter("@Schedule",   SqlDbType.NVarChar,   20),
                new SqlParameter("@Cost",       SqlDbType.Decimal,     9),
                new SqlParameter("@EmpName",    SqlDbType.NVarChar,  100),
                new SqlParameter("@InvoiceNo",  SqlDbType.NVarChar,  100),
                new SqlParameter("@Signedtime", SqlDbType.DateTime),
                new SqlParameter("@Addtime",    SqlDbType.DateTime),
                new SqlParameter("@OperPerson", SqlDbType.NVarChar,   30),
                new SqlParameter("@Remark",     SqlDbType.NVarChar, 1000)
            };
            parameters[0].Value  = model.ContractNo;
            parameters[1].Value  = model.Party;
            parameters[2].Value  = model.B;
            parameters[3].Value  = model.DemoName;
            parameters[4].Value  = model.Money;
            parameters[5].Value  = model.Payment;
            parameters[6].Value  = model.Schedule;
            parameters[7].Value  = model.Cost;
            parameters[8].Value  = model.EmpName;
            parameters[9].Value  = model.InvoiceNo;
            parameters[10].Value = model.Signedtime;
            parameters[11].Value = model.Addtime;
            parameters[12].Value = model.OperPerson;
            parameters[13].Value = model.Remark;

            return(DbHelperSQL.ExecuteCommand(strSql.ToString(), parameters));
        }
Esempio n. 4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(Model.Contract_Model model)
 {
     return(dal.Update(model));
 }
Esempio n. 5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Model.Contract_Model model)
 {
     return(dal.Add(model));
 }