Exemplo n.º 1
0
        //insert to database command
        public void SendCollab(int fk_id, int fk_taskid, string comment, string taskdetail)
        {
            SqlCommand insertcommand = GetSqlCommand(fk_taskid);


            insertcommand.Parameters.AddWithValue("@Comments", comment);
            insertcommand.Parameters.AddWithValue("@Fk_commentor_ID", fk_id);
            insertcommand.Parameters.AddWithValue("@DateCommented", DateTime.Now);
            insertcommand.Parameters.AddWithValue("@Fk_task_ID", fk_taskid);

            oasisconnectionString.Open();

            int results = insertcommand.ExecuteNonQuery();

            if (results > 0)
            {
                oasisconnectionString.Close();

                var query = "Select * from users where id='" + fk_id + "'";

                oasisconnectionString.Open();

                SqlCommand           command       = new SqlCommand(query, oasisconnectionString);
                NotificationsDisplay notifications = new NotificationsDisplay();

                using (SqlDataReader rd = command.ExecuteReader())
                {
                    if (rd.Read())
                    {
                    }
                }
            }

            oasisconnectionString.Close();
        }
Exemplo n.º 2
0
        public void AddcheckListB(
            decimal _4_Softner,
            decimal _5_1_Micron_Preasure,
            decimal _6_Membrane_Preasure,
            decimal _7_Flow_Rate_RAW,
            decimal _2_PF_5_Micron,
            decimal _1_PF_10_Micron,
            decimal TDs_Main,
            decimal TDs_clean,
            decimal _3_Sand_Filter

            )
        {
            decimal MunTanklevelPercentage   = ((_1_PF_10_Micron + _2_PF_5_Micron + _3_Sand_Filter + _4_Softner) / 200) * 100;
            decimal cleanTankLevelPercentage = ((_5_1_Micron_Preasure + _6_Membrane_Preasure) / 400) * 100;

            string OzoneStatus = "";

            if (MunTanklevelPercentage <= 50)
            {
                OzoneStatus = "Not OK";
            }
            else if ((MunTanklevelPercentage > 50) && MunTanklevelPercentage <= 100)
            {
                OzoneStatus = "OK";
            }
            else
            {
                OzoneStatus = "Critical Effected";
            }

            //color meanings
            //Purple The tank is clean
            //Blue Slighly clean will need to be changed soon so that they can prepare for anytihing that need to be changed on the shop
            //pink its not clean, an employee need to change it

            string CrystalColor = "";

            if ((cleanTankLevelPercentage < 50))
            {
                CrystalColor = "Pink";
            }
            else if ((cleanTankLevelPercentage >= 50) && (cleanTankLevelPercentage <= 100))
            {
                CrystalColor = "Purple";
            }

            //The pump cannot pump from a tank which is not clean and the ozone is not ok.
            //We need to dertimine if the ozone is ok and txhe tank is clean so that we can be notified that the pump is not pumping water
            string PumpFuncntionality = "";

            if ((CrystalColor == "Purple") && (OzoneStatus == "OK"))
            {
                PumpFuncntionality = "OK";
            }
            else if ((CrystalColor == "Pink") && (OzoneStatus == "OK"))
            {
                PumpFuncntionality = "Not OK, Tank Need to be Changed";
            }
            else if ((CrystalColor == "Purple") && (OzoneStatus == "Not OK"))
            {
                PumpFuncntionality = "Not OK, Ozone need to be Udjusted";
            }
            else if ((CrystalColor == "Pink") && (OzoneStatus == "Not OK"))
            {
                PumpFuncntionality = "Not OK";
            }

            //we need to dertimine how much clean water was produced at the day
            //clean water are only produced when he pump Functionality is ok
            //single tank hold up to 100 liters of water, so it can be filled to any point in liters(can only clean up 100 liters of water at a time
            //to get the percentage of the clean water produced at a day, we will use the clean tank percentage.
            //We will also use the Mun tank level, this is the percentage from the value entered by the manager based on how he used the scale at oasis to measure the psi unit.
            decimal CleanWaterTotalReading          = 0;
            decimal totalPercentage                 = 0;
            decimal CleanWaterTotalFlowrateCapacity = 0;

            if (PumpFuncntionality == "OK")
            {
                CleanWaterTotalFlowrateCapacity = (_7_Flow_Rate_RAW / 100) * 100 * 25;                 // in percentages
                //how much in percentages can the tannk hold and clean water
                totalPercentage = (((MunTanklevelPercentage + cleanTankLevelPercentage) / 200) * 100); //in percentages

                //we need to get clean water reading,this  gives a reading of much water was cleaned
                CleanWaterTotalReading = (CleanWaterTotalFlowrateCapacity / totalPercentage) * 100; //in liters
            }
            else
            {
                CleanWaterTotalFlowrateCapacity = 0;
            }



            // we need to find out how much clean water was produced on that day over raw water, oasis clean upto 100 liters of water per day

            decimal DayCleanedWater = CleanWaterTotalReading / _7_Flow_Rate_RAW * 100;  //in liters


            // we need to get the conductivity

            //we get the conductivity by mesuring the TDS of clean water and the Tds of raw water. this value are entered by the manager.this will be divided by the total factors effected the change of water value
            //
            decimal conductivity = ((TDs_clean + TDs_Main) / (_1_PF_10_Micron + _2_PF_5_Micron + _3_Sand_Filter + _4_Softner + _5_1_Micron_Preasure + _6_Membrane_Preasure)); //in liter/psi


            NotificationsDisplay notifications = new NotificationsDisplay();

            if (CrystalColor == "Pink")
            {
                notifications.CreateAnotification("Crystal color is Pink", "ProccessMaintananceEmployee");
            }

            if (OzoneStatus == "Not OK")
            {
                notifications.CreateAnotification("Ozone is not ok", "ProccessMaintananceEmployee");
            }



            SqlCommand insertcommand = GetSqlCommand();

            insertcommand.Parameters.AddWithValue("@date", DateTime.Now);

            insertcommand.Parameters.AddWithValue("@_4_Softner", _4_Softner);
            insertcommand.Parameters.AddWithValue("@_5_1_Micron_Preasure", _5_1_Micron_Preasure);

            insertcommand.Parameters.AddWithValue("@_6_Membrane_Preasure", _6_Membrane_Preasure);
            insertcommand.Parameters.AddWithValue("@_7_Flow_Rate_RAW", _7_Flow_Rate_RAW);
            insertcommand.Parameters.AddWithValue("@_8_Flow_Rate_Clean", CleanWaterTotalFlowrateCapacity);

            insertcommand.Parameters.AddWithValue("@_9_Pump_Functional", PumpFuncntionality);
            insertcommand.Parameters.AddWithValue("@Conductive", conductivity);
            insertcommand.Parameters.AddWithValue("@Clean_Water_Meter_Reading", CleanWaterTotalReading);
            insertcommand.Parameters.AddWithValue("@CheckListType", "B");

            insertcommand.Parameters.AddWithValue("@Litres_Purified_Since_Previous_Reading", DayCleanedWater);

            insertcommand.Parameters.AddWithValue("@_3_Sand_Filter", _3_Sand_Filter);
            insertcommand.Parameters.AddWithValue("@_2_PF_5_Micron", _2_PF_5_Micron);

            insertcommand.Parameters.AddWithValue("@_1_PF_10_Micron", _1_PF_10_Micron);
            insertcommand.Parameters.AddWithValue("@Clean_tank_level", cleanTankLevelPercentage);
            insertcommand.Parameters.AddWithValue("@Mun_Tank_level", MunTanklevelPercentage);

            insertcommand.Parameters.AddWithValue("@Silcone_Crystal_Color", CrystalColor);
            insertcommand.Parameters.AddWithValue("@Ozone", OzoneStatus);

            insertcommand.Parameters.AddWithValue("@TDs_Main", TDs_Main);
            insertcommand.Parameters.AddWithValue("@TDs_clean", TDs_clean);
            oasisconnectionString.Open();

            int results = insertcommand.ExecuteNonQuery();

            if (results > 0)
            {
                oasisconnectionString.Close();
            }
        }
