Exemple #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(VAN_OA.Model.EFrom.tb_Consignor model, SqlCommand objCommand)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.consignor != null)
            {
                strSql1.Append("consignor,");
                strSql2.Append("" + model.consignor + ",");
            }
            if (model.appPer != null)
            {
                strSql1.Append("appPer,");
                strSql2.Append("" + model.appPer + ",");
            }
            if (model.fromTime != null)
            {
                strSql1.Append("fromTime,");
                strSql2.Append("'" + model.fromTime + "',");
            }
            if (model.toTime != null)
            {
                strSql1.Append("toTime,");
                strSql2.Append("'" + model.toTime + "',");
            }
            if (model.ifYouXiao != null)
            {
                strSql1.Append("ifYouXiao,");
                strSql2.Append("" + (model.ifYouXiao ? 1 : 0) + ",");
            }
            if (model.conState != null)
            {
                strSql1.Append("conState,");
                strSql2.Append("'" + model.conState + "',");
            }
            if (model.proId != null)
            {
                strSql1.Append("proId,");
                strSql2.Append("" + model.proId + ",");
            }
            strSql.Append("insert into tb_Consignor(");
            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");
            objCommand.CommandText = strSql.ToString();
            object obj = objCommand.ExecuteScalar();

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(VAN_OA.Model.EFrom.tb_Consignor model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_Consignor set ");
            if (model.consignor != null)
            {
                strSql.Append("consignor=" + model.consignor + ",");
            }
            if (model.appPer != null)
            {
                strSql.Append("appPer=" + model.appPer + ",");
            }
            if (model.fromTime != null)
            {
                strSql.Append("fromTime='" + model.fromTime + "',");
            }
            else
            {
                strSql.Append("fromTime= null ,");
            }
            if (model.toTime != null)
            {
                strSql.Append("toTime='" + model.toTime + "',");
            }
            else
            {
                strSql.Append("toTime= null ,");
            }
            if (model.ifYouXiao != null)
            {
                strSql.Append("ifYouXiao=" + (model.ifYouXiao ? 1 : 0) + ",");
            }
            if (model.conState != null)
            {
                strSql.Append("conState='" + model.conState + "',");
            }
            if (model.proId != null)
            {
                strSql.Append("proId=" + model.proId + ",");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where con_Id=" + model.con_Id + "");
            return(DBHelp.ExeCommand(strSql.ToString()));
        }
Exemple #3
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public VAN_OA.Model.EFrom.tb_Consignor ReaderBind(IDataReader dataReader)
        {
            VAN_OA.Model.EFrom.tb_Consignor model = new VAN_OA.Model.EFrom.tb_Consignor();
            object ojb;

            ojb = dataReader["con_Id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.con_Id = (int)ojb;
            }
            model.consignor = Convert.ToInt32(dataReader["consignor"]);
            ojb             = dataReader["consignor_Name"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Consignor_Name = ojb.ToString();
            }
            ojb = dataReader["appPer_Name"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Appper_Name = ojb.ToString();
            }
            model.appPer = Convert.ToInt32(dataReader["appPer"]);
            ojb          = dataReader["fromTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.fromTime = (DateTime)ojb;
            }
            ojb = dataReader["toTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.toTime = (DateTime)ojb;
            }
            ojb = dataReader["ifYouXiao"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ifYouXiao = (bool)ojb;
            }
            model.conState = dataReader["conState"].ToString();
            ojb            = dataReader["proId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.proId = (int)ojb;
            }

            model.ProType = dataReader["pro_Type"].ToString();

            if (model.ifYouXiao == true)
            {
                model.Youxiaoqi = "一直有效";
            }
            else
            {
                if (model.fromTime != null && model.toTime != null)
                {
                    model.Youxiaoqi = Convert.ToDateTime(model.fromTime).ToShortDateString() + "--" + Convert.ToDateTime(model.toTime).ToShortDateString();
                }
                else if (model.fromTime != null && model.toTime == null)
                {
                    model.Youxiaoqi = "生效日期:" + Convert.ToDateTime(model.fromTime).ToShortDateString();
                }
                else if (model.fromTime == null && model.toTime != null)
                {
                    model.Youxiaoqi = "终止日期:" + Convert.ToDateTime(model.toTime).ToShortDateString();
                }
            }
            return(model);
        }