예제 #1
0
        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();
        }
예제 #2
0
        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) { }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
        }
예제 #6
0
        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) { }
        }
예제 #7
0
        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);
            }
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        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);
        }
예제 #12
0
        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;
        }
예제 #13
0
        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;
        }
예제 #14
0
        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();
        }
예제 #15
0
        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");
        }
예제 #16
0
        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();
        }
예제 #17
0
        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;
        }
예제 #18
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));
     }
 }
예제 #19
0
        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();
        }
예제 #20
0
        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();
        }
예제 #21
0
        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("寄送成功");
        }
예제 #22
0
        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;
        }
예제 #23
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);
        }
예제 #24
0
        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();
        }
예제 #25
0
        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--;
            }
        }
예제 #26
0
 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));
     }
 }
예제 #27
0
 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));
     }
 }
예제 #28
0
        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);
        }
예제 #29
0
        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) { }
        }