public void AddTypeBL(TypeBO objTypeBO)
        {
            objTypeBO.TypeCount = 0;
            TypeDA objTypeDA = new TypeDA();

            objTypeDA.AddTypeDA(objTypeBO);
        }
Example #2
0
        /// <summary>
        /// To Get Land Type
        /// </summary>
        /// <returns></returns>
        public TypeList GetLandType()
        {
            OracleConnection con = new OracleConnection(AppConfiguration.ConnectionString);
            OracleCommand    cmd;
            string           proc = "USP_MST_LND_GET_TYPE";

            cmd             = new OracleCommand(proc, con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("Sp_recordset", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
            cmd.Connection.Open();
            OracleDataReader dr          = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            TypeBO           objtypeBO   = null;
            TypeList         objtypelist = new TypeList();

            while (dr.Read())
            {
                objtypeBO            = new TypeBO();
                objtypeBO.LND_TYPEID = (Convert.ToInt32(dr.GetValue(dr.GetOrdinal("LND_TYPEID"))));
                objtypeBO.LandType   = dr.GetValue(dr.GetOrdinal("LANDTYPE")).ToString();
                objtypelist.Add(objtypeBO);
            }

            dr.Close();
            return(objtypelist);
        }
Example #3
0
        public static void LoadData()
        {
            TypeBO type = new TypeBO();

            type.Id   = 1;
            type.Name = "Kindergardens";
            TypeDAL.types.Add(type);

            TypeBO type2 = new TypeBO();

            type2.Id   = 2;
            type2.Name = "Elementary Schools";
            TypeDAL.types.Add(type2);

            TypeBO type3 = new TypeBO();

            type3.Id   = 3;
            type3.Name = "High Schools";
            TypeDAL.types.Add(type3);

            TypeBO type4 = new TypeBO();

            type4.Id   = 4;
            type4.Name = "University";
            TypeDAL.types.Add(type4);
        }
Example #4
0
        public static bool Create(int typeId, string name, char gender)
        {
            bool result = false;

            try
            {
                TypeBO    type        = TypeDAL.findById(typeId);
                StudentBO student_new = new StudentBO();
                student_new.Type   = type;
                student_new.Id     = StudentDAL.getList().OrderByDescending(o => o.Id).First().Id + 1;
                student_new.Name   = name;
                student_new.Gender = gender;
                student_new.SetTime();

                StudentDAL.students.Add(student_new);
                result = true;
            }
            catch (Exception)
            {
                result = false;
                throw;
            }

            return(result);
        }
Example #5
0
        public static void LoadData()
        {
            if (TypeDAL.getList().Count == 0)
            {
                TypeDAL.LoadData();
            }

            //string fileName = @"input.csv";
            string fileName = AppDomain.CurrentDomain.BaseDirectory + @"..\DAL\source\input.csv";

            //string fileName = "c:/Users/brayan-pc/documents/visual studio 2017/Projects/Students/DAL/source/input.csv";

            try
            {
                int contador = 0;
                foreach (var line in File.ReadLines(fileName).Skip(1))
                {
                    contador++;
                    var       data        = line.Split(';');
                    TypeBO    type        = TypeDAL.findByName(data[0]);
                    StudentBO student_new = new StudentBO();
                    student_new.Type   = type;
                    student_new.Id     = contador;
                    student_new.Name   = data[1];
                    student_new.Gender = char.Parse(data[2]);
                    student_new.SetTime(data[3]);
                    StudentDAL.students.Add(student_new);
                }
            }
            catch (Exception)
            {
                throw;
            }
            //return myList;
        }
Example #6
0
        public static bool Edit(int id, int typeId, string name, char gender)
        {
            bool result = false;

            try
            {
                foreach (var item in StudentDAL.students)
                {
                    if (item.Id == id)
                    {
                        TypeBO type = TypeDAL.findById(typeId);
                        item.Type   = type;
                        item.Name   = name;
                        item.Gender = gender;
                        item.SetTime();
                    }
                }
                result = true;
            }
            catch (Exception)
            {
                result = false;
            }

            return(result);
        }
        private void ButtonTypeAddProduct_Click(object sender, EventArgs e)
        {
            try
            {
                if (TextBoxTypeNameAddProduct.Text != "" && TextBoxTypePriceAddProduct.Text != "")
                {
                    TypeBO objTypeBO = new TypeBO();
                    objTypeBO.ProductID = (Int32)ComboBoxProductNameAddProduct.SelectedValue;
                    objTypeBO.TypeName  = TextBoxTypeNameAddProduct.Text;
                    objTypeBO.TypePrice = Convert.ToDecimal(TextBoxTypePriceAddProduct.Text);

                    TypeBL objTypeBL = new TypeBL();
                    objTypeBL.AddTypeBL(objTypeBO);

                    MessageBox.Show("Ürün türü başarıyla eklenmiştir");
                }
                else
                {
                    MessageBox.Show("Lütfen tür adı ve fiyatını giriniz");
                }
                TextBoxTypeNameAddProduct.Clear();
                TextBoxTypePriceAddProduct.Clear();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void ButtonAddProduct_Click(object sender, EventArgs e)
        {
            try
            {
                if (TextBoxProductCount.Text != "")
                {
                    TypeBO objTypeBO = new TypeBO();
                    objTypeBO.ProductID = (Int32)ComboBoxProductName.SelectedValue;
                    objTypeBO.TypeName  = ComboBoxProductType.Text;
                    objTypeBO.TypeCount = Convert.ToInt32(TextBoxProductCount.Text);

                    TypeBL objTypeBL = new TypeBL();
                    objTypeBL.AddProductToStockBL(objTypeBO);

                    MessageBox.Show("Ürün başarı ile eklenmiştir");

                    TextBoxProductCount.Clear();
                    ComboBoxProductName.SelectedIndex = 0;
                    PopulateGridViewStockHistory();
                }
                else
                {
                    MessageBox.Show("Lütfen ürün adedini giriniz");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #9
0
        public void UpdateProduct(TypeBO objTypeBO)
        {
            DbConnection  objDbConnection = DbConnection.GetInstance();
            SqlConnection con             = objDbConnection.GetConnection();

            con.Open();
            SqlCommand cmd = new SqlCommand("Update dbo.Type Set TypeName=@TypeName,TypePrice=@TypePrice Where TypeID=@TypeID", con);

            cmd.Parameters.Add(new SqlParameter("@TypeID", objTypeBO.TypeID));
            cmd.Parameters.Add(new SqlParameter("@TypeName", objTypeBO.TypeName));
            cmd.Parameters.Add(new SqlParameter("@TypePrice", objTypeBO.TypePrice));
            cmd.ExecuteNonQuery();
        }
Example #10
0
        public void AddProductToStockDA(TypeBO objTypeBO)
        {
            DbConnection  objDbConnection = DbConnection.GetInstance();
            SqlConnection con             = objDbConnection.GetConnection();

            con.Open();
            SqlCommand cmd = new SqlCommand("Update dbo.Type Set TypeCount=@TypeCount Where TypeName=@TypeName And ProductID=@ProductID", con);

            cmd.Parameters.Add(new SqlParameter("@TypeName", objTypeBO.TypeName));
            cmd.Parameters.Add(new SqlParameter("@ProductID", objTypeBO.ProductID));
            cmd.Parameters.Add(new SqlParameter("@TypeCount", objTypeBO.TypeCount));
            cmd.ExecuteNonQuery();
        }
Example #11
0
        public void AddTypeDA(TypeBO objTypeBO)
        {
            DbConnection  objDbConnection = DbConnection.GetInstance();
            SqlConnection con             = objDbConnection.GetConnection();

            con.Open();
            SqlCommand cmd = new SqlCommand("Insert Into dbo.Type (TypeName,TypeCount,TypePrice,ProductID) Values (@TypeName,@TypeCount,@TypePrice,@ProductID)", con);

            cmd.Parameters.Add(new SqlParameter("@TypeName", objTypeBO.TypeName));
            cmd.Parameters.Add(new SqlParameter("@TypeCount", objTypeBO.TypeCount));
            cmd.Parameters.Add(new SqlParameter("@TypePrice", objTypeBO.TypePrice));
            cmd.Parameters.Add(new SqlParameter("@ProductID", objTypeBO.ProductID));
            cmd.ExecuteNonQuery();
        }
Example #12
0
        public static bool Delete(TypeBO type)
        {
            bool result = false;

            try
            {
                result = true;
            }
            catch (Exception)
            {
                result = false;
            }

            return(result);
        }
Example #13
0
        public static bool Insert(TypeBO type)
        {
            bool result = false;

            try
            {
                TypeDAL.types.Add(type);
                result = true;
            }
            catch (Exception)
            {
                result = false;
            }
            return(result);
        }
Example #14
0
        public static List <TypeBO> getListSearch()
        {
            List <TypeBO> list     = new List <TypeBO>();
            TypeBO        new_type = new TypeBO();

            new_type.Id   = 0;
            new_type.Name = "Select an Item (Type)";
            list.Add(new_type);

            foreach (var item in TypeDAL.types)
            {
                list.Add(item);
            }

            return(list);
        }
        public void AddProductToStockBL(TypeBO objTypeBO)
        {
            StockBO   objStockBO   = new StockBO();
            StockDA   objStockDA   = new StockDA();
            TypeDA    objTypeDA    = new TypeDA();
            ProductDA objProductDA = new ProductDA();

            objStockBO.StockName  = objProductDA.GetProductName(objTypeBO.ProductID);
            objStockBO.StockType  = objTypeBO.TypeName;
            objStockBO.StockCount = objTypeBO.TypeCount;
            objStockBO.StockDate  = DateTime.Today;

            int oldCount = objTypeDA.GetOldTypeCount(objTypeBO.TypeName, objTypeBO.ProductID);

            objTypeBO.TypeCount = objTypeBO.TypeCount + oldCount;

            objTypeDA.AddProductToStockDA(objTypeBO);
            objStockDA.AddStockRecord(objStockBO);
        }
Example #16
0
        public int GetTypeID(TypeBO objTypeBO)
        {
            DbConnection  objDbConnection = DbConnection.GetInstance();
            SqlConnection con             = objDbConnection.GetConnection();

            con.Open();
            SqlCommand cmd = new SqlCommand("Select TypeID From dbo.Type Where ProductID=@ProductID And TypeName=@TypeName", con);

            cmd.Parameters.Add(new SqlParameter("@ProductID", objTypeBO.ProductID));
            cmd.Parameters.Add(new SqlParameter("@TypeName", objTypeBO.TypeName));
            SqlDataReader dr     = cmd.ExecuteReader();
            int           TypeID = 0;

            if (dr.Read())
            {
                TypeID = dr.GetInt32(0);
            }
            return(TypeID);
        }
Example #17
0
        public static void LoadData2()
        {
            TypeBO type = new TypeBO();

            if (TypeDAL.getList().Count == 0)
            {
                TypeDAL.LoadData();
            }

            type = TypeDAL.findById(2);

            StudentBO student = new StudentBO();

            student.Id     = 1;
            student.Name   = "Jose";
            student.Gender = 'M';
            student.Type   = type;
            student.Time   = DateTime.Now.ToString();

            StudentDAL.students.Add(student);

            StudentBO student_2 = new StudentBO();

            student_2.Id     = 2;
            student_2.Name   = "Maria";
            student_2.Gender = 'F';
            student_2.Type   = type;
            student_2.Time   = DateTime.Now.ToString();

            StudentDAL.students.Add(student_2);

            StudentBO student_3 = new StudentBO();

            student_3.Id     = 3;
            student_3.Name   = "Jorge";
            student_3.Gender = 'M';
            student_3.Type   = type;
            student_3.Time   = DateTime.Now.ToString();

            StudentDAL.students.Add(student_3);
            //return myList;
        }
        //Create a method to calculate the best and worst type for a team to face against
        public TypeDAO CalculateTypes(List <int> TypesToCalculate)
        {
            //Instantiate a new instance of the TypeCalculator object
            TypeCalculator Calculator = new TypeCalculator();
            //Get all types in the types table and assign them to a TypeDAO List
            List <TypeDAO> AllDAOTypes = typeData.GetAllTypes();
            //Create a new Instance of the TypeBO List
            List <TypeBO> AllBOTypes = new List <TypeBO>();

            //Loop thorugh TypeDAO List and map each type and values into a TypeBO Value and send it to the TypeBO List
            foreach (TypeDAO Types in AllDAOTypes)
            {
                //Create a new instance of the TypeBO Object
                TypeBO BOTypes = new TypeBO();
                BOTypes.TypeID    = Types.TypeID;
                BOTypes.TypeName  = Types.TypeName;
                BOTypes.xNormal   = Types.xNormal;
                BOTypes.xFire     = Types.xFire;
                BOTypes.xWater    = Types.xWater;
                BOTypes.xGrass    = Types.xGrass;
                BOTypes.xElectric = Types.xElectric;
                BOTypes.xIce      = Types.xIce;
                BOTypes.xFighting = Types.xFighting;
                BOTypes.xPoision  = Types.xPoision;
                BOTypes.xGround   = Types.xGround;
                BOTypes.xFlying   = Types.xFlying;
                BOTypes.xPsychic  = Types.xPsychic;
                BOTypes.xBug      = Types.xBug;
                BOTypes.xRock     = Types.xRock;
                BOTypes.xGhost    = Types.xGhost;
                BOTypes.xDragon   = Types.xDragon;
                BOTypes.xDark     = Types.xDark;
                BOTypes.xSteel    = Types.xSteel;
                BOTypes.xFairy    = Types.xFairy;
                AllBOTypes.Add(BOTypes);
            }
            //Create a new TypeBO Object
            List <TypeBO> TypesToEvaluate = new List <TypeBO>();

            //Loop through the list of interagers passed as a parameter
            foreach (int chosenType in TypesToCalculate)
            {
                //Check to make sure the type is not null
                if (chosenType != 19)
                {
                    //Loop thorugh all types in the TypeBO List
                    foreach (TypeBO BOType in AllBOTypes)
                    {
                        //Search through the typeBO List until the typeID matches the given interager and add the values of that type to the TypesToEvaluate List
                        //Repeat this until all types have been sifted through
                        if (chosenType == BOType.TypeID)
                        {
                            TypeBO Types = new TypeBO();
                            Types.TypeID    = BOType.TypeID;
                            Types.TypeName  = BOType.TypeName;
                            Types.xNormal   = BOType.xNormal;
                            Types.xFire     = BOType.xFire;
                            Types.xWater    = BOType.xWater;
                            Types.xGrass    = BOType.xGrass;
                            Types.xElectric = BOType.xElectric;
                            Types.xIce      = BOType.xIce;
                            Types.xFighting = BOType.xFighting;
                            Types.xPoision  = BOType.xPoision;
                            Types.xGround   = BOType.xGround;
                            Types.xFlying   = BOType.xFlying;
                            Types.xPsychic  = BOType.xPsychic;
                            Types.xBug      = BOType.xBug;
                            Types.xRock     = BOType.xRock;
                            Types.xGhost    = BOType.xGhost;
                            Types.xDragon   = BOType.xDragon;
                            Types.xDark     = BOType.xDark;
                            Types.xSteel    = BOType.xSteel;
                            Types.xFairy    = BOType.xFairy;
                            TypesToEvaluate.Add(Types);
                        }
                    }
                }
            }
            //Send the final list of Types to the Buissness logic layer to be evaluated
            TypeBO FinalTypeValues = Calculator.Calculate(TypesToEvaluate);
            //Create a new instance of the TypeDAO Object
            TypeDAO FinalValues = new TypeDAO();

            //Map the new calculated values from TypeBO To TypeDAO
            FinalValues.xNormal   = FinalTypeValues.xNormal;
            FinalValues.xFire     = FinalTypeValues.xFire;
            FinalValues.xWater    = FinalTypeValues.xWater;
            FinalValues.xGrass    = FinalTypeValues.xGrass;
            FinalValues.xElectric = FinalTypeValues.xElectric;
            FinalValues.xIce      = FinalTypeValues.xIce;
            FinalValues.xFighting = FinalTypeValues.xFighting;
            FinalValues.xPoision  = FinalTypeValues.xPoision;
            FinalValues.xGround   = FinalTypeValues.xGround;
            FinalValues.xFlying   = FinalTypeValues.xFlying;
            FinalValues.xPsychic  = FinalTypeValues.xPsychic;
            FinalValues.xBug      = FinalTypeValues.xBug;
            FinalValues.xRock     = FinalTypeValues.xRock;
            FinalValues.xGhost    = FinalTypeValues.xGhost;
            FinalValues.xDragon   = FinalTypeValues.xDragon;
            FinalValues.xDark     = FinalTypeValues.xDark;
            FinalValues.xSteel    = FinalTypeValues.xSteel;
            FinalValues.xFairy    = FinalTypeValues.xFairy;
            FinalValues.Max       = FinalTypeValues.Max;
            FinalValues.Max2      = FinalTypeValues.Max2;
            FinalValues.MaxName   = FinalTypeValues.MaxName;
            FinalValues.Max2Name  = FinalTypeValues.Max2Name;
            FinalValues.Min       = FinalTypeValues.Min;
            FinalValues.Min2      = FinalTypeValues.Min2;
            FinalValues.MinName   = FinalTypeValues.MinName;
            FinalValues.Min2Name  = FinalTypeValues.Min2Name;
            //Return the final values to the Presentation Layer
            return(FinalValues);
        }
Example #19
0
        public static TypeBO findById(int id)
        {
            TypeBO type = TypeDAL.types.FirstOrDefault(o => o.Id == id);

            return(type);
        }
Example #20
0
        public static TypeBO findByName(string name)
        {
            TypeBO type = TypeDAL.types.FirstOrDefault(o => o.Name == name);

            return(type);
        }
Example #21
0
 public TypesController(Context context)
 {
     _context = context;
     typeBO   = new TypeBO(context);
 }
        public int GetTypeID(TypeBO objTypeBO)
        {
            TypeDA objTypeDA = new TypeDA();

            return(objTypeDA.GetTypeID(objTypeBO));
        }
        public void UpdateProduct(TypeBO objTypeBO)
        {
            TypeDA objTypeDA = new TypeDA();

            objTypeDA.UpdateProduct(objTypeBO);
        }