Example #1
0
        public static void addLogistics(SqlCommand cmd, Equipment equip)
        {
            String sqlCommand = "INSERT INTO Logistics (InvID, Building, Room, PrimaryUser, Name, StartDate, Status) " +
                            "VALUES (@InvID, @Building, @Room, @PrimaryUser, @Name, @StartDate, @Status)";

            cmd.CommandText = sqlCommand;

            cmd.Parameters.AddWithValue("InvID", equip.InvID);
            cmd.Parameters.AddWithValue("Building", equip.CurrentLocation.Building);
            cmd.Parameters.AddWithValue("Room", equip.CurrentLocation.Room);
            cmd.Parameters.AddWithValue("PrimaryUser", equip.CurrentLocation.PrimaryUser);
            cmd.Parameters.AddWithValue("Name", equip.CurrentLocation.Name);
            cmd.Parameters.AddWithValue("StartDate", DateTime.Now.ToShortDateString());
            cmd.Parameters.AddWithValue("Status", "Active");

            cmd.ExecuteNonQuery();
            cmd.Parameters.Clear();
        }
Example #2
0
        public static Boolean equipmentExist(string serialNo)
        {
            SqlConnection dbConn;
            SqlCommand dbCmd;
            SqlDataReader dbReader;
            string sConnection;
            string sql;

            sConnection = GlobalVars.ConnectionString;
            dbConn = new SqlConnection(sConnection);
            dbConn.Open();

            sql = "SELECT SerialNo FROM Inventory, Equipment Where Inventory.InvID = Equipment.InvID AND SerialNo = @SerialNo";

            dbCmd = new SqlCommand();
            dbCmd.CommandText = sql;
            dbCmd.Parameters.AddWithValue("@SerialNo", serialNo);
            dbCmd.Connection = dbConn;

            dbReader = dbCmd.ExecuteReader();
            List<Equipment> equipment = new List<Equipment>();

            while (dbReader.Read())
            {
                Equipment equip = new Equipment();
                equip.SerialNo = dbReader["SerialNo"].ToString();
                equipment.Add(equip);
            }
            dbReader.Close();
            dbCmd.Parameters.Clear();

            if (equipment.Count > 0)
                return true;
            else
                return false;
        }
Example #3
0
 public static string updateEquipment(Equipment oEquip, Equipment equip)
 {
     return EquipmentDA.updateEquipment(oEquip, equip);
 }
Example #4
0
        protected void btnUpdateEquipment_Click(object sender, EventArgs e)
        {
            List<Equipment> equipment = new List<Equipment>();

            for (int i = 0; i < lstBoxSerialNos.Items.Count  ; i++)
            {
                Equipment equip = new Equipment();
                equip.InvID = Convert.ToInt32(lstBoxSerialNos.Items[i].Value);
                equip.SerialNo = lstBoxSerialNos.Items[i].Text;
                equip.SMSUtag = txtBoxSMSUTag.Text;
                equip.Manufacturer = ddlManufacturer.Text;
                equip.Model = txtBoxModel.Text;
                equip.EquipmentType = ddlType.Text;
                equip.Status = ddlStatus.Text;

                if (txtBoxPurchasePrice.Text != "")
                    equip.PurchasePrice = Convert.ToDouble(txtBoxPurchasePrice.Text);

                equip.Connectivity = txtBoxConnectivity.Text;
                equip.NetworkCapable = ddlNetworkCapable.Text;
                equip.Other = txtBoxOther.Text;
                equip.Notes = txtBoxNotes.Text;
                equip.PhysicalAddress = txtBoxPhysicalAddress.Text.ToUpper();

                if (ddlPONO.Visible == true)
                {
                    equip.PO.ID = Convert.ToInt32(ddlPONO.SelectedValue);
                }
                else
                {
                    equip.PO.ID = null;
                }

                equipment.Add(equip);
            }
            lblMessage.Text = Equipment.updateEquipment(equipment);
            lblMessage.Visible = true;

            btnPopUpExtender_ModalPopupExtender.Show();
        }
Example #5
0
        protected void btnSelectGroup_Click(object sender, EventArgs e)
        {
            foreach (int i in lstBoxGroups.GetSelectedIndices())
            {
                Group selectedGroup = new Group();
                selectedGroup = Group.getGroupEquipment(lstBoxGroups.Items[i].Text);

                for (int j = 0; j < selectedGroup.Equipment.Count; j++)
                {
                    Equipment equip = new Equipment();
                    equip = (Equipment)selectedGroup.Equipment[j];
                    //txtBoxServiceTags.Text += comp.SerialNo + "\r\n";

                    bool existsLB = false;
                    for (int k = 0; k < lstBoxSerialNos.Items.Count; k++)
                    {
                        if (lstBoxSerialNos.Items[k].Text == equip.SerialNo.ToUpper())
                        {
                            existsLB = true;
                        }
                    }
                    if (existsLB == false)
                    {
                        ListItem li = new ListItem(equip.SerialNo.ToUpper(), equip.InvID.ToString());
                        lstBoxSerialNos.Items.Add(li);
                        lstBoxSerialNos.SelectedValue = li.Value;
                    }
                }
            }
        }
