private void btn_Srh_Click(object sender, EventArgs e) { DeliciousEntities dbcontext = new DeliciousEntities(); var q = dbcontext.Member_Table.Where(n => n.CellNumber.Contains(this.tb_SrhCondition.Text) || n.MemberName.Contains(this.tb_SrhCondition.Text) || n.Email.Contains(this.tb_SrhCondition.Text)).Select(n => new { n.MemberID, n.MemberName, n.Nickname, n.CellNumber, n.Email }); this.dgv_MemInfo.DataSource = q.ToList(); }
private void btn_CheckEdit_Click(object sender, EventArgs e) { DeliciousEntities dbcontext = new DeliciousEntities(); var countsamename = dbcontext.Ingredient_Table.Where(n => n.Ingredient == tb_IngrName.Text).Select(n => n).Count(); if (countsamename > 1) { MessageBox.Show("食材名稱重複,無法使用該名稱"); return; } var hasnums = new Regex("[0-9]+"); var hasSymbolChar = new Regex(@"[!@#$%^&*().,=';_\x2f\x2d\x5b\x5d\x22\x20\x5c]+"); if (string.IsNullOrWhiteSpace(this.tb_IngrName.Text)) { MessageBox.Show("食材名稱不可含有空白"); return; } if (hasSymbolChar.IsMatch(this.tb_IngrName.Text) || hasnums.IsMatch(this.tb_IngrName.Text)) { MessageBox.Show("食材名稱不可含有空白/特殊字元/數字"); return; } if (this.tb_IngrName.Text.Length > 10) { MessageBox.Show("食材名稱不可超過10個字"); return; } if (hasSymbolChar.IsMatch(this.tb_IngUnt.Text)) { MessageBox.Show("食材單位不可含有空白/特殊字元/數字"); return; } if (!hasnums.IsMatch(tb_IngSto.Text)) { MessageBox.Show("數量需為數字"); return; } if (!hasnums.IsMatch(tb_IngPr.Text)) { MessageBox.Show("價錢需為數字"); return; } try { int i = cb_IngrCat.Text.ToString().IndexOf(':'); int CIDforNew = Convert.ToInt32(cb_IngrCat.Text.ToString().Substring(0, i)); var q = dbcontext.Ingredient_Table.Where(n => n.IngredientID == IngID).Select(n => n); foreach (var item in q) { item.Ingredient = this.tb_IngrName.Text; item.IngredientCategoryID = CIDforNew; item.IngredientUnit = this.tb_IngUnt.Text; item.Price = Convert.ToDecimal(this.tb_IngPr.Text); item.AmountInStore = Convert.ToInt32(this.tb_IngSto.Text); item.MerchandiseDescription = this.tb_Ingdes.Text; item.InStoreOrNot = this.cb_IsSell.Checked; // ingri.IngPics = item.Merchandise_Picture_Table.FirstOrDefault(); } dbcontext.SaveChanges(); GetDataForIng(); MessageBox.Show("修改成功"); } catch (Exception) { } }
public bool addCaddcolnfolder(string foldername, int memberID) { DeliciousEntities dbcontext = new DeliciousEntities(); //判斷新增的收藏夾名稱是否重複 var countsame = dbcontext.CollectionFolder_Table.Where(m => m.MemberID == memberID && m.CollectionFolder == foldername).Select(m => m.CollectionFolder).Count(); if (countsame > 0) {//如果收藏夾名稱重複 回傳false MessageBox.Show("已有相同名稱收藏夾"); return(false); } else if (foldername == "" || foldername.Contains(" ")) {//收藏夾名稱若為空白 回傳false MessageBox.Show("新增收藏夾的名稱不可含空白"); return(false); } else {//如果收藏夾名稱沒有重複 並回傳true CollectionFolder_Table _collectionFolder = new CollectionFolder_Table() { CollectionFolder = foldername, MemberID = memberID }; dbcontext.CollectionFolder_Table.Add(_collectionFolder); dbcontext.SaveChanges(); return(true); } }
public void IngdTips(DeliciousEntities DBContext, TextBox textBox, ToolTip toolTip) { DeliciousEntities dbc = DBContext; int[] tagids = this.FindAdviceIngds(dbc, textBox.Text); string LastTag = textBox.Text.Split().LastOrDefault(); if (dbc.Ingredient_Table.Where(t => t.Ingredient == LastTag).ToList().Count() == 0) { if (tagids.Count() != 0) { var atags = tagids.Select(i => dbc.Ingredient_Table.Where(t => t.IngredientID == i).Select(t => t.Ingredient).FirstOrDefault()).ToList().Take(8); string tips = "您是不是要輸入:"; foreach (string atag in atags) { tips += atag + " "; } toolTip.SetToolTip(textBox, tips); } else { toolTip.SetToolTip(textBox, "請輸入食材"); } } else { toolTip.SetToolTip(textBox, "您輸入了:" + LastTag); } }
public int[] TagIdsToRecipeIds(DeliciousEntities DBContext, int[] TagIds) { var dbc = DBContext; int[] recipeids = dbc.Hashtag_Record_Table.GroupBy(r => r.RecipeID).Where(g => TagIds.All(t => g.Where(r => r.HashTagID == t).Count() != 0)).Select(g => g.Key).ToArray <int>(); return(recipeids); }
private void flp_Pic_DragDrop(object sender, DragEventArgs e) { try { DeliciousEntities dbcontext = new DeliciousEntities(); if (CountPic > 0) { IngID = Convert.ToInt32(this.dataGridView1.Rows[this.bindingSource1.Position].Cells["食材編號"].Value); string[] filenames = (string[])(e.Data.GetData(DataFormats.FileDrop)); for (int i = 0; i < filenames.Length && CountPic > 0; i++) { System.IO.MemoryStream ms = new System.IO.MemoryStream(); Image.FromFile(filenames[i]).Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] bytes; bytes = ms.GetBuffer(); Merchandise_Picture_Table TableNew = new Merchandise_Picture_Table() { IngredientID = IngID, MerchandisePicture = bytes }; dbcontext.Merchandise_Picture_Table.Add(TableNew); dbcontext.SaveChanges(); CountPic--; } } else { MessageBox.Show("圖片超過5張了"); } ShowPic(); } catch (Exception) { } }
public void TagTips(DeliciousEntities DBContext, TextBox textBox, ToolTip toolTip) { DeliciousEntities dbc = DBContext; int[] tagids = this.FindAdviceTags(dbc, textBox.Text); string LastTag = textBox.Text.Split().LastOrDefault(); if (dbc.Hashtag_Table.Where(t => t.Hasgtag == LastTag).ToList().Count() == 0) { if (tagids.Count() != 0) { var atags = tagids.Select(i => dbc.Hashtag_Table.Where(t => t.HashtagID == i).Select(t => t.Hasgtag).FirstOrDefault()).ToList(); string tips = "您是不是要輸入:"; foreach (string atag in atags) { tips += "#" + atag + " "; } toolTip.SetToolTip(textBox, tips); } else { toolTip.SetToolTip(textBox, "請輸入HashTag"); } } else { toolTip.SetToolTip(textBox, "您輸入了:#" + LastTag); } }
public IQueryable <Accusation_Table> get_Accusation_Table_All(DeliciousEntities Get_DE, int get_mode) { var q = from n in Get_DE.Accusation_Table where n.AccusedAvatar == get_mode.ToString() select n; return(q); }
public int[] IngdStringToIngdIds(DeliciousEntities DBContext, string IngdsString) { var dbc = DBContext; string[] tags = IngdsString.Split(); int[] tagids = dbc.Ingredient_Table.Where(t => tags.Contains(t.Ingredient)).Select(t => t.IngredientID).ToArray <int>(); return(tagids); }
public int[] TagsStringToTagIds(DeliciousEntities DBContext, string TagsString) { var dbc = DBContext; string[] tags = TagsString.Split(); int[] tagids = dbc.Hashtag_Table.Where(t => tags.Contains(t.Hasgtag)).Select(t => t.HashtagID).ToArray <int>(); return(tagids); }
public int[] RcpStringToRcpIds(DeliciousEntities DBContext, string TagsString) { var dbc = DBContext; string[] tags = TagsString.Split(); int[] tagids = dbc.Recipe_Table.Where(t => tags.Contains(t.RecipeName)).Select(t => t.RecipeID).ToArray <int>(); return(tagids); }
private void Fill_Dvg_Order() { DeliciousEntities dbcontext = new DeliciousEntities(); var q = dbcontext.Order_Table.Where(n => n.OrderStatus == this.cb_OrderStatusCat.Text).Select(n => new { n.OrderID, n.OrderDate, n.OrderStatus, n.DeliveredDate, n.DeliveryCounty, n.PayMethod }); this.bindingSource1.DataSource = q.ToList(); this.dgv_Order.DataSource = this.bindingSource1; this.bindingNavigator1.BindingSource = this.bindingSource1; }
public FrmAnswerYesNo(int IngId) { DeliciousEntities dbcontext = new DeliciousEntities(); InitializeComponent(); IngIDfordelete = IngId; var q = dbcontext.Ingredient_Table.Single(n => n.IngredientID == IngId).Ingredient.ToString(); this.lb_IngName.Text = "食材名稱 " + q; }
private void Picbox_DoubleClick(object sender, EventArgs e) { DeliciousEntities dbcontext = new DeliciousEntities(); PictureBox picdelete = (PictureBox)sender; int DeleteID = Convert.ToInt32(picdelete.Name); var pic = (dbcontext.Merchandise_Picture_Table.Where(n => n.MerchandisePicID == DeleteID).Select(n => n)).FirstOrDefault(); dbcontext.Merchandise_Picture_Table.Remove(pic); dbcontext.SaveChanges(); ShowPic(); }
private void btn_Srh_Click(object sender, EventArgs e) { DeliciousEntities dbcontext = new DeliciousEntities(); var q = dbcontext.Member_Table.Where(n => n.CellNumber.Contains(this.tb_SrhCondition.Text) || n.MemberName.Contains(this.tb_SrhCondition.Text) || n.Email.Contains(this.tb_SrhCondition.Text)).Select(n => new { n.MemberID, n.AccountName, n.MemberName, n.CellConfirm, n.Email }); this.bindingSource1.DataSource = q.ToList(); this.dgv_MemberInfo.DataSource = this.bindingSource1; this.tb_MID.DataBindings.Add("Text", bindingSource1, "MemberID"); this.tb_AccountName.DataBindings.Add("Text", bindingSource1, "AccountName"); this.tb_MemberName.DataBindings.Add("Text", bindingSource1, "MemberName"); this.tb_Email.DataBindings.Add("Text", bindingSource1, "Email"); }
private void GetDataForIng() { DeliciousEntities dbcontext = new DeliciousEntities(); var q = dbcontext.Ingredient_Table.Select(n => new { 食材名稱 = n.Ingredient, 食材分類 = n.IngredientCategoryID + ":" + n.IngredientCategory_Table.IngredientCategory, 食材單位 = n.IngredientUnit, 商品售價 = n.Price, 商品庫存 = n.AmountInStore, 商品描述 = n.MerchandiseDescription, 商品販賣狀況 = n.InStoreOrNot, 食材編號 = n.IngredientID }); this.bindingSource1.DataSource = q.ToList(); this.dataGridView1.DataSource = this.bindingSource1; this.bindingNavigator1.BindingSource = this.bindingSource1; this.dataGridView1.Columns["食材編號"].Visible = false; FormContent(); }
private void Add_CB_CatForIng() { DeliciousEntities dbcontext = new DeliciousEntities(); var q = from p in dbcontext.IngredientCategory_Table select new { ID = p.IngredientCategoryID + ":" + p.IngredientCategory }; foreach (var item in q) { cb_IngrCat.Items.Add(item.ID.ToString()); } cb_IngrCat.SelectedIndex = 0; }
public int[] TagIdsToRecipeIds(DeliciousEntities DBContext, int[] TagIds, bool fuzzy = (false)) { if (fuzzy) { var dbc = DBContext; int[] recipeids = dbc.Hashtag_Record_Table.GroupBy(r => r.RecipeID).Where(g => TagIds.Any(t => g.Where(r => r.HashTagID == t).Count() != 0)).Select(g => g.Key).ToArray <int>(); return(recipeids); } else { return(TagIdsToRecipeIds(DBContext, TagIds)); } }
private void btn_Delivered_Click(object sender, EventArgs e) { if (this.dgv_Order.Rows.Count <= 0) { MessageBox.Show("目前無資料"); return; } DeliciousEntities dbcontext = new DeliciousEntities(); var q = dbcontext.Order_Table.AsEnumerable().Single(n => n.OrderID == Convert.ToInt32(this.tb_OrderID.Text)); q.OrderStatus = "已送達"; q.DeliveredDate = DateTime.Now; dbcontext.SaveChanges(); Fill_Dvg_Order(); }
private void button1_Click(object sender, EventArgs e) { DeliciousEntities dbcontext = new DeliciousEntities(); var q0 = dbcontext.Ingredient_Table.Single(n => n.IngredientID == IngIDfordelete); var q1 = dbcontext.Merchandise_Picture_Table.Where(n => n.IngredientID == IngIDfordelete).Select(n => n); foreach (var Q in q1) { dbcontext.Merchandise_Picture_Table.Remove(Q); } dbcontext.Ingredient_Table.Remove(q0); dbcontext.SaveChanges(); this.Close(); }
private void btn_Send_Click(object sender, EventArgs e) { DeliciousEntities dbcontext = new DeliciousEntities(); string confornnums = dbcontext.Member_Table.AsEnumerable().Single(n => n.MemberID == Convert.ToInt32(this.tb_MID.Text)).EmailConfirm.ToString(); SendEmail sendtomember = new SendEmail() { email = this.tb_Email.Text, conform = confornnums, //驗證碼 Subject = "瘋廚網認證信寄發", //主旨 Body = "您好 " + this.tb_MemberName.Text + "\n\n 管理員 " + Viewbag.Admin.AdminName + " 很高興能為您服務" + "\n\n以下為認證碼\n", //內文 Result = "感謝", //回傳訊息 }; sendtomember.send(); MessageBox.Show("寄送成功"); }
private void btn_delete_Click(object sender, EventArgs e) { DeliciousEntities dbcontext = new DeliciousEntities(); var countused = dbcontext.Ingredient_Record_Table.Where(n => n.IngredientID == IngID).Select(n => n).Count(); if (countused > 0) { MessageBox.Show("此食材已被使用過,無法刪除"); return; } FrmAnswerYesNo yesNoFrm = new FrmAnswerYesNo(IngID); yesNoFrm.ShowDialog(); GetDataForIng(); this.bindingSource1.Position = 0; }
private bool checkcontent() { DeliciousEntities dbcontext = new DeliciousEntities(); var countcell = dbcontext.Member_Table.AsEnumerable().Where(n => n.CellNumber == tb_cellnumber.Text && n.MemberID != Convert.ToInt32(this.tb_Mid.Text)).Select(n => n).Count(); var iswords = new Regex(@"[\u4E00-\u9FA5]{2,4}$"); var isnums = new Regex(@"09[0-9]{8}$"); if (!iswords.IsMatch(tb_MemberName.Text)) { MessageBox.Show("會員姓名2-4個中文字"); return(false); } if (!isnums.IsMatch(tb_cellnumber.Text)) { MessageBox.Show("請輸入正確的手機號碼"); return(false); } if (countcell > 0) { MessageBox.Show("手機號碼已被註冊過"); return(false); } var q = (from m in dbcontext.Member_Table where m.Email == this.tb_email.Text select m).ToList(); if (q.Count > 1) { MessageBox.Show("此信箱已被使用"); return(false); } var emailjdg = new Regex(@"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"); if (string.IsNullOrWhiteSpace(this.tb_email.Text)) { MessageBox.Show("請輸入電子信箱"); return(false); } else if (!emailjdg.IsMatch(this.tb_email.Text)) { MessageBox.Show("請輸入正確的電子信箱"); return(false); } return(true); }
private void btn_Canceled_Click(object sender, EventArgs e) { if (this.dgv_Order.Rows.Count <= 0) { MessageBox.Show("目前無資料"); return; } DeliciousEntities dbcontext = new DeliciousEntities(); var q = dbcontext.Order_Table.AsEnumerable().Single(n => n.OrderID == Convert.ToInt32(this.tb_OrderID.Text)); var qc = dbcontext.Order_Detail_Table.AsEnumerable().Where(n => n.OrderiD == Convert.ToInt32(this.tb_OrderID.Text)).Select(n => n); foreach (var item in qc) { var qd = dbcontext.Ingredient_Table.Single(n => n.IngredientID == item.IngredientID); qd.AmountInStore = qd.AmountInStore + item.InCartQuantity; } q.OrderStatus = "已取消"; dbcontext.SaveChanges(); Fill_Dvg_Order(); }
private void ShowPic() { DeliciousEntities dbcontext = new DeliciousEntities(); this.flp_Pics.Controls.Clear(); var pic = dbcontext.Merchandise_Picture_Table.Where(n => n.IngredientID == IngID).Select(n => n); CountPic = 5; foreach (var item in pic) { byte[] bytes = (byte[])(item.MerchandisePicture); PictureBox picbox = new PictureBox(); System.IO.MemoryStream ms = new System.IO.MemoryStream(bytes); picbox.Image = Image.FromStream(ms); picbox.SizeMode = PictureBoxSizeMode.StretchImage; flp_Pics.Controls.Add(picbox); picbox.DoubleClick += Picbox_DoubleClick; picbox.Name = item.MerchandisePicID.ToString(); CountPic--; } }
public int[] RcpStringToRcpIds(DeliciousEntities DBContext, string TagsString, bool fuzzy = (false)) { if (fuzzy) { var dbc = DBContext; char[] tags = TagsString.ToCharArray(); string[] stc = tags.Select(c => c.ToString()).Distinct().ToArray(); var ttsl = dbc.Recipe_Table.ToList(); var tts = ttsl.Select(t => new { t.RecipeID, ttcs = t.RecipeName.ToCharArray().Select(c => c.ToString()).Distinct().ToArray(), }).ToList(); int[] tagids = tts.Where(tt => tt.ttcs.Where(ttc => stc.Contains(ttc)).Count() != 0).Select(t => t.RecipeID).ToArray(); return(tagids); } else { return(RcpStringToRcpIds(DBContext, TagsString)); } }
public int[] IngdStringToIngdIds(DeliciousEntities DBContext, string IngdsString, bool fuzzy = (false)) { if (fuzzy) { var dbc = DBContext; char[] tags = IngdsString.ToCharArray(); string[] stc = tags.Select(c => c.ToString()).Distinct().ToArray(); var ttsl = dbc.Ingredient_Table.ToList(); var tts = ttsl.Select(t => new { t.IngredientID, ttcs = t.Ingredient.ToCharArray().Select(c => c.ToString()).Distinct().ToArray(), }).ToList(); int[] tagids = tts.Where(tt => tt.ttcs.Where(ttc => stc.Contains(ttc)).Count() != 0).Select(t => t.IngredientID).ToArray(); return(tagids); } else { return(IngdStringToIngdIds(DBContext, IngdsString)); } }
public int[] FindAdviceTags(DeliciousEntities DBContext, string TagsString) { var dbc = DBContext; string LastTag = TagsString.Split().LastOrDefault(); char[] tags = LastTag.ToCharArray(); string[] stc = tags.Select(c => c.ToString()).Distinct().ToArray(); var ttsl = dbc.Hashtag_Table.ToList(); var tts = ttsl.Select(t => new { t.HashtagID, ttcs = t.Hasgtag.ToCharArray().Select(c => c.ToString()).Distinct().ToArray(), }).ToList(); int[] tagids = tts.Where(tt => tt.ttcs.Where(ttc => stc.Contains(ttc)).Count() != 0).Select(t => t.HashtagID).ToArray(); if (dbc.Hashtag_Table.Where(t => t.Hasgtag == LastTag).ToList().Count() != 0) { tagids = new int[] { } } ; return(tagids); }
private void FormContent() { try { DeliciousEntities dbcontext = new DeliciousEntities(); IngID = Convert.ToInt32(this.dataGridView1.Rows[this.bindingSource1.Position].Cells["食材編號"].Value); var q = dbcontext.Ingredient_Table.Where(n => n.IngredientID == IngID).Select(n => n); foreach (var item in q) { this.tb_IngrName.Text = item.Ingredient; this.cb_IngrCat.Text = item.IngredientCategoryID + ":" + item.IngredientCategory_Table.IngredientCategory; this.tb_IngUnt.Text = item.IngredientUnit; this.tb_IngPr.Text = item.Price.ToString(); this.tb_IngSto.Text = item.AmountInStore.ToString(); this.tb_Ingdes.Text = item.MerchandiseDescription; this.cb_IsSell.Checked = item.InStoreOrNot; } ShowPic(); } catch (Exception) { } }