Ejemplo n.º 1
0
 public void AddItem(string title, string answera, string answerb,
                     string answerc, string answerd, string answer, int state)
 {
     // 向备忘录里面添加新的元素;
     DataBase.Item todo = new DataBase.Item(title, answera, answerb, answerc, answerd, answer, state);
     this.allItems.Add(todo);
     DataBase.DbContext.InsertData(todo.getID(), title, answera, answerb,
                                   answerc, answerd, answer, state);
 }
Ejemplo n.º 2
0
        public void UpdateItem(int id, string title, string answera, string answerb,
                               string answerc, string answerd, string answer, int state)
        {
            int index = getIndexOfItemById(id);

            if (index != -1)
            {
                DataBase.DbContext.UpdateData(id, title, answera, answerb, answerc, answerd, answer, state);
                allItems[index].UpdateItem(title, answera, answerb, answerc, answerd, answer, state);
            }

            // set selectedItem to null after update
            this.selectedItem = null;
        }
Ejemplo n.º 3
0
        public void RemoveItem(int id)
        {
            // DIY
            // set selectedItem to null after remove
            int index = getIndexOfItemById(id);

            if (index != -1)
            {
                this.allItems.Remove(selectedItem);
                DataBase.DbContext.DeleteData(id);
            }

            this.selectedItem = null;
        }
Ejemplo n.º 4
0
        private void SaveData()
        {
            try
            {
                ADAM.DataBase.ADAMConnectionString Mdb = new DataBase.ADAMConnectionString();
                ADAM.DataBase.Item dr = new DataBase.Item();

                #region InsertImgIntoSql
                string       filePath = fulImage.PostedFile.FileName;
                string       filename = Path.GetFileName(filePath);
                string       ext      = Path.GetExtension(filename);
                Stream       fs       = fulImage.PostedFile.InputStream;
                BinaryReader br       = new BinaryReader(fs);
                Byte[]       bytes    = br.ReadBytes((Int32)fs.Length);
                #endregion

                dr.Code             = long.Parse(txtCode.Text);
                dr.Image            = bytes;
                dr.ItemStatus       = int.Parse(ddlItemStatus.SelectedValue);
                dr.ItemTypeId       = long.Parse(ddlItemType.SelectedValue);
                dr.ItemunitId       = long.Parse(ddlItemUnit.SelectedValue);
                dr.LimitQty         = decimal.Parse(txtLimitQty.Text);
                dr.Note             = txtNote.Text;
                dr.Sex              = int.Parse(ddlSex.SelectedValue);
                dr.Specification    = txtSpecification.Text;
                dr.Name             = txtName.Text;
                dr.ProductionLineId = int.Parse(ddlProductionLine.SelectedValue);

                Mdb.Items.Add(dr);
                Mdb.SaveChanges();

                #region showImg
                Binary binary = dr.Image;
                byte[] Nbytes;
                string Base64String = string.Empty;
                Nbytes           = binary.ToArray();
                Base64String     = Convert.ToBase64String(bytes, 0, Nbytes.Length);
                ImgItem.ImageUrl = "data:image/png;base64," + Base64String;
                #endregion
            }
            catch { Response.Write("<script>alert('خطأ أثناء الحفظ من فضلك تأكد من ادخال البيانات بشكل صحيح او الاتصال بقاعدة البيانات')</script>"); }
        }