Exemplo n.º 3
0
        //insert to database command
        public string NewTask(int fk_id, string typeofTask, string taskdetail = "")
        {
            SqlCommand insertcommand = GetSqlCommand();


            if (taskdetail == "")
            {
                insertcommand.Parameters.AddWithValue("@TaskDetail", Item.Taskdetail);
                insertcommand.Parameters.AddWithValue("@dateAssigned", DateTime.Now);



                insertcommand.Parameters.AddWithValue("@DateFinished", DateTime.Now.AddDays(20));
                insertcommand.Parameters.AddWithValue("@DueDate", DateTime.Now.AddDays(7));
                insertcommand.Parameters.AddWithValue("@TaskStatus", "Started");
                insertcommand.Parameters.AddWithValue("@TaskType", typeofTask);

                insertcommand.Parameters.AddWithValue("@Fk_EmployeeID", fk_id);
                oasisconnectionString.Open();

                int results = insertcommand.ExecuteNonQuery();

                if (results > 0)
                {
                    oasisconnectionString.Close();

                    var query = "Select * from users where id='" + fk_id + "'";

                    oasisconnectionString.Open();

                    SqlCommand           command       = new SqlCommand(query, oasisconnectionString);
                    NotificationsDisplay notifications = new NotificationsDisplay();

                    using (SqlDataReader rd = command.ExecuteReader())
                    {
                        if (rd.Read())
                        {
                            if (rd["UserRole"].ToString() == "Manager")
                            {
                                notifications.CreateAnotification(rd["fullNames"].ToString() + " has started a task for " + Item.Taskdetail, "Employees");
                                notifications.CreateAnotification(rd["fullNames"].ToString() + " has started a task for " + Item.Taskdetail, "Boss");
                            }
                            else if (rd["UserRole"].ToString() == "Boss")
                            {
                                notifications.CreateAnotification(rd["fullNames"].ToString() + " has started a task for " + Item.Taskdetail, "Manager");
                            }
                            else if (rd["UserRole"].ToString() == "ProccessAreaEmployee")
                            {
                                notifications.CreateAnotification(rd["fullNames"].ToString() + " has started a task for " + Item.Taskdetail, "Manager");
                            }
                            else if (rd["UserRole"].ToString() == "FrontEndEmployee")
                            {
                                notifications.CreateAnotification(rd["fullNames"].ToString() + " has started a task for " + Item.Taskdetail, "Manager");
                            }
                            else if (rd["UserRole"].ToString() == "StorageAreaEmployee")
                            {
                                notifications.CreateAnotification(rd["fullNames"].ToString() + " has started a task for " + Item.Taskdetail, "Manager");
                            }
                        }
                    }
                }
            }
            else
            {
                insertcommand.Parameters.AddWithValue("@TaskDetail", taskdetail);
                insertcommand.Parameters.AddWithValue("@dateAssigned", DateTime.Now);
                insertcommand.Parameters.AddWithValue("@DateFinished", DateTime.Now.AddDays(20));
                insertcommand.Parameters.AddWithValue("@DueDate", DateTime.Now.AddDays(7));
                insertcommand.Parameters.AddWithValue("@TaskStatus", "Started");
                insertcommand.Parameters.AddWithValue("@TaskType", typeofTask);
                insertcommand.Parameters.AddWithValue("@Fk_EmployeeID", fk_id);


                oasisconnectionString.Open();

                int results = insertcommand.ExecuteNonQuery();

                if (results > 0)
                {
                    oasisconnectionString.Close();

                    var query = "Select * from users where id='" + fk_id + "'";

                    oasisconnectionString.Open();

                    SqlCommand           command       = new SqlCommand(query, oasisconnectionString);
                    NotificationsDisplay notifications = new NotificationsDisplay();

                    using (SqlDataReader rd = command.ExecuteReader())
                    {
                        if (rd.Read())
                        {
                            if (rd["UserRole"].ToString() == "Manager")
                            {
                                notifications.CreateAnotification(rd["fullNames"].ToString() + " has started a task for " + taskdetail, "Employees");
                                notifications.CreateAnotification(rd["fullNames"].ToString() + " has started a task for " + taskdetail, "Boss");
                            }
                            else if (rd["UserRole"].ToString() == "Boss")
                            {
                                notifications.CreateAnotification(rd["fullNames"].ToString() + " has started a task for " + taskdetail, "Manager");
                            }
                            else if (rd["UserRole"].ToString() == "ProccessAreaEmployee")
                            {
                                notifications.CreateAnotification(rd["fullNames"].ToString() + " has started a task for " + taskdetail, "Manager");
                            }
                            else if (rd["UserRole"].ToString() == "FrontEndEmployee")
                            {
                                notifications.CreateAnotification(rd["fullNames"].ToString() + " has started a task for " + taskdetail, "Manager");
                            }
                            else if (rd["UserRole"].ToString() == "StorageAreaEmployee")
                            {
                                notifications.CreateAnotification(rd["fullNames"].ToString() + " has started a task for " + taskdetail, "Manager");
                            }
                        }
                    }
                }
            }



            oasisconnectionString.Close();

            return("");
        }