Example #6
0
        public static string massUpdateLogisticsEquipment(List<int> ids, Logistics logs)
        {
            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;
            dbCmd.Connection = dbConn;

            for (int i = 0; i < ids.Count; i++)
            {
                int invID = ids[i];
                Equipment equip = new Equipment();
                equip = EquipmentDA.getEquipment(dbCmd, invID);

                LogisticsDA.removeLogistics(dbCmd, invID);

                try
                {
                    string sqlCommand = "INSERT INTO Logistics (InvID, Building, Room, PrimaryUser, Name, StartDate, Status) VALUES " +
                        "(@InvID, @Building, @Room, @PrimaryUser, @Name, @StartDate, @Status)";

                    dbCmd.CommandText = sqlCommand;

                    if (logs.Building == "")
                    {
                        dbCmd.Parameters.AddWithValue("Building", equip.CurrentLocation.Building);
                    }
                    else
                    {
                        dbCmd.Parameters.AddWithValue("Building", logs.Building);
                    }

                    if (logs.Room == "")
                    {
                        dbCmd.Parameters.AddWithValue("Room", equip.CurrentLocation.Room);
                    }
                    else
                    {
                        dbCmd.Parameters.AddWithValue("Room", logs.Room);
                    }

                    if (logs.PrimaryUser == "")
                    {
                        dbCmd.Parameters.AddWithValue("PrimaryUser", equip.CurrentLocation.PrimaryUser);
                    }
                    else
                    {
                        dbCmd.Parameters.AddWithValue("PrimaryUser", logs.PrimaryUser);
                    }

                    if (logs.Name == "")
                    {
                        dbCmd.Parameters.AddWithValue("Name", equip.CurrentLocation.Name);
                    }
                    else
                    {
                        dbCmd.Parameters.AddWithValue("Name", logs.Name);
                    }

                    dbCmd.Parameters.AddWithValue("InvID", invID);
                    dbCmd.Parameters.AddWithValue("StartDate", DateTime.Now.ToShortDateString());
                    dbCmd.Parameters.AddWithValue("Status", "Active");

                    dbCmd.ExecuteNonQuery();
                    dbCmd.Parameters.Clear();

                    message.Append("Logistics uppdated successfully for computer with serial number " + equip.SerialNo + "!<bR>");

                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    message.Append(ex.ToString());
                    transaction.Rollback();
                }
            }
            transaction.Commit();
            dbConn.Close();
            return message.ToString();
        }
