Ejemplo n.º 1
0
        public int AddGiftType(GiftTypeBE mod)
        {
            EntityDE ety = new EntityDE();
            ety.SiteCode = mod.SiteCode;
            ety.EntityTypeCode = mod.EntityTypeCode;
            ety.EntityName = mod.EntityName;
            ety.Code = mod.Code;

            int retVal = 0;
            SqlConnection con = new SqlConnection(DBHelper.ConnectionString);
            try
            {
                _bdmSvc = new BDMService();
                StringBuilder sb = new StringBuilder();
                using (TransactionScope trans = new TransactionScope())
                {
                    mod.ID = _bdmSvc.AddEntity(ety);

                    SqlCommand cmd = new SqlCommand();

                    #region CommandText & Params

                    sb.Append("INSERT INTO [dbo].[GiftType]");
                    sb.Append("([GiftTypeID]");
                    sb.Append(",[IsCondition]");
                    sb.Append(",[Price])");
                    sb.Append("VALUES");
                    sb.Append("(@GiftTypeID");
                    sb.Append(",@IsCondition");
                    sb.Append(",@Price)");

                    cmd.Parameters.AddWithValue("@GiftTypeID", mod.ID);
                    cmd.Parameters.AddWithValue("@IsCondition", mod.IsCondition);
                    cmd.Parameters.AddWithValue("@Price", mod.Price);

                    #endregion

                    cmd.Connection = con;

                    cmd.CommandText = sb.ToString();
                    con.Open();

                    cmd.ExecuteNonQuery();
                    retVal = mod.ID;
                    trans.Complete();
                }
            }
            catch (Exception ex)
            {
                retVal = -1;
            }
            finally
            {
                con.Close();
            }

            return retVal;
        }
Ejemplo n.º 2
0
        //[TestMethod]
        public void AddEntity()
        {
            _bdmSvc = new BDMService();
            EntityDE ety = new EntityDE();
            ety.EntityName = "Imran Farooq";
            ety.EntityTypeCode = EntityTypes.MGR.ToString();
            ety.SiteCode = AppConstants.SITE_CODE;

            AddressDE add = new AddressDE(AddressTypes.Personal.ToString());
            add.AddressLine1 = "St. Ahmad Din Sipahi";
            add.AddressLine2 = "Moh. Fatu Pura, Gujrat";

            ContactDE contact = new ContactDE();
            contact.Mobile1 = "0333-348343499";

            ety.Addresses.Add(add);
            ety.Contacts.Add(contact);

            decimal retVal = _bdmSvc.AddEntity(ety);
        }
Ejemplo n.º 3
0
        public void Entity_CRUD()
        {
            EntityDE ety = new EntityDE();
            ety.SiteCode = "QST";
            ety.EntityTypeCode = "DNR";
            ety.EntityName = "Khairaat";
            ety.Code = "090";

            _bdmSvc = new BDMService();
            int id = _bdmSvc.AddEntity(ety);

            ety.ID = id;
            ety.EntityName = "Khariraat ...";
            bool res = _bdmSvc.ModifyEntity(ety);

            res = _bdmSvc.DeleteEntity(ety.SiteCode, ety.EntityTypeCode, ety.ID);
        }