Beispiel #1
0
        public static string addMassMaintenanceComputer(List<int> ids, Maintenance maint)
        {
            SqlConnection dbConn;
            string sConnection;
            SqlCommand dbCmd;
            SqlTransaction transaction;
            StringBuilder message = new StringBuilder();

            sConnection = GlobalVars.ConnectionString;
            dbConn = new SqlConnection(sConnection);
            dbConn.Open();
            dbCmd = dbConn.CreateCommand();
            transaction = dbConn.BeginTransaction("Transaction");
            dbCmd.Transaction = transaction;
            try
            {
                for (int i = 0; i < ids.Count; i++)
                {
                    int invID = ids[i];
                    string sqlCommand = "INSERT INTO Maintenance (InvID, Date, Maintenance) " +
                        "VALUES (@InvID, @Date, @Maintenance)";

                    dbCmd.CommandText = sqlCommand;

                    dbCmd.Parameters.AddWithValue("InvID", invID);
                    dbCmd.Parameters.AddWithValue("Date", maint.Date);
                    dbCmd.Parameters.AddWithValue("Maintenance", maint.Description);

                    dbCmd.ExecuteNonQuery();
                    dbCmd.Parameters.Clear();
                }
                transaction.Commit();
                dbConn.Close();
                message.Append("Maintenance added successfully!<bR>");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                message.Append(ex.ToString() + "<bR>");
                transaction.Rollback();
            }
            return message.ToString();
        }
Beispiel #2
0
        protected void btnInsertMaintenance_Click(object sender, EventArgs e)
        {
            List<int> ids = new List<int>();
            ids = getIDs();

            List<Maintenance> newMaintenance = new List<Maintenance>();

            Maintenance maint = new Maintenance();
            maint.Date = txtboxDate.Text;
            maint.Description = txtBoxMaintenance.Text;

            lblMaintenanceMessage.Visible = true;
            lblMaintenanceMessage.Text = Maintenance.addMassMaintenanceEquipment(ids, maint);

            btnMaintenanceMessage_ModalPopupExtender.Show();
        }
Beispiel #3
0
 public static string addMassMaintenanceEquipment(List<int> ids, Maintenance maint)
 {
     return MaintenanceDA.addMassMaintenanceEquipment(ids, maint);
 }
Beispiel #4
0
 public static string addMassMaintenanceComputer(List<int> ids, Maintenance maint)
 {
     return MaintenanceDA.addMassMaintenanceComputer(ids, maint);
 }
Beispiel #5
0
 public static string addMaintenance(Maintenance maint)
 {
     return MaintenanceDA.addMaintenance(maint);
 }
Beispiel #6
0
        protected void btnInsertMaintenance_Click(object sender, EventArgs e)
        {
            Maintenance maint = new Maintenance();
            maint.InvID = Convert.ToInt32(Session["CurrentEquipment"]);
            maint.Date = txtBoxMaintDate.Text;
            maint.Description = txtBoxMaintDescription.Text;

            lblMaintenanceMessage.Text = Maintenance.addMaintenance(maint);

            if (lblMaintenanceMessage.Text == "Maintenance added successfully<bR>")
            {
                GridView2.Visible = true;
                panelAddMaintenance.Visible = false;
                btnAddMaintenance.Visible = true;
                GridView2.DataBind();
            }
        }