Example #7
0
        public static string updateEquipment(List<Equipment> equipment)
        {
            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;
            dbCmd.Connection = dbConn;

            try
            {
                for (int i = 0; i < equipment.Count; i++)
                {
                    Equipment equip = new Equipment();
                    equip = (Equipment)equipment[i];

                    Equipment oEquip = EquipmentDA.getEquipment(dbCmd, equip.SerialNo);

                    StringBuilder sqlCommand = new StringBuilder();
                    sqlCommand.Append("UPDATE Inventory SET ");
                    if (equip.SMSUtag != "")
                    {
                        sqlCommand.Append("SMSUtag = @SMSUtag,");
                        dbCmd.Parameters.AddWithValue("SMSUtag", equip.SMSUtag);
                    }
                    if (equip.Manufacturer != "")
                    {
                        sqlCommand.Append("Manufacturer = @Manufacturer,");
                        dbCmd.Parameters.AddWithValue("Manufacturer", equip.Manufacturer);
                    }
                    if (equip.Model != "")
                    {
                        sqlCommand.Append("Model = @Model,");
                        dbCmd.Parameters.AddWithValue("Model", equip.Model);
                    }

                    double? price = equip.PurchasePrice;
                    if (price.HasValue)
                    {
                        sqlCommand.Append("PurchasePrice = @PurchasePrice,");
                        dbCmd.Parameters.AddWithValue("PurchasePrice", equip.PurchasePrice);
                    }
                    if (equip.Notes != "")
                    {
                        sqlCommand.Append("Notes = @Notes,");
                        dbCmd.Parameters.AddWithValue("Notes", equip.Notes);
                    }
                    if (equip.PhysicalAddress!= "")
                    {
                        sqlCommand.Append("PhysicalAddress = @PhysicalAddress,");
                        dbCmd.Parameters.AddWithValue("PhysicalAddress", equip.PhysicalAddress);
                    }
                    if (equip.Status != "")
                    {
                        if (oEquip.Status != "Transferred")
                        {
                            sqlCommand.Append("Status = @Status,");
                            dbCmd.Parameters.AddWithValue("Status", equip.Status);
                        }
                    }

                    sqlCommand.Remove((sqlCommand.Length - 1), 1);
                    sqlCommand.Append(" WHERE InvID = @InvID");
                    dbCmd.Parameters.AddWithValue("InvID", oEquip.InvID);

                    dbCmd.CommandText = sqlCommand.ToString();

                    if (dbCmd.CommandText != "UPDATE Inventory SET WHERE InvID = @InvID")
                    {
                        dbCmd.ExecuteNonQuery();
                    }

                    dbCmd.Parameters.Clear();

                    sqlCommand = new StringBuilder();
                    sqlCommand.Append("UPDATE Equipment SET ");
                    if (equip.EquipmentType != "")
                    {
                        sqlCommand.Append("EquipmentType = @EquipmentType,");
                        dbCmd.Parameters.AddWithValue("EquipmentType", equip.EquipmentType);
                    }
                    if (equip.Connectivity != "")
                    {
                        sqlCommand.Append("Connectivity = @Connectivity,");
                        dbCmd.Parameters.AddWithValue("Connectivity", equip.Connectivity);
                    }
                    if (equip.NetworkCapable != "")
                    {
                        sqlCommand.Append("NetworkCapable = @NetworkCapable,");
                        dbCmd.Parameters.AddWithValue("NetworkCapable", equip.NetworkCapable);
                    }
                    if (equip.Other != "")
                    {
                        sqlCommand.Append("Other = @Other,");
                        dbCmd.Parameters.AddWithValue("Other", equip.Other);
                    }

                    sqlCommand.Remove((sqlCommand.Length - 1), 1);
                    sqlCommand.Append(" WHERE InvID = @InvID");
                    dbCmd.Parameters.AddWithValue("InvID", oEquip.InvID);

                    dbCmd.CommandText = sqlCommand.ToString();

                    if (dbCmd.CommandText != "UPDATE Equipment SET WHERE InvID = @InvID")
                    {
                        dbCmd.ExecuteNonQuery();
                    }

                    dbCmd.Parameters.Clear();

                    if (equip.PO.ID != null)
                    {
                        PODA.deleteLink(dbCmd, oEquip.InvID);
                        PODA.addLink(dbCmd, oEquip.InvID, equip.PO.ID);
                    }

                    message.Append("Equipment with Service Tag " + equip.SerialNo + " updated successfully!<bR>");
                }
                transaction.Commit();
                dbConn.Close();

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                message.Clear();
                message.Append(ex.ToString() + "<bR>");
                transaction.Rollback();
            }
            return message.ToString();
        }
Example #8
0
        public static string updateEquipment(Equipment oEquip, Equipment equip)
        {
            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;
            dbCmd.Connection = dbConn;

            if (oEquip.SerialNo.ToUpper() != equip.SerialNo.ToUpper() && EquipmentDA.equipmentExist(dbCmd, equip.SerialNo))
            {
                message.Append("That serial number is already in use. Please try again.<bR>");
            }
            else
            {
                try
                {

                    String sqlCommand = "UPDATE Inventory SET SMSUTag = @SMSUTag, SerialNo = @SerialNo, Manufacturer = @Manufacturer, Model = @Model, PurchasePrice = @PurchasePrice, " +
                        "Notes = @Notes, Status = @Status, PhysicalAddress = @PhysicalAddress WHERE InvID = @InvID";

                    dbCmd.CommandText = sqlCommand;

                    dbCmd.Parameters.AddWithValue("SMSUTag", equip.SMSUtag);
                    dbCmd.Parameters.AddWithValue("SerialNo", equip.SerialNo);
                    dbCmd.Parameters.AddWithValue("Manufacturer", equip.Manufacturer);
                    dbCmd.Parameters.AddWithValue("Model", equip.Model);
                    dbCmd.Parameters.AddWithValue("PurchasePrice", equip.PurchasePrice);
                    dbCmd.Parameters.AddWithValue("Notes", equip.Notes);
                    dbCmd.Parameters.AddWithValue("PhysicalAddress", equip.PhysicalAddress);

                    if (oEquip.Status != "Transferred")
                    {
                        dbCmd.Parameters.AddWithValue("Status", equip.Status);
                    }
                    else
                    {
                        dbCmd.Parameters.AddWithValue("Status", oEquip.Status);
                    }

                    dbCmd.Parameters.AddWithValue("InvID", equip.InvID);

                    dbCmd.ExecuteNonQuery();
                    dbCmd.Parameters.Clear();

                    sqlCommand = "UPDATE Equipment SET EquipmentType = @EquipmentType, Connectivity = @Connectivity, NetworkCapable = @NetworkCapable, Other = @Other WHERE " +
                        "InvID = @InvID";

                    dbCmd.Parameters.AddWithValue("InvID", equip.InvID);
                    dbCmd.Parameters.AddWithValue("EquipmentType", equip.EquipmentType);
                    dbCmd.Parameters.AddWithValue("Connectivity", equip.Connectivity);
                    dbCmd.Parameters.AddWithValue("NetworkCapable", equip.NetworkCapable);
                    dbCmd.Parameters.AddWithValue("Other", equip.Other);

                    dbCmd.CommandText = sqlCommand;
                    dbCmd.ExecuteNonQuery();
                    dbCmd.Parameters.Clear();

                    if (equip.CurrentLocation.Name == oEquip.CurrentLocation.Name && equip.CurrentLocation.Building == oEquip.CurrentLocation.Building
                        && equip.CurrentLocation.Room == oEquip.CurrentLocation.Room && equip.CurrentLocation.PrimaryUser == oEquip.CurrentLocation.PrimaryUser)
                    {
                        //do nothing
                    }
                    else
                    {
                        LogisticsDA.removeLogistics(dbCmd, equip.InvID);
                        LogisticsDA.addLogistics(dbCmd, equip);
                    }

                    if (oEquip.PO.ID != equip.PO.ID)
                    {
                        PODA.deleteLink(dbCmd, equip.InvID);
                        PODA.addLink(dbCmd, equip.InvID, equip.PO.ID);
                    }

                    transaction.Commit();
                    dbConn.Close();
                    message.Append("Update Successful!<bR>");

                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    message.Append(ex.ToString());
                    transaction.Rollback();
                }
            }

            return message.ToString();
        }
