Example #1
0
        public List <PEIS.Model.DictFeeWay> DataTableToList(DataTable dt)
        {
            List <PEIS.Model.DictFeeWay> list = new List <PEIS.Model.DictFeeWay>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    PEIS.Model.DictFeeWay dictFeeWay = new PEIS.Model.DictFeeWay();
                    if (dt.Rows[i]["FeeWayID"].ToString() != "")
                    {
                        dictFeeWay.FeeWayID = int.Parse(dt.Rows[i]["FeeWayID"].ToString());
                    }
                    dictFeeWay.FeeWayName = dt.Rows[i]["FeeWayName"].ToString();
                    if (dt.Rows[i]["Default"].ToString() != "")
                    {
                        if (dt.Rows[i]["Default"].ToString() == "1" || dt.Rows[i]["Default"].ToString().ToLower() == "true")
                        {
                            dictFeeWay.Default = true;
                        }
                        else
                        {
                            dictFeeWay.Default = false;
                        }
                    }
                    dictFeeWay.InputCode = dt.Rows[i]["InputCode"].ToString();
                    list.Add(dictFeeWay);
                }
            }
            return(list);
        }
Example #2
0
        public int Add(PEIS.Model.DictFeeWay model)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("insert into DictFeeWay(");
            stringBuilder.Append("FeeWayName,Default,InputCode)");
            stringBuilder.Append(" values (");
            stringBuilder.Append("@FeeWayName,@Default,@InputCode)");
            stringBuilder.Append(";select @@IDENTITY");
            SqlParameter[] array = new SqlParameter[]
            {
                new SqlParameter("@FeeWayName", SqlDbType.VarChar, 10),
                new SqlParameter("@Default", SqlDbType.Bit, 1),
                new SqlParameter("@InputCode", SqlDbType.VarChar, 8)
            };
            array[0].Value = model.FeeWayName;
            array[1].Value = model.Default;
            array[2].Value = model.InputCode;
            object single = DbHelperSQL.GetSingle(stringBuilder.ToString(), array);
            int    result;

            if (single == null)
            {
                result = 0;
            }
            else
            {
                result = Convert.ToInt32(single);
            }
            return(result);
        }
Example #3
0
        public PEIS.Model.DictFeeWay GetModel(int FeeWayID)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("select  top 1 FeeWayID,FeeWayName,Default,InputCode from DictFeeWay ");
            stringBuilder.Append(" where FeeWayID=@FeeWayID");
            SqlParameter[] array = new SqlParameter[]
            {
                new SqlParameter("@FeeWayID", SqlDbType.Int, 4)
            };
            array[0].Value = FeeWayID;
            PEIS.Model.DictFeeWay dictFeeWay = new PEIS.Model.DictFeeWay();
            DataSet dataSet = DbHelperSQL.Query(stringBuilder.ToString(), array);

            PEIS.Model.DictFeeWay result;
            if (dataSet.Tables[0].Rows.Count > 0)
            {
                if (dataSet.Tables[0].Rows[0]["FeeWayID"].ToString() != "")
                {
                    dictFeeWay.FeeWayID = int.Parse(dataSet.Tables[0].Rows[0]["FeeWayID"].ToString());
                }
                dictFeeWay.FeeWayName = dataSet.Tables[0].Rows[0]["FeeWayName"].ToString();
                if (dataSet.Tables[0].Rows[0]["Default"].ToString() != "")
                {
                    if (dataSet.Tables[0].Rows[0]["Default"].ToString() == "1" || dataSet.Tables[0].Rows[0]["Default"].ToString().ToLower() == "true")
                    {
                        dictFeeWay.Default = true;
                    }
                    else
                    {
                        dictFeeWay.Default = false;
                    }
                }
                dictFeeWay.InputCode = dataSet.Tables[0].Rows[0]["InputCode"].ToString();
                result = dictFeeWay;
            }
            else
            {
                result = null;
            }
            return(result);
        }
Example #4
0
        public bool Update(PEIS.Model.DictFeeWay model)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("update DictFeeWay set ");
            stringBuilder.Append("FeeWayName=@FeeWayName,");
            stringBuilder.Append("Default=@Default,");
            stringBuilder.Append("InputCode=@InputCode");
            stringBuilder.Append(" where FeeWayID=@FeeWayID");
            SqlParameter[] array = new SqlParameter[]
            {
                new SqlParameter("@FeeWayName", SqlDbType.VarChar, 10),
                new SqlParameter("@Default", SqlDbType.Bit, 1),
                new SqlParameter("@InputCode", SqlDbType.VarChar, 8),
                new SqlParameter("@FeeWayID", SqlDbType.Int, 4)
            };
            array[0].Value = model.FeeWayName;
            array[1].Value = model.Default;
            array[2].Value = model.InputCode;
            array[3].Value = model.FeeWayID;
            int num = DbHelperSQL.ExecuteSql(stringBuilder.ToString(), array);

            return(num > 0);
        }
Example #5
0
 public bool Update(PEIS.Model.DictFeeWay model)
 {
     return(this.dal.Update(model));
 }
Example #6
0
 public int Add(PEIS.Model.DictFeeWay model)
 {
     return(this.dal.Add(model));
 }