示例#1
0
        public bool Update(RecordsHyperFoodsModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update ARCHIVE_HYPER_FOOD set ");
            builder.Append("IDCardNo=@IDCardNo,");
            builder.Append("FoodName=@FoodName,");
            builder.Append("EatYesNo=@EatYesNo,");
            builder.Append("DayBeats=@DayBeats,");
            builder.Append("WeekBeats=@WeekBeats,");
            builder.Append("MouthBeats = @MouthBeats,");
            builder.Append("SaltSumBeats = @SaltSumBeats, ");
            builder.Append("OutKey=@OutKey ");
            builder.Append(" where ID=@ID");
            MySqlParameter[] cmdParms = new MySqlParameter[]
            { new MySqlParameter("@IDCardNo", MySqlDbType.String, 18),
              new MySqlParameter("@FoodName", MySqlDbType.String, 100),
              new MySqlParameter("@EatYesNo", MySqlDbType.String, 1),
              new MySqlParameter("@DayBeats", MySqlDbType.Decimal),
              new MySqlParameter("@WeekBeats", MySqlDbType.Decimal),
              new MySqlParameter("@MouthBeats", MySqlDbType.Decimal),
              new MySqlParameter("@SaltSumBeats", MySqlDbType.Decimal),
              new MySqlParameter("@OutKey", MySqlDbType.Int32, 4),
              new MySqlParameter("@ID", MySqlDbType.Int32, 8) };
            cmdParms[0].Value = model.IDCardNo;
            cmdParms[1].Value = model.FoodName;
            cmdParms[2].Value = model.EatYesNo;
            cmdParms[3].Value = model.DayBeats;
            cmdParms[4].Value = model.WeekBeats;
            cmdParms[5].Value = model.MouthBeats;
            cmdParms[6].Value = model.SaltSumBeats;
            cmdParms[7].Value = model.OutKey;
            cmdParms[8].Value = model.ID;
            return(MySQLHelper.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
示例#2
0
        public RecordsHyperFoodsModel DataRowToModel(DataRow row)
        {
            RecordsHyperFoodsModel HyperFoodsModel = new RecordsHyperFoodsModel();

            if (row != null)
            {
                if (((row["ID"] != null) && (row["ID"] != DBNull.Value)) && (row["ID"].ToString() != ""))
                {
                    HyperFoodsModel.ID = int.Parse(row["ID"].ToString());
                }
                if ((row["IDCardNo"] != null) && (row["IDCardNo"] != DBNull.Value))
                {
                    HyperFoodsModel.IDCardNo = row["IDCardNo"].ToString();
                }
                if ((row["FoodName"] != null) && (row["FoodName"] != DBNull.Value))
                {
                    HyperFoodsModel.FoodName = row["FoodName"].ToString();
                }
                if ((row["EatYesNo"] != null) && (row["EatYesNo"] != DBNull.Value))
                {
                    HyperFoodsModel.EatYesNo = row["EatYesNo"].ToString();
                }
                if (((row["DayBeats"] != null) && (row["DayBeats"] != DBNull.Value)) && (row["DayBeats"].ToString() != ""))
                {
                    HyperFoodsModel.DayBeats = new decimal?(decimal.Parse(row["DayBeats"].ToString()));
                }
                if (((row["WeekBeats"] != null) && (row["WeekBeats"] != DBNull.Value)) && (row["WeekBeats"].ToString() != ""))
                {
                    HyperFoodsModel.WeekBeats = new decimal?(decimal.Parse(row["WeekBeats"].ToString()));
                }
                if (((row["MouthBeats"] != null) && (row["MouthBeats"] != DBNull.Value)) && (row["MouthBeats"].ToString() != ""))
                {
                    HyperFoodsModel.MouthBeats = new decimal?(decimal.Parse(row["MouthBeats"].ToString()));
                }
                if (((row["SaltSumBeats"] != null) && (row["SaltSumBeats"] != DBNull.Value)) && (row["SaltSumBeats"].ToString() != ""))
                {
                    HyperFoodsModel.SaltSumBeats = new decimal?(decimal.Parse(row["SaltSumBeats"].ToString()));
                }
                if (((row["OutKey"] != null) && (row["OutKey"] != DBNull.Value)) && (row["OutKey"].ToString() != ""))
                {
                    HyperFoodsModel.OutKey = int.Parse(row["OutKey"].ToString());
                }
            }
            return(HyperFoodsModel);
        }
示例#3
0
        public List <RecordsHyperFoodsModel> DataTableToList(DataTable dt)
        {
            List <RecordsHyperFoodsModel> list = new List <RecordsHyperFoodsModel>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    RecordsHyperFoodsModel item = this.dal.DataRowToModel(dt.Rows[i]);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
示例#4
0
        public int Add(RecordsHyperFoodsModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into ARCHIVE_HYPER_FOOD(");
            builder.Append("IDCardNo,FoodName,EatYesNo,DayBeats,WeekBeats,MouthBeats,SaltSumBeats,OutKey )");
            builder.Append(" values (");
            builder.Append("@IDCardNo,@FoodName,@EatYesNo,@DayBeats,@WeekBeats,@MouthBeats,@SaltSumBeats,@OutKey )");
            builder.Append(";select @@IDENTITY");
            MySqlParameter[] cmdParms = new MySqlParameter[]
            {
                new MySqlParameter("@IDCardNo", MySqlDbType.String, 18),
                new MySqlParameter("@FoodName", MySqlDbType.String, 100),
                new MySqlParameter("@EatYesNo", MySqlDbType.String, 1),
                new MySqlParameter("@DayBeats", MySqlDbType.Decimal),
                new MySqlParameter("@WeekBeats", MySqlDbType.Decimal),
                new MySqlParameter("@MouthBeats", MySqlDbType.Decimal),
                new MySqlParameter("@SaltSumBeats", MySqlDbType.Decimal),
                new MySqlParameter("@OutKey", MySqlDbType.Int32, 4)
            };
            cmdParms[0].Value = model.IDCardNo;
            cmdParms[1].Value = model.FoodName;
            cmdParms[2].Value = model.EatYesNo;
            cmdParms[3].Value = model.DayBeats;
            cmdParms[4].Value = model.WeekBeats;
            cmdParms[5].Value = model.MouthBeats;
            cmdParms[6].Value = model.SaltSumBeats;
            cmdParms[7].Value = model.OutKey;
            object single = MySQLHelper.GetSingle(builder.ToString(), cmdParms);

            if (single == null)
            {
                return(0);
            }
            return(Convert.ToInt32(single));
        }
示例#5
0
        public void InitEveryThing()
        {
            this.HyperSurveyModel = new RecordsHyperSurveyBLL().GetModel(PhysicalInfoFactory.ID);
            this.HyperFoodsModel  = new RecordsHyperFoodsBLL().GetModelList(string.Format("IDCardNo = '{0}' and OutKey={1}", this.Model.IDCardNo, PhysicalInfoFactory.ID));
            if (this.HyperSurveyModel == null)
            {
                HyperSurveyModel          = new RecordsHyperSurveyModel();
                HyperSurveyModel.IDCardNo = Model.IDCardNo;
            }

            this.tbName.Text = Model.CustomerName;

            this.bindingManagersurvey = new SimpleBindingManager <RecordsHyperSurveyModel>(this.inputRangessurvey, this.inputrange_str, this.HyperSurveyModel);
            this.bindingManagersurvey.SimpleBindingInt(this.txbPersonSum, "EatPersonSum", true);
            this.bindingManagersurvey.SimpleBindingInt(this.txbPersonChild, "EatChildSum", true);
            this.bindingManagersurvey.SimpleBinding(this.txbSalt, "EatSaltQuantity", true);
            this.bindingManagersurvey.SimpleBinding(this.txbSoy, "EatSoyQuntity", true);

            for (int k = 0; k < this.foodControl.Count; k++)
            {
                if (k < HyperFoodsModel.Count)
                {
                    switch (HyperFoodsModel[k].FoodName)
                    {
                    case "咸蛋": this.foodControl[0].Source = this.HyperFoodsModel[k]; break;

                    case "咸鱼": this.foodControl[1].Source = this.HyperFoodsModel[k]; break;

                    case "虾皮": this.foodControl[2].Source = this.HyperFoodsModel[k]; break;

                    case "虾米": this.foodControl[3].Source = this.HyperFoodsModel[k]; break;

                    case "方便面": this.foodControl[4].Source = this.HyperFoodsModel[k]; break;

                    case "豆腐乳": this.foodControl[5].Source = this.HyperFoodsModel[k]; break;

                    case "咸菜": this.foodControl[6].Source = this.HyperFoodsModel[k]; break;

                    case "辣椒酱": this.foodControl[7].Source = this.HyperFoodsModel[k]; break;

                    case "虾酱": this.foodControl[8].Source = this.HyperFoodsModel[k]; break;

                    case "甜面酱": this.foodControl[9].Source = this.HyperFoodsModel[k]; break;

                    case "豆瓣酱": this.foodControl[10].Source = this.HyperFoodsModel[k]; break;

                    default: break;
                    }
                }
            }
            for (int k = 0; k < this.foodControl.Count; k++)
            {
                if (this.foodControl[k].Source == null)
                {
                    RecordsHyperFoodsModel recordsHyperFoodsModel = new RecordsHyperFoodsModel
                    {
                        IDCardNo   = this.Model.IDCardNo,
                        ModelState = RecordsStateModel.AddToDB
                    };
                    this.foodControl[k].Source = recordsHyperFoodsModel;
                }
                else
                {
                    this.foodControl[k].Source.ModelState = RecordsStateModel.UpdateInDB;
                }
            }

            this.EveryThingIsOk = true;
        }
示例#6
0
 public bool Update(RecordsHyperFoodsModel model)
 {
     return(this.dal.Update(model));
 }
示例#7
0
 public int Add(RecordsHyperFoodsModel model)
 {
     return(this.dal.Add(model));
 }