Example #9
0
        public static Equipment getEquipment(int invID)
        {
            SqlConnection dbConn;
            string sConnection;
            SqlCommand dbCmd;
            SqlTransaction transaction;
            SqlDataReader dbReader;

            sConnection = GlobalVars.ConnectionString;
            dbConn = new SqlConnection(sConnection);
            dbConn.Open();
            dbCmd = dbConn.CreateCommand();
            transaction = dbConn.BeginTransaction("Transaction");
            dbCmd.Transaction = transaction;
            dbCmd.Connection = dbConn;

            try
            {
                string sql = "SELECT SMSUtag, SerialNo, Manufacturer, Model, PurchasePrice, Notes, PhysicalAddress, EquipmentType, Connectivity, "+
                    "NetworkCapable, Other, Inventory.Status, Building, Room, PrimaryUser, Name FROM Inventory, Equipment, Logistics WHERE Inventory.InvID = Equipment.InvID AND "
                + "Inventory.InvID = Logistics.InvID AND Inventory.InvID = @InvID AND Logistics.Status = @Status";

                dbCmd.CommandText = sql;

                dbCmd.Parameters.AddWithValue("InvID", invID);
                dbCmd.Parameters.AddWithValue("Status", "Active");

                dbReader = dbCmd.ExecuteReader();
                Equipment equip = new Equipment();

                while (dbReader.Read())
                {
                    equip.InvID = Convert.ToInt32(invID);
                    equip.SMSUtag = dbReader["SMSUtag"].ToString();
                    equip.SerialNo = dbReader["SerialNo"].ToString();
                    equip.Manufacturer = dbReader["Manufacturer"].ToString();
                    equip.Model = dbReader["Model"].ToString();
                    equip.PurchasePrice = Convert.ToDouble(dbReader["PurchasePrice"]);
                    equip.Notes = dbReader["Notes"].ToString();
                    equip.PhysicalAddress = dbReader["PhysicalAddress"].ToString();

                    equip.EquipmentType = dbReader["EquipmentType"].ToString();
                    equip.Connectivity = dbReader["Connectivity"].ToString();
                    equip.NetworkCapable = dbReader["NetworkCapable"].ToString();
                    equip.Other = dbReader["Other"].ToString();

                    equip.Status = dbReader["Status"].ToString();
                    equip.CurrentLocation.Building = dbReader["Building"].ToString();
                    equip.CurrentLocation.Room = dbReader["Room"].ToString();
                    equip.CurrentLocation.PrimaryUser = dbReader["PrimaryUser"].ToString();
                    equip.CurrentLocation.Name = dbReader["Name"].ToString();

                }
                dbReader.Close();
                dbCmd.Parameters.Clear();

                if (equip.Status == "Transferred")
                {
                    equip.Transfer = Transfer.getTransfer(dbCmd, invID);
                }

                equip.PO = PODA.getPODetails(dbCmd, equip.InvID);
                equip.Groups = GroupDA.getGroups(dbCmd, equip.InvID);

                dbReader.Close();

                transaction.Commit();
                dbConn.Close();

                return equip;
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                transaction.Rollback();
                dbConn.Close();
                return null;
            }
        }
