Beispiel #1
0
        public static bool Pull(NArtikujt artikulli, double sasia, NotValidEvent _notValid)
        {
            bool check = true;

            try
            {
                Magazina magazina = new Magazina(_notValid, artikulli.ID);

                if (artikulli == null)
                {
                    _notValid.Invoke("Error ne Magazine");
                    check = false;
                }
                else if (magazina.Sasia < sasia)
                {
                    _notValid.Invoke("Nuk ka mjaftueshem " + artikulli.Emri + " ne magazine !");
                    check = false;
                }
                else if (magazina.Sasia >= sasia)
                {
                    connection.UpdateInsert("UPDATE Magazina SET Sasia = '" + (magazina.Sasia - sasia) + "' WHERE NArtikullID=" + magazina.NArtikull.ID);
                    check = true;
                }
            }
            catch (Exception e)
            {
                _notValid.Invoke(e.Message);
                return(false);
            }
            return(check);
        }
Beispiel #2
0
        public static NArtikujt Map(DataRow Row)
        {
            NArtikujt artikull = new NArtikujt();

            artikull.ID    = Helper.SantitizeLong(Row["ID"]);
            artikull.Emri  = Helper.SanitizeString(Row["Emri"]);
            artikull.Njesi = new Njesia(Helper.SantitizeLong(Row["Njesia"]));
            return(artikull);
        }
Beispiel #3
0
        public static List <NArtikujt> GetNArtikujt()
        {
            List <NArtikujt> artikujts = new List <NArtikujt>();

            try
            {
                string getNArtikujt = "SELECT * FROM NArtikujt";
                var    tb           = connection.Read(getNArtikujt);
                foreach (DataRow row in tb.Rows)
                {
                    artikujts.Add(NArtikujt.Map(row));
                }
            }
            catch (Exception e)
            {
            }
            return(artikujts);
        }
Beispiel #4
0
        public static bool Push(NArtikujt artikulli, double sasia)
        {
            bool check = true;

            try
            {
                var magazina = Magazina.GetMagazina(artikulli.ID);

                if (artikulli == null)
                {
                    check = false;
                }
                else
                {
                    connection.UpdateInsert("UPDATE Magazina SET Sasia = '" + (magazina.Sasia + sasia) + "' WHERE NArtikullID=" + magazina.NArtikull.ID);
                    check = true;
                }
            }
            catch (Exception e)
            {
                return(false);
            }
            return(check);
        }
Beispiel #5
0
        public static OleDbCommand AddMagazina(NArtikujt artikulli, double sasia)
        {
            var mgz = Magazina.GetMagazina(artikulli.ID);

            return(new OleDbCommand("UPDATE Magazina SET Sasia = '" + (mgz.Sasia + sasia) + "' WHERE NArtikullID=" + mgz.NArtikull.ID));
        }
Beispiel #6
0
 private void MapThis(NArtikujt artikulli)
 {
     this.ID    = artikulli.ID;
     this.Emri  = artikulli.Emri;
     this.Njesi = artikulli.Njesi;
 }