Example #1
0
        public bool AddPaymentByIncoming(Payment pay, string TransType)
        {
            using (var trans = ent.Database.BeginTransaction())
            {
                bool sonuc = false;
                try
                {
                    ent.Payments.Add(pay);
                    ent.SaveChanges();

                    GuestTransaction gt = new GuestTransaction();
                    gt.Date        = pay.Date;
                    gt.TransType   = TransType;
                    gt.Debt        = 0;
                    gt.Credit      = pay.Incoming;
                    gt.GuestId     = pay.GuestId;
                    gt.Status      = true;
                    gt.Description = pay.Description;
                    ent.GuestTransactions.Add(gt);
                    ent.SaveChanges();

                    trans.Commit();
                    sonuc = true;
                }
                catch (Exception)
                {
                    trans.Rollback();
                }
                return(sonuc);
            }
        }
Example #2
0
        public bool CancelReservations(int ID)
        {
            using (var trans = ent.Database.BeginTransaction())
            {
                bool sonuc = false;

                try
                {
                    Sale sa = (from s in ent.Sales
                               where s.GuestId == ID && s.Deleted == false
                               orderby s.Id descending
                               select s).FirstOrDefault();
                    sa.Deleted    = true;
                    sa.TotalPrice = 0;
                    ent.SaveChanges();
                    GuestTransaction gt = (from g in ent.GuestTransactions
                                           where g.Id == ID && g.TransType == "Konaklama Ücreti"
                                           orderby g.Id descending
                                           select g).FirstOrDefault();
                    gt.Status = false;
                    gt.Debt   = 0;
                    ent.SaveChanges();
                    trans.Commit();
                    sonuc = true;
                }
                catch (Exception ex)
                {
                    string hata = ex.Message;
                    trans.Rollback();
                }
                return(sonuc);
            }
        }
Example #3
0
        public bool AddExtraAndGTrans(ExtraTransactions Ex, int GId)
        {
            using (var trans = ent.Database.BeginTransaction())
            {
                bool Sonuc = false;
                try
                {
                    ent.ExtraTransactions.Add(Ex);
                    ent.SaveChanges();

                    GuestTransaction g = new GuestTransaction();
                    g.Date        = Ex.TransactionDate;
                    g.TransType   = "Extra Ücreti";
                    g.Debt        = Ex.Sum;
                    g.Credit      = 0;
                    g.GuestId     = Ex.GuestId;
                    g.Status      = true;
                    g.Description = "";
                    ent.GuestTransactions.Add(g);
                    ent.SaveChanges();

                    trans.Commit();
                    Sonuc = true;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    string hata = ex.Message;
                }
                return(Sonuc);
            }
        }