Example #10
0
        public static Equipment getEquipment(SqlCommand cmd, int InvID)
        {
            SqlDataReader dbReader;

            string sql = "SELECT SMSUtag, SerialNo, Manufacturer, Model, PurchasePrice, Notes, EquipmentType, Connectivity, NetworkCapable, "+
                "Other, Inventory.Status, Building, Room, PrimaryUser, Name FROM Inventory, Equipment, Logistics WHERE Inventory.InvID = Equipment.InvID AND "
            + "Inventory.InvID = Logistics.InvID AND Inventory.InvID = @InvID AND Logistics.Status = @Status";

            cmd.CommandText = sql;

            cmd.Parameters.AddWithValue("InvID", InvID);
            cmd.Parameters.AddWithValue("Status", "Active");

            dbReader = cmd.ExecuteReader();
            Equipment equip = new Equipment();

            while (dbReader.Read())
            {
                equip.InvID = InvID;
                equip.SMSUtag = dbReader["SMSUtag"].ToString();
                equip.SerialNo = dbReader["SerialNo"].ToString();
                equip.Manufacturer = dbReader["Manufacturer"].ToString();
                equip.Model = dbReader["Model"].ToString();
                equip.PurchasePrice = Convert.ToDouble(dbReader["PurchasePrice"]);
                equip.Notes = dbReader["Notes"].ToString();

                equip.EquipmentType = dbReader["EquipmentType"].ToString();
                equip.Connectivity = dbReader["Connectivity"].ToString();
                equip.NetworkCapable = dbReader["NetworkCapable"].ToString();
                equip.Other = dbReader["Other"].ToString();

                equip.Status = dbReader["Status"].ToString();
                equip.CurrentLocation.Building = dbReader["Building"].ToString();
                equip.CurrentLocation.Room = dbReader["Room"].ToString();
                equip.CurrentLocation.PrimaryUser = dbReader["PrimaryUser"].ToString();
                equip.CurrentLocation.Name = dbReader["Name"].ToString();

            }
            dbReader.Close();
            cmd.Parameters.Clear();

            equip.PO = PODA.getPODetails(cmd, equip.InvID);
            equip.Groups = GroupDA.getGroups(cmd, equip.InvID);

            dbReader.Close();

            return equip;
        }
Example #11
0
        protected void btnAddEquipment_Click(object sender, EventArgs e)
        {
            List<Equipment> equipList = new List<Equipment>();
            List<Group> groupList = new List<Group>();
            for (int i = 0; i < chkBoxListGroups1.Items.Count; i++)
            {
                if (chkBoxListGroups1.Items[i].Selected == true)
                {
                    Group group = new Group();
                    group.ID = Convert.ToInt32(chkBoxListGroups1.Items[i].Value);
                    group.Name = chkBoxListGroups1.Items[i].Text;
                    groupList.Add(group);
                }
            }
            for (int i = 0; i < chkBoxListGroups2.Items.Count; i++)
            {
                if (chkBoxListGroups2.Items[i].Selected == true)
                {
                    Group group = new Group();
                    group.ID = Convert.ToInt32(chkBoxListGroups2.Items[i].Value);
                    group.Name = chkBoxListGroups2.Items[i].Text;
                    groupList.Add(group);
                }
            }
            for (int i = 0; i < chkBoxListGroups3.Items.Count; i++)
            {
                if (chkBoxListGroups3.Items[i].Selected == true)
                {
                    Group group = new Group();
                    group.ID = Convert.ToInt32(chkBoxListGroups3.Items[i].Value);
                    group.Name = chkBoxListGroups3.Items[i].Text;
                    groupList.Add(group);
                }
            }
            for (int i = 0; i < chkBoxListGroups4.Items.Count; i++)
            {
                if (chkBoxListGroups4.Items[i].Selected == true)
                {
                    Group group = new Group();
                    group.ID = Convert.ToInt32(chkBoxListGroups4.Items[i].Value);
                    group.Name = chkBoxListGroups4.Items[i].Text;
                    groupList.Add(group);
                }
            }

            for (int i = 0; i < lstBoxSerialNos.Items.Count; i++)
            {
                Equipment equip = new Equipment();

                equip.SerialNo = lstBoxSerialNos.Items[i].Text;
                equip.SMSUtag = txtBoxSMSUTag.Text;
                equip.EquipmentType = ddlType.Text;
                equip.Manufacturer = ddlManufacturer.Text;
                equip.Status = ddlStatus.Text;
                equip.Model = txtBoxModel.Text;
                if (txtBoxPurchasePrice.Text == "")
                {
                    equip.PurchasePrice = 0;
                }
                else
                {
                    equip.PurchasePrice = Convert.ToDouble(txtBoxPurchasePrice.Text);
                }
                equip.Connectivity = txtBoxConnectivity.Text;
                equip.Other = txtBoxOther.Text;
                equip.Notes = txtBoxNotes.Text;
                equip.CurrentLocation.Building = ddlBuilding.Text;
                equip.CurrentLocation.Room = txtBoxRoomNumber.Text;
                equip.CurrentLocation.PrimaryUser = txtBoxPrimaryUser.Text;
                equip.CurrentLocation.Name = txtBoxName.Text;
                equip.NetworkCapable = ddlNetworkCapable.Text;
                equip.PhysicalAddress = txtBoxPhysicalAddress.Text.ToUpper();

                equip.PO.ID = Convert.ToInt32(ddlPONO.SelectedValue);
                equip.Groups = groupList;

                equipList.Add(equip);

                for (int j = 0; j < lstBoxLicenses.Items.Count; j++)
                {
                    License lic = new License();
                    lic.ID = Convert.ToInt32(lstBoxLicenses.Items[j].Value);
                    equip.Licenses.Add(lic);
                }

                equip.Warranties = (List<Warranty>)Session["Warranties"];

            }

            lblMessage.Text = Equipment.saveEquipment(equipList);
            if (lblMessage.Text == "Operation successfull!<bR>")
            {
                lstBoxSerialNos.Items.Clear();
            }
            lblMessage.Visible = true;
            btnClearMessage.Visible = true;

            btnPopUpExtender_ModalPopupExtender.Show();
        }
