Ejemplo n.º 1
0
 //only for 1 order
 public static bool deleteOrderDB(OrderDataModel orderToBeDeleted)
 {
     try
     {
         if (Connect())
         {
             string query = "delete from productionOrders where idProductionOrder=@IdProductionOrder and targetPieces=@TargetPieces and priority=@Priority and orderNum=@OrderNum and orderModified=@OrderModified and machineRecipe=@MachineRecipe and timestampInsert=@TimestampInsert and status=@Status";
             using (SqlCommand cmd = new SqlCommand(query, m_dbConnection))
             {
                 cmd.Parameters.AddWithValue("@Status", orderToBeDeleted.Status);
                 cmd.Parameters.AddWithValue("@IdProductionOrder", orderToBeDeleted.IdProductionOrder);
                 cmd.Parameters.AddWithValue("@MachineRecipe", orderToBeDeleted.MachineRecipe);
                 cmd.Parameters.AddWithValue("@TargetPieces", orderToBeDeleted.TargetPieces);
                 cmd.Parameters.AddWithValue("@Priority", orderToBeDeleted.Priority);
                 cmd.Parameters.AddWithValue("@OrderNum", orderToBeDeleted.Order);
                 cmd.Parameters.AddWithValue("@OrderModified", orderToBeDeleted.OrderModified);
                 cmd.Parameters.AddWithValue("@TimestampInsert", orderToBeDeleted.InsertingTime);
                 cmd.ExecuteNonQuery();
             }
             return(true);
         }
         else
         {
             MessageBox.Show("Unable to insert into DB");
             return(false);
         }
     }
     catch (Exception ecc)
     {
         MessageBox.Show(ecc.ToString());
         return(false);
     }
 }
Ejemplo n.º 2
0
 //only for 1 order
 public static bool insertOrderDB(OrderDataModel orderToBeInserted)
 {
     try
     {
         if (Connect())
         {
             string query = "insert into productionOrders(idProductionOrder,targetPieces, priority, orderNum, orderModified, machineRecipe, timestampInsert, status) values(@IdProductionOrder, @TargetPieces, @Priority, @OrderNum, @OrderModified, @MachineRecipe, @TimestampInsert, @Status) ";
             using (SqlCommand cmd = new SqlCommand(query, m_dbConnection))
             {
                 cmd.Parameters.AddWithValue("@Status", orderToBeInserted.Status);
                 cmd.Parameters.AddWithValue("@IdProductionOrder", orderToBeInserted.IdProductionOrder);
                 cmd.Parameters.AddWithValue("@MachineRecipe", orderToBeInserted.MachineRecipe);
                 cmd.Parameters.AddWithValue("@TargetPieces", orderToBeInserted.TargetPieces);
                 cmd.Parameters.AddWithValue("@Priority", orderToBeInserted.Priority);
                 cmd.Parameters.AddWithValue("@OrderNum", orderToBeInserted.Order);
                 cmd.Parameters.AddWithValue("@OrderModified", orderToBeInserted.OrderModified);
                 cmd.Parameters.AddWithValue("@TimestampInsert", orderToBeInserted.InsertingTime);
                 cmd.ExecuteNonQuery();
             }
             return(true);
         }
         else
         {
             MessageBox.Show("Unable to insert into DB");
             return(false);
         }
     }
     catch (Exception ecc)
     {
         MessageBox.Show(ecc.ToString());
         return(false);
     }
 }