Example #4
0
        public async Task <ActionResult <GuestTransaction> > PostGuestTransaction(TransactionRequest request)
        {
            Dictionary <string, Object> data = new Dictionary <string, object>();

            data.Add("status", "SUCCESS");
            data.Add("data", null);

            if (request.PaymentCard == null || request.PaymentCard.Equals("") ||
                request.FirstName == null || request.FirstName.Equals("") ||
                request.LastName == null || request.LastName.Equals("") ||
                request.PhoneNumber == null || request.PhoneNumber.Equals("")
                )
            {
                data.Remove("status");
                data.Add("status", "WARNING");
                data.Add("message", "Field not null ! !");
                return(BadRequest(data));
            }

            bool paymentCardRegex = Regex.Match(request.PaymentCard, @"^[0-9]+$").Success;
            bool phoneRegex       = Regex.Match(request.PhoneNumber, @"(\+[0-9]{2}|\+[0-9]{2}\(0\)|\(\+[0-9]{2}\)\(0\)|00[0-9]{2}|0)([0-9]{9}|[0-9\-\s]{9,18})").Success;

            if (paymentCardRegex == false)
            {
                data.Remove("status");
                data.Add("status", "WARNING");
                data.Add("message", "Payment card must be a number ! !");
                return(BadRequest(data));
            }
            if (phoneRegex == false)
            {
                data.Remove("status");
                data.Add("status", "WARNING");
                data.Add("message", "Phone number must be a number ! !");
                return(BadRequest(data));
            }

            var plan        = _context.Plans.Find(request.PlanId);
            var transaction = new GuestTransaction
            {
                PlanId      = plan.Id,
                FirstName   = request.FirstName,
                LastName    = request.LastName,
                PhoneNumber = request.PhoneNumber,
                Simtype     = "Prepay",
                PaymentCard = request.PaymentCard,
                CreatedDate = DateTime.Now,
            };

            _context.GuestTransactions.Add(transaction);

            await _context.SaveChangesAsync();

            data.Remove("data");
            data.Add("message", "Add new data is success ! !");
            data.Add("data", transaction);

            return(Ok(data));
        }
        //private void btnOdaSec_Click(object sender, EventArgs e)
        //{
        //    frmOdaSec frm = new frmOdaSec();
        //    frm.ShowDialog();
        //    txtOdaNo.Text = OdaNo;
        //    txtGirisTarihi.Text = Giris.ToShortDateString();
        //    txtCikisTarihi.Text = Cikis.ToShortDateString();
        //    TimeSpan fark = Cikis - Giris;
        //    int gunsayisi = fark.Days;
        //    decimal OdaFiyat = Rp.GetRoomPrice(OdaNo);
        //    txtToplamTutar.Text = ((gunsayisi + 1) * OdaFiyat).ToString();
        //}

        private void btnOnayla_Click(object sender, EventArgs e)
        {
            //if (txtAdi.Text.Trim() == "" || txtSoyadi.Text == "" || txtTc.Text == "")
            //{
            //    MessageBox.Show("Zorunlu alanlar girilmedi.", "Dikkat Eksik Bilgi!");
            //}

            Sale sa = new Sale();

            sa.RoomId      = Rp.GetRoomId(OdaNo);
            sa.CheckIn     = Giris;
            sa.CheckOut    = Cikis;
            sa.NoOfGuests  = 1;
            sa.TotalPrice  = ToplamTutar;
            sa.PersonnelId = General.PersonelId;
            sa.GuestId     = Gid;
            if (Giris.Date == DateTime.Now.Date)
            {
                sa.Status = true;
            }
            else
            {
                sa.Status = false;
            }
            Sp.AddSales(sa);

            GuestTransaction gtrans = new GuestTransaction();

            gtrans.Date = DateTime.Now;
            /*if (Giris.Date == DateTime.Now.Date)*/ gtrans.TransType = "Konaklama Ücreti";
            //else { gtrans.TransType = "Rezervasyon Ücreti"; }

            gtrans.Debt    = ToplamTutar;
            gtrans.Credit  = 0;
            gtrans.GuestId = Gid;
            gtrans.Status  = true;
            if (Giris.Date == DateTime.Now.Date)
            {
                gtrans.Description = "Konaklama Açılış";
            }
            else
            {
                gtrans.Description = "Rezervasyon";
            }
            if (Gtp.AddGTrans(gtrans))
            {
                MessageBox.Show("Kayıt yapıldı");
            }
            else
            {
                MessageBox.Show("Kayıt yapılmadı");
            }
        }
        public bool AddGTrans(GuestTransaction gt)
        {
            bool Sonuc = false;

            ent.GuestTransactions.Add(gt);
            try
            {
                ent.SaveChanges();
                Sonuc = true;
            }
            catch (Exception ex)
            {
                string hata = ex.Message;
            }
            return(Sonuc);
        }
