コード例 #1
0
        private TypesOfProductType CreateTypesOfProductType()
        {
            TypesOfProductType p = new TypesOfProductType();

            p.Name   = TxtName.Text;
            p.TypeID = Convert.ToInt32(DdlType.SelectedValue);
            return(p);
        }
コード例 #2
0
        protected void BtnSend_Click(object sender, EventArgs e)
        {
            TypesOfProductTypeModel model = new TypesOfProductTypeModel();
            TypesOfProductType      pt    = CreateTypesOfProductType();

            LblResult.Text = model.InsertTypesOfProductType(pt);
            TxtName.Text   = string.Empty;
        }
コード例 #3
0
 public string InsertTypesOfProductType(TypesOfProductType typesOfProductType)
 {
     try
     {
         Ukrainian_delicacyEntities db = new Ukrainian_delicacyEntities();
         db.TypesOfProductTypes.Add(typesOfProductType);
         db.SaveChanges();
         return(typesOfProductType.Name + " uspješno je umetnuto");
     }
     catch (Exception e)
     {
         return("Error" + e);
     }
 }
コード例 #4
0
        public string UpdateTypesOfProductType(int id, TypesOfProductType typesOfProductType)
        {
            try
            {
                Ukrainian_delicacyEntities db = new Ukrainian_delicacyEntities();
                TypesOfProductType         p  = db.TypesOfProductTypes.Find(id);
                p.Name   = typesOfProductType.Name;
                p.TypeID = typesOfProductType.TypeID;
                db.SaveChanges();

                return(typesOfProductType.Name + "uspješno je ažurirano");
            }
            catch (Exception e)
            {
                return("Error" + e);
            }
        }
コード例 #5
0
        public string DeleteTypesOfProductType(int id)
        {
            try
            {
                Ukrainian_delicacyEntities db = new Ukrainian_delicacyEntities();
                TypesOfProductType         typesOfProductType = db.TypesOfProductTypes.Find(id);
                db.TypesOfProductTypes.Attach(typesOfProductType);
                db.TypesOfProductTypes.Remove(typesOfProductType);

                db.SaveChanges();

                return(typesOfProductType.Name + "uspješno je obrisano");
            }
            catch (Exception e)
            {
                return("Error" + e);
            }
        }