Example #12
0
        public static Group getGroupEquipment(string groupName)
        {
            SqlConnection dbConn;
            string sConnection;
            SqlCommand dbCmd;
            SqlTransaction transaction;
            SqlDataReader dbReader;

            sConnection = GlobalVars.ConnectionString;
            dbConn = new SqlConnection(sConnection);
            dbConn.Open();
            dbCmd = dbConn.CreateCommand();
            transaction = dbConn.BeginTransaction("Transaction");
            dbCmd.Transaction = transaction;

            try
            {
                int groupID = GroupDA.getGroupID(dbCmd, groupName);

                string sql = "SELECT SerialNo, Inventory.InvID FROM Inventory, GroupInventory WHERE GroupInventory.InvID = Inventory.InvID AND GroupInventory.GroupID = @GroupID";

                dbCmd.CommandText = sql;

                dbCmd.Parameters.AddWithValue("GroupID", groupID);

                dbReader = dbCmd.ExecuteReader();

                Group group = new Group();
                while (dbReader.Read())
                {
                    Equipment equip = new Equipment();
                    equip.SerialNo = dbReader["SerialNo"].ToString();
                    equip.InvID = Convert.ToInt32(dbReader["InvID"]);
                    group.Equipment.Add(equip);
                }
                dbReader.Close();
                dbCmd.Parameters.Clear();

                transaction.Commit();
                dbConn.Close();
                return group;

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                transaction.Rollback();
                return null;
            }
        }