Example #7
0
        public bool EarlyCheckOut(int GId, int RId, decimal GerekliOdeme)
        {
            using (var trans = ent.Database.BeginTransaction())
            {
                bool sonuc = false;
                try
                {
                    List <Guest> glist = ent.Guests.Where(x => x.RoomId == RId && x.Status == true).ToList();
                    foreach (Guest ig in glist)
                    {
                        ig.Status = false;
                    }
                    ent.SaveChanges();

                    GuestTransaction gs = ent.GuestTransactions.Where(x => x.GuestId == GId && x.Status == true).FirstOrDefault();
                    gs.Debt = GerekliOdeme;
                    ent.SaveChanges();
                    List <GuestTransaction> gt = ent.GuestTransactions.Where(x => x.GuestId == GId && x.Status == true).ToList();
                    foreach (GuestTransaction item in gt)
                    {
                        item.Status = false;
                    }
                    ent.SaveChanges();

                    Sale sa = ent.Sales.Where(x => x.GuestId == GId).FirstOrDefault();
                    sa.Status     = false;
                    sa.TotalPrice = GerekliOdeme;
                    sa.CheckOut   = DateTime.Now;
                    ent.SaveChanges();

                    List <ExtraTransactions> et = ent.ExtraTransactions.Where(x => x.GuestId == GId).ToList();
                    foreach (ExtraTransactions item in et)
                    {
                        item.Status = false;
                    }
                    ent.SaveChanges();

                    trans.Commit();
                    sonuc = true;
                }
                catch (Exception)
                {
                    trans.Rollback();
                }
                return(sonuc);
            }
        }
 public bool DeleteGTrans(GuestTransaction gt)
 {
     throw new NotImplementedException();
 }
Example #9
0
        private void btnOnayla_Click(object sender, EventArgs e)
        {
            if (txtAdi.Text.Trim() == "" || txtSoyadi.Text == "" || txtTc.Text == "")
            {
                MessageBox.Show("Zorunlu alanlar girilmedi.", "Dikkat Eksik Bilgi!");
            }
            Guest gue = new Guest();

            gue.FirstName = txtAdi.Text;
            gue.LastName  = txtSoyadi.Text;

            gue.IdentificationNo = txtTc.Text;
            gue.RoomId           = Rp.GetRoomId(OdaNo);
            gue.Adress           = txtAdres.Text;
            gue.Gender           = cbCinsiyet.SelectedItem.ToString();
            gue.Birthday         = dtpDogumTarihi.Value;
            gue.ContactNo        = txtTelefon.Text;
            gue.Email            = txtEmail.Text;
            if (Giris.Date == DateTime.Now.Date)
            {
                gue.Status = true;
            }
            else
            {
                gue.Status = false;
            }
            if (Gp.AddGuest(gue))
            {
                Guest gst = Gp.GetGuest();
                Sale  sa  = new Sale();
                sa.RoomId     = gst.RoomId;
                sa.CheckIn    = Giris;
                sa.CheckOut   = Cikis;
                sa.NoOfGuests = Convert.ToInt32(cbMisafirSayisi.SelectedItem.ToString());
                try
                {
                    sa.TotalPrice = ToplamTutar;
                }
                catch (FormatException)
                {
                    throw;
                }
                if (Giris.Date == DateTime.Now.Date)
                {
                    sa.Status = true;
                }
                else
                {
                    sa.Status = false;
                }
                sa.PersonnelId = General.PersonelId;
                sa.GuestId     = gst.Id;
                if (Sp.AddSales(sa))
                {
                    GuestTransaction Gtr = new GuestTransaction();
                    Gtr.Date = DateTime.Now;
                    /*if (Giris.Date == DateTime.Now.Date)*/
                    Gtr.TransType = "Konaklama Ücreti";
                    //else { gtrans.TransType = "Rezervasyon Ücreti"; }
                    try
                    {
                        Gtr.Debt = ToplamTutar;
                    }
                    catch (FormatException)
                    {
                        throw;
                    }
                    Gtr.Credit  = 0;
                    Gtr.GuestId = gst.Id;
                    Gtr.Status  = true;
                    if (Giris.Date == DateTime.Now.Date)
                    {
                        Gtr.Description = "Konaklama Açılış";
                    }
                    else
                    {
                        Gtr.Description = "Rezervasyon";
                    }
                    if (GTrans.AddGTrans(Gtr))
                    {
                        MessageBox.Show("Kayıt yapıldı");
                    }
                    else
                    {
                        MessageBox.Show("Misafir harekeleri oluşturulamadı");
                    }
                }
                else
                {
                    MessageBox.Show("Satış Yapılamadı");
                }
            }
            else
            {
                MessageBox.Show("Yapılmadı");
            }
        }