Ejemplo n.º 3
0
 //only for the status
 public static bool updateOrderDB(OrderDataModel orderToBeUpdated, int newStatus)
 {
     try
     {
         if (Connect())
         {
             string query = "update productionOrders set status=@Status where idProductionOrder like @IdProductionOrder and machineRecipe like @MachineRecipe and targetPieces like @TargetPieces and priority like @Priority";
             using (SqlCommand cmd = new SqlCommand(query, m_dbConnection))
             {
                 cmd.Parameters.AddWithValue("@Status", newStatus);
                 cmd.Parameters.AddWithValue("@IdProductionOrder", orderToBeUpdated.IdProductionOrder);
                 cmd.Parameters.AddWithValue("@MachineRecipe", orderToBeUpdated.MachineRecipe);
                 cmd.Parameters.AddWithValue("@TargetPieces", orderToBeUpdated.TargetPieces);
                 cmd.Parameters.AddWithValue("@Priority", orderToBeUpdated.Priority);
                 cmd.ExecuteNonQuery();
             }
             return(true);
         }
         else
         {
             MessageBox.Show("Unable to update DB");
             return(false);
         }
     }
     catch (Exception ecc)
     {
         MessageBox.Show(ecc.ToString());
         return(false);
     }
 }
Ejemplo n.º 4
0
        private void exchangeRow(int rowInit, int rowDest)
        {
            OrderDataModel temp      = Helper.productionOrderList[rowDest];
            int            tempOrder = temp.Order;

            Helper.productionOrderList[rowDest].Order         = Helper.productionOrderList[rowInit].Order;
            Helper.productionOrderList[rowInit].Order         = tempOrder;
            Helper.productionOrderList[rowDest]               = Helper.productionOrderList[rowInit];
            Helper.productionOrderList[rowDest].OrderModified = true;

            activeRow = rowDest;

            //return false;
        }
Ejemplo n.º 5
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex < dataGridView1.NewRowIndex - 1)
                {
                    switch (dataGridView1.Columns[e.ColumnIndex].Name)
                    {
                    case "idProductionOrder":
                        Helper.productionOrderList[e.RowIndex].IdProductionOrder = (string)dataGridView1.CurrentCell.Value;
                        break;

                    case "targetPieces":
                        Helper.productionOrderList[e.RowIndex].TargetPieces = (int)dataGridView1.CurrentCell.Value;
                        break;

                    case "machineRecipe":
                        Helper.productionOrderList[e.RowIndex].MachineRecipe = (string)dataGridView1.CurrentCell.Value;
                        break;

                    case "priority":
                        Helper.productionOrderList[e.RowIndex].Priority = (int)dataGridView1.CurrentCell.Value;
                        break;

                    case "timeStampInsert":
                        Helper.productionOrderList[e.RowIndex].InsertingTime = Convert.ToDateTime(dataGridView1.CurrentCell.Value);
                        break;

                    case "status":
                        Helper.productionOrderList[e.RowIndex].Status = (int)dataGridView1.CurrentCell.Value;
                        break;

                    default:
                        Console.WriteLine("Default case");
                        break;
                    }
                }
                else
                {
                    OrderDataModel temp_order = new OrderDataModel();
                }
            }
            catch (Exception ecc)
            {
                MessageBox.Show(ecc.ToString());
            }
        }
Ejemplo n.º 6
0
        public static bool readOrderDB(int status, out List <OrderDataModel> tempOrderListout)
        {
            List <OrderDataModel> tempOrderList = new List <OrderDataModel>();

            try
            {
                if (Connect())
                {
                    string query = "select * from productionOrders where status=@Status;";
                    using (SqlCommand cmd = new SqlCommand(query, m_dbConnection))
                    {
                        cmd.Parameters.AddWithValue("@Status", status);
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                OrderDataModel item = new OrderDataModel((string)reader["idProductionOrder"], (string)reader["machineRecipe"], (int)reader["targetPieces"], (int)reader["priority"], (int)reader["status"], (System.DateTime)reader["timestampInsert"], (int)reader["orderNum"], (bool)reader["orderModified"]);
                                tempOrderList.Add(item);
                            }
                        }
                    }
                    tempOrderListout = tempOrderList;
                    return(true);
                }
                else
                {
                    MessageBox.Show("Unable to read DB");
                    tempOrderListout = tempOrderList;
                    return(false);
                }
            }
            catch (Exception ecc)
            {
                MessageBox.Show("Error during OrderGuiData: " + ecc.ToString());
                tempOrderListout = tempOrderList;
                return(false);
            }
        }