Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(VAN_OA.Model.JXC.TB_SupplierAdvancePayments model, SqlCommand objCommand)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TB_SupplierAdvancePayments set ");
            //if (model.Id != null)
            //{
            //    strSql.Append("Id=" + model.Id + ",");
            //}
            //if (model.CaiIds != null)
            //{
            //    strSql.Append("CaiIds=" + model.CaiIds + ",");
            //}
            if (model.SupplierFPNo != null)
            {
                strSql.Append("SupplierFPNo='" + model.SupplierFPNo + "',");
            }
            if (model.SupplierInvoiceDate != null)
            {
                strSql.Append("SupplierInvoiceDate='" + model.SupplierInvoiceDate + "',");
            }
            if (model.SupplierInvoiceNum != null)
            {
                strSql.Append("SupplierInvoiceNum=" + model.SupplierInvoiceNum + ",");
            }
            if (model.SupplierInvoicePrice != null)
            {
                strSql.Append("SupplierInvoicePrice=" + model.SupplierInvoicePrice + ",");
            }
            if (model.SupplierInvoiceTotal != null)
            {
                strSql.Append("SupplierInvoiceTotal=" + model.SupplierInvoiceTotal + ",");
            }
            if (model.SupplierProNo != null)
            {
                strSql.Append("SupplierProNo='" + model.SupplierProNo + "',");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where Ids=" + model.Ids + "");
            objCommand.CommandText = strSql.ToString();
            objCommand.ExecuteNonQuery();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(VAN_OA.Model.JXC.TB_SupplierAdvancePayments model, SqlCommand objCommand)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.Id != null)
            {
                strSql1.Append("Id,");
                strSql2.Append("" + model.Id + ",");
            }
            if (model.CaiIds != null)
            {
                strSql1.Append("CaiIds,");
                strSql2.Append("" + model.CaiIds + ",");
            }
            if (model.SupplierFPNo != null)
            {
                strSql1.Append("SupplierFPNo,");
                strSql2.Append("'" + model.SupplierFPNo + "',");
            }
            if (model.SupplierInvoiceDate != null)
            {
                strSql1.Append("SupplierInvoiceDate,");
                strSql2.Append("'" + model.SupplierInvoiceDate + "',");
            }
            if (model.SupplierInvoiceNum != null)
            {
                strSql1.Append("SupplierInvoiceNum,");
                strSql2.Append("" + model.SupplierInvoiceNum + ",");
            }
            if (model.SupplierInvoicePrice != null)
            {
                strSql1.Append("SupplierInvoicePrice,");
                strSql2.Append("" + model.SupplierInvoicePrice + ",");
            }
            if (model.SupplierInvoiceTotal != null)
            {
                strSql1.Append("SupplierInvoiceTotal,");
                strSql2.Append("" + model.SupplierInvoiceTotal + ",");
            }
            strSql1.Append("SupplierProNo,");
            strSql2.Append("'" + model.SupplierProNo + "',");

            strSql.Append("insert into TB_SupplierAdvancePayments(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");

            int result;

            objCommand.CommandText = strSql.ToString();
            object obj = objCommand.ExecuteScalar();

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }