Пример #1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.Haulway> DataTableToList(DataTable dt)
        {
            List<Model.Haulway> modelList = new List<Model.Haulway>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.Haulway model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.Haulway();
                    if (dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    model.Name = dt.Rows[n]["Name"].ToString();
                    if (dt.Rows[n]["LoadingCapacityRunning"].ToString() != "")
                    {
                        model.LoadingCapacityRunning = decimal.Parse(dt.Rows[n]["LoadingCapacityRunning"].ToString());
                    }
                    if (dt.Rows[n]["NoLoadingCapacityRunning"].ToString() != "")
                    {
                        model.NoLoadingCapacityRunning = decimal.Parse(dt.Rows[n]["NoLoadingCapacityRunning"].ToString());
                    }
                    model.Code = dt.Rows[n]["Code"].ToString();

                    modelList.Add(model);
                }
            }
            return modelList;
        }
Пример #2
0
        private bool DoAdd()
        {
            bool result = false;
            Model.Haulway model = new Model.Haulway();
            BLL.Haulway bll = new BLL.Haulway();

            model.Name = txtName.Text.Trim();
            model.Code = string.IsNullOrEmpty(txtCode.Text.Trim()) ? model.Name : txtCode.Text.Trim();
            model.LoadingCapacityRunning = Utils.StrToDecimal(txtLoadingCapacityRunning.Text.Trim(), 0.00M);
            model.NoLoadingCapacityRunning = Utils.StrToDecimal(txtNoLoadingCapacityRunning.Text.Trim(), 0.00M);

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加运输路线:" + model.Name); //记录日志
                result = true;
            }
            return result;
        }
Пример #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Haulway GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select Id, Name, LoadingCapacityRunning, NoLoadingCapacityRunning, Code  ");
            strSql.Append("  from mtms_Haulway ");
            strSql.Append(" where [email protected]");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)
            };
            parameters[0].Value = Id;

            Model.Haulway model = new Model.Haulway();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                if (ds.Tables[0].Rows[0]["LoadingCapacityRunning"].ToString() != "")
                {
                    model.LoadingCapacityRunning = decimal.Parse(ds.Tables[0].Rows[0]["LoadingCapacityRunning"].ToString());
                }
                if (ds.Tables[0].Rows[0]["NoLoadingCapacityRunning"].ToString() != "")
                {
                    model.NoLoadingCapacityRunning = decimal.Parse(ds.Tables[0].Rows[0]["NoLoadingCapacityRunning"].ToString());
                }
                model.Code = ds.Tables[0].Rows[0]["Code"].ToString();

                return model;
            }
            else
            {
                return null;
            }
        }