Example #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int invID = 0;
                string invIDstr = Request.QueryString["id"];
                try
                {
                    invID = Convert.ToInt32(invIDstr);
                    Session["CurrentEquipment"] = invID;
                }
                catch (System.FormatException ex)
                {
                    Session["Exception"] = "Input is in improper format.<bR><bR>" + ex.ToString();
                    Response.Redirect("~/Error.aspx");
                }
                catch (Exception ex)
                {
                    Session["Exception"] = ex.ToString();
                    Response.Redirect("~/Error.aspx");
                }

                Equipment equip = new Equipment();
                equip = Equipment.getEquipment(invID);

                if (equip.Status == "Transferred")
                {
                    pnlTransferInfo.Visible = true;
                    lblTransferDate.Text = equip.Transfer.Date;
                    lblTransferTo.Text = equip.Transfer.Where;
                    lblTransferNotes.Text = equip.Transfer.Notes;
                    Session["CurrentTransfer"] = equip.Transfer.ID;
                }

                txtBoxSMSUTag.Text = equip.SMSUtag;
                ddlType.Text = equip.EquipmentType;

                bool containsManufacturer = false;
                ddlManufacturer.DataBind();
                for (int i = 0; i < ddlManufacturer.Items.Count; i++)
                {
                    if (ddlManufacturer.Items[i].Text == equip.Manufacturer)
                    {
                        containsManufacturer = true;
                    }
                }
                if (containsManufacturer == false)
                {
                    ddlManufacturer.Items.Add(equip.Manufacturer);
                    ddlManufacturer.Text = equip.Manufacturer;
                }
                else
                {
                    ddlManufacturer.Text = equip.Manufacturer;
                }
                if (equip.Status != "Transferred")
                {
                    ddlStatus.Text = equip.Status;
                }
                else
                {
                    ddlStatus.Items.Add("Transferred");
                    ddlStatus.Text = "Transferred";
                    ddlStatus.Enabled = false;
                }

                txtBoxModel.Text = equip.Model;
                txtBoxSerialNo.Text = equip.SerialNo;

                ddlBuilding.DataBind();
                bool containsBuilding = false;
                for (int i = 0; i < ddlBuilding.Items.Count; i++)
                {
                    if (ddlBuilding.Items[i].Text == equip.CurrentLocation.Building)
                    {
                        containsBuilding = true;
                    }
                }
                if (containsBuilding == false)
                {
                    ddlBuilding.Items.Add(equip.CurrentLocation.Building);
                    ddlBuilding.Text = equip.CurrentLocation.Building;
                }
                else
                {
                    ddlBuilding.Text = equip.CurrentLocation.Building;
                }

                txtBoxRoomNumber.Text = equip.CurrentLocation.Room;
                txtBoxPrimaryUser.Text = equip.CurrentLocation.PrimaryUser;
                txtBoxName.Text = equip.CurrentLocation.Name;

                txtBoxPurchasePrice.Text = equip.PurchasePrice.ToString();
                ddlPONO.SelectedValue = equip.PO.ID.ToString();

                txtBoxConnectivity.Text = equip.Connectivity;
                ddlNetworkCapable.Text = equip.NetworkCapable;
                txtBoxOther.Text = equip.Other;
                txtBoxPhysicalAddress.Text = equip.PhysicalAddress;

                txtBoxNotes.Text = equip.Notes;

                txtBoxMaintDate.Text = DateTime.Now.ToShortDateString();

                List<Group> groups = new List<Group>();
                groups = Group.getAllEquipmentGroups();
                int nextGroup = 1;

                //populates chkBoxList
                for (int i = 0; i < groups.Count; i++)
                {
                    Group group = new Group();
                    group = (Group)groups[i];
                    if (nextGroup == 1)
                    {
                        chkBoxLstGroups1.Items.Add(group.Name);
                        nextGroup = 2;
                        for (int j = 0; j < equip.Groups.Count; j++)
                        {
                            Group compGroup = new Group();
                            compGroup = (Group)equip.Groups[j];
                            if (compGroup.Name == group.Name)
                            {
                                chkBoxLstGroups1.Items[chkBoxLstGroups1.Items.Count - 1].Selected = true;
                            }
                        }
                    }
                    else if (nextGroup == 2)
                    {
                        chkBoxLstGroups2.Items.Add(group.Name);
                        nextGroup = 3;
                        for (int j = 0; j < equip.Groups.Count; j++)
                        {
                            Group compGroup = new Group();
                            compGroup = (Group)equip.Groups[j];
                            if (compGroup.Name == group.Name)
                            {
                                chkBoxLstGroups2.Items[chkBoxLstGroups1.Items.Count - 1].Selected = true;
                            }
                        }
                    }
                    else if (nextGroup == 3)
                    {
                        chkBoxLstGroups3.Items.Add(group.Name);
                        nextGroup = 4;
                        for (int j = 0; j < equip.Groups.Count; j++)
                        {
                            Group compGroup = new Group();
                            compGroup = (Group)equip.Groups[j];
                            if (compGroup.Name == group.Name)
                            {
                                chkBoxLstGroups3.Items[chkBoxLstGroups1.Items.Count - 1].Selected = true;
                            }
                        }
                    }
                    else if (nextGroup == 4)
                    {
                        chkBoxLstGroups4.Items.Add(group.Name);
                        nextGroup = 1;
                        for (int j = 0; j < equip.Groups.Count; j++)
                        {
                            Group compGroup = new Group();
                            compGroup = (Group)equip.Groups[j];
                            if (compGroup.Name == group.Name)
                            {
                                chkBoxLstGroups4.Items[chkBoxLstGroups1.Items.Count - 1].Selected = true;
                            }
                        }
                    }
                    if (Session["Authenticated"].ToString() != "True")
                    {
                        panelLicenses.Visible = false;
                    }
                }

                if (equip.Status == "Transferred")
                {
                    btnEditGroups.Enabled = false;
                    btnAddLicense.Enabled = false;
                    btnRemoveSelectedLicense.Enabled = false;
                    btnAddMaintenance.Enabled = false;
                    btnAddWarranty.Enabled = false;
                    btnUpdateEquipment.Enabled = false;
                    GridView4.Enabled = false;
                }

            }
        }
