Exemple #1
0
        void Show()
        {
            try
            {
                fusha = BussinessFusha.GetFushaById(fushaid);

                if (fusha.FushaEMbuluar == true)
                {
                    fmbuluar_PO.IsChecked = true;
                }

                if (fusha.FushaEMbuluar == false)
                {
                    fmbuluar_JO.IsChecked = true;
                }

                if (fusha.BariArtificial == true)
                {
                    bartificial_PO.IsChecked = true;
                }

                if (fusha.BariArtificial == false)
                {
                    bartificial_JO.IsChecked = true;
                }

                txtGjatesia.Text     = fusha.Gjatesia;
                txtGjeresia.Text     = fusha.Gjeresia;
                txtcmimiifushes.Text = fusha.CmimiFushes.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnShto_Click(object sender, EventArgs e)
        {
            try
            {
                string gjatesia      = txtGjatesia.Text;
                string gjeresia      = txtGjeresia.Text;
                double cmimi         = double.Parse(txtcmimiifushes.Text);
                bool   fushaEmbuluar = false;
                if (fmbuluar_PO.IsChecked)
                {
                    fushaEmbuluar = true;
                }
                if (fmbuluar_JO.IsChecked)
                {
                    fushaEmbuluar = false;
                }

                bool bariartificial = false;
                if (bartificial_PO.IsChecked)
                {
                    bariartificial = true;
                }
                if (bartificial_JO.IsChecked)
                {
                    bariartificial = false;
                }

                if (String.IsNullOrEmpty(gjatesia) || String.IsNullOrEmpty(gjeresia) || String.IsNullOrEmpty(txtcmimiifushes.Text))
                {
                    MessageBox.Show("Mbushini te gjitha hapsirat e kerkuara");
                }
                else
                {
                    Fusha newFusha = new Fusha()
                    {
                        BariArtificial = bariartificial,
                        FushaEMbuluar  = fushaEmbuluar,
                        Gjatesia       = gjatesia,
                        Gjeresia       = gjeresia,
                        CmimiFushes    = cmimi
                    };

                    BussinessFusha.InsertFusha(newFusha);
                    MessageBox.Show("U shtua nje fushe e re");
                    this.Close();
                }
            }
            catch (FormatException ex)
            {
                MessageBox.Show("Gabim ne tip te te dhenave");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnShto_Click(object sender, EventArgs e)
        {
            try
            {
                Rezervimi newRezervim = new Rezervimi();
                int       fushaid     = int.Parse(cmbFushat.SelectedValue.ToString());
                int       klientiid   = int.Parse(cmbKlientat.SelectedValue.ToString());
                DateTime  dt          = Convert.ToDateTime(dtDataeRezervimit.Value);
                DateTime  dtF         = Convert.ToDateTime(dtFillimiRezervimit.Value);
                DateTime  dtM         = Convert.ToDateTime(dtMbarimiRezervimit.Value);
                if (dtF.Date >= DateTime.Now && dtM.Date >= DateTime.Now)
                {
                    if (dtM.Hour > dtF.Hour)
                    {
                        newRezervim.User = Form1.useri;
                        Fusha fusha = new Fusha();
                        fusha.FushaID     = fushaid;
                        newRezervim.Fusha = fusha;

                        newRezervim.Klienti           = new Klienti();
                        newRezervim.Klienti.KlientiID = klientiid;
                        newRezervim.DataERezervimit   = DateTime.Now;
                        newRezervim.FillimiRezervimit = dtF;
                        newRezervim.MbarimiRezervimit = dtM;

                        if (BussinessRezervimi.CheckReservation(newRezervim) == true)
                        {
                            MessageBox.Show("U shtua nje rezervim i ri");
                            BussinessRezervimi.InsertRezervim(newRezervim);
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("Ekziston rezervim ne kete kohe");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Data e mbarimit duhet të jete më e madhe se data e fillimit");
                    }
                }
                else
                {
                    MessageBox.Show("Gabim në datë");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #4
0
        public static List <Fusha> GetAll()
        {
            List <Fusha> fushat = null;

            try
            {
                using (SqlConnection con = new SqlConnection(Connection.ConnectionString))
                {
                    SqlCommand cmd = new SqlCommand("sp_GetAllFushat", con);
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    con.Open();

                    using (SqlDataReader sqlr = cmd.ExecuteReader())
                    {
                        if (sqlr.HasRows)
                        {
                            fushat = new List <Fusha>();

                            while (sqlr.Read())
                            {
                                Fusha fusha = new Fusha();

                                fusha.FushaID        = int.Parse(sqlr["FushaID"].ToString());
                                fusha.FushaEMbuluar  = bool.Parse(sqlr["FushaEMbuluar"].ToString());
                                fusha.BariArtificial = bool.Parse(sqlr["BariArtificial"].ToString());
                                fusha.Gjatesia       = sqlr["Gjatesia"].ToString();
                                fusha.Gjeresia       = sqlr["Gjeresia"].ToString();
                                fusha.CmimiFushes    = double.Parse(sqlr["CmimiIFushes"].ToString());
                                fusha.IsActive       = bool.Parse(sqlr["IsActive"].ToString());
                                fushat.Add(fusha);
                            }
                        }
                    }
                    con.Close();
                }
            }
            catch (Exception)
            {
                fushat = null;
                throw;
            }
            return(fushat);
        }
Exemple #5
0
 public static void Insert(Fusha fusha)
 {
     try
     {
         using (SqlConnection con = new SqlConnection(Connection.ConnectionString))
         {
             SqlCommand cmd = new SqlCommand("sp_ShtoFusha", con);
             cmd.CommandType = System.Data.CommandType.StoredProcedure;
             con.Open();
             cmd.Parameters.AddWithValue("@FushaEMbuluar", fusha.FushaEMbuluar);
             cmd.Parameters.AddWithValue("@BariArtificial", fusha.BariArtificial);
             cmd.Parameters.AddWithValue("@Gjatesia", fusha.Gjatesia);
             cmd.Parameters.AddWithValue("@Gjeresia", fusha.Gjeresia);
             cmd.Parameters.AddWithValue("@CmimiIFushes", fusha.CmimiFushes);
             cmd.ExecuteNonQuery();
             con.Close();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 public static void EditFusha(int id, Fusha fusha)
 {
     AccessFusha.Edit(id, fusha);
 }
 public static void InsertFusha(Fusha fusha)
 {
     AccessFusha.Insert(fusha);
 }