private void dgvMyItem_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { EntityItemTask item = dgvMyItem.Rows[e.RowIndex].DataBoundItem as EntityItemTask; currSelectedItem = item; } }
private void Form1_Load(object sender, EventArgs e) { LoadData(); if (dgvMyItem.Rows.Count > 0) { currSelectedItem = dgvMyItem.Rows[0].DataBoundItem as EntityItemTask; } }
public string AddItemTask(EntityItemTask model) { string result = string.Empty; StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_item_task("); strSql.Append("local_item_task_id,creative_two_title,keyword,effect_start_time,effect_end_time,create_time,update_time,remark,is_enable,item_id,nick,item_title,img_url,price,max_click,run_days,creative_one_title"); strSql.Append(") values ("); strSql.Append("@local_item_task_id,@creative_two_title,@keyword,@effect_start_time,@effect_end_time,@create_time,@update_time,@remark,@is_enable,@item_id,@nick,@item_title,@img_url,@price,@max_click,@run_days,@creative_one_title"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@local_item_task_id", SqlDbType.UniqueIdentifier, 16), new SqlParameter("@creative_two_title", SqlDbType.VarChar, 100), new SqlParameter("@keyword", SqlDbType.VarChar, 100), new SqlParameter("@effect_start_time", SqlDbType.Char, 4), new SqlParameter("@effect_end_time", SqlDbType.Char, 4), new SqlParameter("@create_time", SqlDbType.DateTime), new SqlParameter("@update_time", SqlDbType.DateTime), new SqlParameter("@remark", SqlDbType.VarChar, 1000), new SqlParameter("@is_enable", SqlDbType.Bit, 1), new SqlParameter("@item_id", SqlDbType.BigInt, 8), new SqlParameter("@nick", SqlDbType.VarChar, 100), new SqlParameter("@item_title", SqlDbType.VarChar, 100), new SqlParameter("@img_url", SqlDbType.VarChar, 100), new SqlParameter("@price", SqlDbType.Decimal, 9), new SqlParameter("@max_click", SqlDbType.Int, 4), new SqlParameter("@run_days", SqlDbType.Int, 4), new SqlParameter("@creative_one_title", SqlDbType.VarChar, 100) }; parameters[0].Value = model.local_item_task_id; parameters[1].Value = model.creative_two_title; parameters[2].Value = model.keyword; parameters[3].Value = model.effect_start_time; parameters[4].Value = model.effect_end_time; parameters[5].Value = model.create_time; parameters[6].Value = model.update_time; parameters[7].Value = model.remark; parameters[8].Value = model.is_enable; parameters[9].Value = model.item_id; parameters[10].Value = model.nick; parameters[11].Value = model.item_title; parameters[12].Value = model.img_url; parameters[13].Value = model.price; parameters[14].Value = model.max_click; parameters[15].Value = model.run_days; parameters[16].Value = model.creative_one_title; DataBase.ExecuteNone(strSql.ToString(), parameters); return(result); }
public List <EntityItemTask> GetMyItem() { List <EntityItemTask> lstMyItem = new List <EntityItemTask>(); string strSql = "select * from t_item_task"; DataTable dt = DataBase.ExecuteTable(strSql); if (dt != null && dt.Rows.Count != 0) { for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; EntityItemTask model = new EntityItemTask(); model.local_item_task_id = new Guid(dr["local_item_task_id"].ToString()); model.item_id = Convert.ToInt64(dr["item_id"]); model.nick = dr["nick"].ToString(); model.item_title = dr["item_title"].ToString(); model.img_url = dr["img_url"].ToString(); model.img_data = dr["img_data"] as byte[]; if (dr["price"] != DBNull.Value) { model.price = Convert.ToDecimal(dr["price"]); } if (dr["max_click"] != DBNull.Value) { model.max_click = Convert.ToInt32(dr["max_click"]); } if (dr["run_days"] != DBNull.Value) { model.run_days = Convert.ToInt32(dr["run_days"]); } model.creative_one_title = dr["creative_one_title"].ToString(); model.creative_two_title = dr["creative_two_title"].ToString(); model.keyword = dr["keyword"].ToString(); model.effect_start_time = dr["effect_start_time"].ToString(); model.effect_end_time = dr["effect_end_time"].ToString(); model.create_time = Convert.ToDateTime(dr["create_time"]); model.update_time = Convert.ToDateTime(dr["update_time"]); model.remark = dr["remark"].ToString(); if (dr["is_enable"] != DBNull.Value) { model.is_enable = Convert.ToBoolean(dr["is_enable"]); } lstMyItem.Add(model); } } return(lstMyItem); }
/// <summary> /// 增加我的宝贝 /// </summary> public void AddMyItem(EntityItemTask model) { StringBuilder sbSql = new StringBuilder(); sbSql.Append("insert into t_item_task("); sbSql.Append("local_item_task_id,item_id,creative_two_title,keyword,effect_start_time,effect_end_time,create_time,update_time,is_enable,nick,item_title,img_url,img_data,price,max_click,run_days,creative_one_title,remark"); sbSql.Append(") values ("); sbSql.Append("'{0}',{1},'{2}','{3}','{4}','{5}','{6}','{7}',{8},'{9}','{10}','{11}',@img_data,{12},{13},{14},'{15}','{16}'"); sbSql.Append(") "); string strSql = string.Format(sbSql.ToString(), model.local_item_task_id.ToString(), model.item_id, model.creative_two_title, model.keyword, model.effect_start_time, model.effect_end_time, model.create_time.ToString("s"), model.update_time.ToString("s"), model.is_enable ? 1 : 0, model.nick, model.item_title, model.img_url, model.price, model.max_click, model.run_days, model.creative_one_title, model.remark); SQLiteParameter[] ps = new SQLiteParameter[1]; ps[0] = new SQLiteParameter("@img_data", DbType.Binary); ps[0].Size = 55000; ps[0].Value = model.img_data; DataBase.ExecuteNone(strSql, ps); }
public string EditItemTask(EntityItemTask model) { string result = string.Empty; try { string strSql = @"update t_item_task set update_time=getdate(),creative_one_title=@creative_one_title,creative_two_title=@creative_two_title, effect_start_time=@effect_start_time,effect_end_time=@effect_end_time,remark=@remark,item_title=@item_title,price=@price where local_item_task_id=@local_item_task_id "; SqlParameter[] parameters = { new SqlParameter("@creative_one_title", SqlDbType.VarChar, 100), new SqlParameter("@creative_two_title", SqlDbType.VarChar, 100), new SqlParameter("@effect_start_time", SqlDbType.Char, 4), new SqlParameter("@effect_end_time", SqlDbType.Char, 4), new SqlParameter("@remark", SqlDbType.VarChar, 1000), new SqlParameter("@item_title", SqlDbType.VarChar, 100), new SqlParameter("@price", SqlDbType.Decimal, 9), new SqlParameter("@local_item_task_id", SqlDbType.UniqueIdentifier, 16) }; parameters[0].Value = model.creative_one_title; parameters[1].Value = model.creative_two_title; parameters[2].Value = model.effect_start_time; parameters[3].Value = model.effect_end_time; parameters[4].Value = model.remark; parameters[5].Value = model.item_title; parameters[6].Value = model.price; parameters[7].Value = model.local_item_task_id; DataBase.ExecuteNone(strSql, parameters); } catch (Exception se) { result = se.Message; } return(result); }
private void btnGetItem_Click(object sender, EventArgs e) { if (txtInputUrl.Text.ToLower().Contains("&id") || txtInputUrl.Text.ToLower().Contains("?id")) { long item_id = Strings.GetItemId(txtInputUrl.Text.ToLower()); string jsonItem = FrmMain.ws.GetItemOnline(item_id); if (!string.IsNullOrEmpty(jsonItem) && !jsonItem.Contains("sub_code")) { currentItem = ModelUtil.ConvertWsToLocal(FrmMain.ws.GetItemTaskFromJson(jsonItem)); picItem.Image = Helper.GetImgOnLine(currentItem.img_url); txtItemTitle.Text = currentItem.item_title; txtNickName.Text = currentItem.nick; txtPrice.Text = currentItem.price.ToString(); } else { MessageBox.Show("获取宝贝信息失败,请过一段时间再试"); } } else { MessageBox.Show("宝贝的网址输入错误,请使用浏览器打开宝贝,然后复制地址栏内容"); } }
/// <summary> /// 从宝贝的Json数据中,获取结构化的宝贝对象 /// </summary> public static EntityItemTask GetItemTaskFromJson(string jsonItem) { EntityItemTask model = new EntityItemTask(); JsonObject data; using (JsonParser parser = new JsonParser(new StringReader(jsonItem), true)) { data = parser.ParseObject(); } JsonObject item_get_response = (JsonObject)data["item_get_response"]; JsonObject item = (JsonObject)item_get_response["item"]; if (item.ContainsKey("num_iid")) { model.item_id = Helper.JsonObjectToLong(item["num_iid"]); } if (item.ContainsKey("title")) { model.item_title = Helper.JsonObjectToString(item["title"]); } if (item.ContainsKey("nick")) { model.nick = item["nick"].ToString(); } if (item.ContainsKey("pic_url")) { model.img_url = Helper.JsonObjectToString(item["pic_url"]); } if (item.ContainsKey("price")) { model.price = Helper.JsonObjectToDecimal(item["price"]); } return(model); }
public EntityItemTask GetItemTaskFromJson(string jsonItem) { EntityItemTask model = BLL.BllTopApi.GetItemTaskFromJson(jsonItem); return(model); }