Example #14
0
        protected void btnUpdateEquipment_Click(object sender, EventArgs e)
        {
            Equipment equip = new Equipment();
            Equipment oEquip = new Equipment();

            oEquip = Equipment.getEquipment(Convert.ToInt32(Session["CurrentEquipment"]));

            equip.InvID = Convert.ToInt32(Session["CurrentEquipment"]);
            equip.SMSUtag = txtBoxSMSUTag.Text;
            equip.EquipmentType = ddlType.Text;
            equip.Manufacturer = ddlManufacturer.Text;
            if (ddlStatus.Enabled == true)
            {
                equip.Status = ddlStatus.Text;
            }
            else
            {
                equip.Status = null;
            }

            equip.Model = txtBoxModel.Text;
            equip.SerialNo = txtBoxSerialNo.Text.ToUpper();

            equip.CurrentLocation.Building = ddlBuilding.Text;
            equip.CurrentLocation.Room = txtBoxRoomNumber.Text;
            equip.CurrentLocation.PrimaryUser = txtBoxPrimaryUser.Text;
            equip.CurrentLocation.Name = txtBoxName.Text;

            equip.PurchasePrice = Convert.ToDouble(txtBoxPurchasePrice.Text);
            equip.PO.ID = Convert.ToInt32(ddlPONO.SelectedValue);

            equip.Connectivity = txtBoxConnectivity.Text;
            equip.NetworkCapable = ddlNetworkCapable.Text;
            equip.Other = txtBoxOther.Text;
            equip.PhysicalAddress = txtBoxPhysicalAddress.Text.ToUpper();

            equip.Notes = txtBoxNotes.Text;

            lblMessage.Text = Equipment.updateEquipment(oEquip, equip);
            lblMessage.Visible = true;
            btnClearMessage.Visible = true;
        }
Example #15
0
        protected void btnSelectGroup_Click(object sender, EventArgs e)
        {
            List<Group> computerGroups = new List<Group>();
            computerGroups = Group.getAllComputerGroups();
            List<Group> equipmentGroups = new List<Group>();
            equipmentGroups = Group.getAllEquipmentGroups();

            foreach (int i in lstBoxGroups.GetSelectedIndices())
            {
                bool isComputerGroup = false;
                bool isEquipmentGroup = false;

                for (int j = 0; j < computerGroups.Count; j++)
                {
                    Group group = new Group();
                    group = (Group)computerGroups[j];
                    if (group.Name == lstBoxGroups.Items[i].Text)
                    {
                        isComputerGroup = true;
                    }
                }

                for (int j = 0; j < equipmentGroups.Count; j++)
                {
                    Group group = new Group();
                    group = (Group)equipmentGroups[j];
                    if (group.Name == lstBoxGroups.Items[i].Text)
                    {
                        isEquipmentGroup = true;
                    }
                }

                if (isComputerGroup == true)
                {
                    Group selectedGroup = new Group();
                    selectedGroup = Group.getGroupComputers(lstBoxGroups.Items[i].Text);

                    for (int j = 0; j < selectedGroup.Computers.Count; j++)
                    {
                        Computer comp = new Computer();
                        comp = (Computer)selectedGroup.Computers[j];
                        //txtBoxServiceTags.Text += comp.SerialNo + "\r\n";

                        bool existsLB = false;
                        for (int k = 0; k < lstBoxSerialNos.Items.Count; k++)
                        {
                            if (lstBoxSerialNos.Items[k].Text == comp.SerialNo.ToUpper())
                            {
                                existsLB = true;
                            }
                        }
                        if (existsLB == false)
                        {
                            lstBoxSerialNos.Items.Add(comp.SerialNo.ToUpper());
                            lstBoxSerialNos.Text = comp.SerialNo.ToUpper();
                        }
                    }
                }
                else if (isEquipmentGroup == true)
                {
                    Group selectedGroup = new Group();
                    selectedGroup = Group.getGroupEquipment(lstBoxGroups.Items[i].Text);

                    for (int j = 0; j < selectedGroup.Equipment.Count; j++)
                    {
                        Equipment equip = new Equipment();
                        equip = (Equipment)selectedGroup.Equipment[j];
                        //txtBoxServiceTags.Text += comp.SerialNo + "\r\n";

                        bool existsLB = false;
                        for (int k = 0; k < lstBoxSerialNos.Items.Count; k++)
                        {
                            if (lstBoxSerialNos.Items[k].Text == equip.SerialNo.ToUpper())
                            {
                                existsLB = true;
                            }
                        }
                        if (existsLB == false)
                        {
                            lstBoxSerialNos.Items.Add(equip.SerialNo.ToUpper());
                            lstBoxSerialNos.Text = equip.SerialNo.ToUpper();
                        }
                    }
                }
            }
        }