示例#1
0
        public JsonResultEntity Create([FromBody] PromoEntity promoEntity)
        {
            PromoBL          promoBL  = new PromoBL();
            JsonResultEntity response = new JsonResultEntity();

            try
            {
                var result = promoBL.Create(promoEntity);

                if (result.HasWarning())
                {
                    response.Message = String.Join(",", result.Warning);
                    return(response);
                }

                response.Success = true;
                response.Data    = result.Value;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                LoggerHelper.Error(ex);
            }

            return(response);
        }
示例#2
0
        public PromoEntity Create(PromoEntity promoEntity)
        {
            var query = @"INSERT INTO ""Promo""(""Title"",""Description"",""StartDate"",""StartTime"",""EndDate"",""EndTime"",""Tag"",""Issuer"",""Days"",""Times"",""Terms"",""Online"",""CreatedDate"",""PromoCategoryID"",""BrandID"",""Priority"",""Slug"") VALUES(@Title,@Description,@StartDate,@StartTime,@EndDate,@EndTime,@Tag,@Issuer,@Days,@Times,@Terms,@Online,@CreatedDate,@PromoCategoryID,@BrandID,@Priority,@Slug) RETURNING ""ID"";";

            int id = DbConnection.Query <int>(query, promoEntity).Single();

            promoEntity.ID = id;
            return(promoEntity);
        }
示例#3
0
        public int Update(PromoEntity promoEntity)
        {
            int affectedRows = 0;

            if (IsHaveId <PromoEntity>(promoEntity) == false)
            {
                var query = @"UPDATE ""Promo"" SET ""Title""=@Title,""Description""=@Description,""StartDate""=@StartDate,""StartTime""=@StartTime,""EndDate""=@EndDate,""EndTime""=@EndTime,""Tag""=@Tag,""Issuer""=@Issuer,""Days""=@Days,""Times""=@Times,""Terms""=@Terms,""Online""=@Online,""ModifiedDate""=@ModifiedDate,""PromoCategoryID""=@PromoCategoryID,""BrandID""=@BrandID,""Priority""=@Priority,""Slug""=@Slug WHERE ""ID""=@ID";
                affectedRows = DbConnection.Execute(query, promoEntity);
            }

            return(affectedRows);
        }
示例#4
0
        public ResultEntity <PromoEntity> Create(PromoEntity promoEntity)
        {
            var validationResult = new ResultEntity <PromoEntity>();

            promoEntity.CreatedDate = DateTime.Now;

            using (var promoDA = new PromoDA())
            {
                validationResult.Value = promoDA.Create(promoEntity);
            }

            return(validationResult);
        }
示例#5
0
        private void btnTambah_Click(object sender, EventArgs e)
        {
            try
            {
                if (flagperintah == 1)
                {
                    if (cektxt() == true)
                    {
                        errorProvider1.Clear();
                        PromoEntity promo = new PromoEntity(comboBox1.SelectedItem.ToString(), (decimal)double.Parse(edHarga.Text), edKeterangan.Text, edPromo.Text);
                        if (ProControl.CekPromoUnik(promo.Jenis_promo) != 0)
                        {
                            MessageBox.Show("Maaf, data sudah ada " + ProControl.CekPromoUnik(promo.Jenis_promo), "Kesalahan", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        ProControl.EntriPromo(promo.Jenis_promo, promo.Harga, promo.Keterangan, promo.Nama);
                        cleartxt();
                        this.Hide();
                        FormPromo myParent = (FormPromo)this.Parent;
                        myParent.enable();
                    }
                }

                else
                {
                    if (cektxt() == true)
                    {
                        errorProvider1.Clear();
                        PromoEntity promo = new PromoEntity(comboBox1.SelectedItem.ToString(), (decimal)double.Parse(edHarga.Text), edKeterangan.Text, edPromo.Text);
                        if (ProControl.CekPromoUnik(promo.Jenis_promo) > 1)
                        {
                            MessageBox.Show("Maaf, data sudah ada " + ProControl.CekPromoUnik(promo.Jenis_promo), "Kesalahan", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        DialogResult dr = MessageBox.Show("Apakah Anda yakin akan mengupdate pegawai ini ?", "Pertanyaan",
                                                          MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (dr == DialogResult.Yes)
                        {
                            ProControl.EditPromo(promo.Jenis_promo, promo.Harga, promo.Keterangan, int.Parse(txtID.Text), promo.Nama);
                        }
                        cleartxt();
                        this.Hide();
                        FormPromo myParent = (FormPromo)this.Parent;
                        myParent.EnableEdit();
                    }
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.ToString(), "Kesalahan", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#6
0
        public ResultEntity <PromoEntity> Update(PromoEntity promoEntity)
        {
            var validationResult = new ResultEntity <PromoEntity>();

            promoEntity.ModifiedDate = DateTime.Now;

            using (var promoDA = new PromoDA())
            {
                var resultUpdate = promoDA.Update(promoEntity);

                if (resultUpdate <= 0)
                {
                    validationResult.Warning.Add("Failed Updating Promo!");
                    return(validationResult);
                }

                validationResult.Value = promoEntity;
            }

            return(validationResult);
        }