Ejemplo n.º 1
0
        protected void btnAddDesktop_Click(object sender, EventArgs e)
        {
            List<Computer> computers = new List<Computer>();

            for (int i = 0; i < lstBoxSerialNos.Items.Count; i++)
            {
                Computer comp = new Computer();
                comp.InvID = Convert.ToInt32(lstBoxSerialNos.Items[i].Value);
                comp.SerialNo = lstBoxSerialNos.Items[i].Text;
                comp.SMSUtag = txtBoxSMSUTag.Text;
                comp.Manufacturer = ddlManufacturer.Text;
                comp.Model = txtBoxModel.Text;

                if (txtBoxPurchasePrice.Text != "")
                    comp.PurchasePrice = Convert.ToDouble(txtBoxPurchasePrice.Text);
                comp.CPU = txtBoxCPU.Text;
                comp.VideoCard = txtBoxVideoCard.Text;
                comp.HardDrive = txtBoxHardDrive.Text;
                comp.Memory = txtBoxMemory.Text;
                comp.OpticalDrive = txtBoxOpticalDrive.Text;
                comp.RemovableMedia = txtBoxRemovableMedia.Text;

                if (ddlUSBPorts.Text == "")
                {
                    comp.USBports = null;
                }
                else
                {
                    comp.USBports = Convert.ToInt32(ddlUSBPorts.SelectedValue);
                }

                comp.OtherConnectivity = txtBoxOtherConnectivity.Text;
                comp.Size = txtBoxSize.Text;
                comp.PhysicalAddress = txtBoxPhysicalAddress.Text.ToUpper();

                comp.Notes = txtBoxNotes.Text;
                comp.Type = ddlType.Text;
                comp.Status = ddlStatus.Text;

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

                computers.Add(comp);
            }

            lblMessage.Text = Computer.updateComputers(computers);
            lblMessage.Visible = true;
            btnClearMessage.Visible = true;
            btnPopUpExtender_ModalPopupExtender.Show();
        }
Ejemplo n.º 2
0
        public static void addLogistics(SqlCommand cmd, Computer comp)
        {
            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", comp.InvID);
            cmd.Parameters.AddWithValue("Building", comp.CurrentLocation.Building);
            cmd.Parameters.AddWithValue("Room", comp.CurrentLocation.Room);
            cmd.Parameters.AddWithValue("PrimaryUser", comp.CurrentLocation.PrimaryUser);
            cmd.Parameters.AddWithValue("Name", comp.CurrentLocation.Name);
            cmd.Parameters.AddWithValue("StartDate", DateTime.Now.ToShortDateString());
            cmd.Parameters.AddWithValue("Status", "Active");

            cmd.ExecuteNonQuery();
            cmd.Parameters.Clear();
        }
Ejemplo n.º 3
0
        public static Boolean computerExist(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, Computer Where Inventory.InvID = Computer.InvID AND SerialNo = @SerialNo";

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

            dbReader = dbCmd.ExecuteReader();
            List<Computer> desktops = new List<Computer>();

            while (dbReader.Read())
            {
                Computer comp = new Computer();
                comp.SerialNo = dbReader["SerialNo"].ToString();
                desktops.Add(comp);
            }
            dbReader.Close();
            dbCmd.Parameters.Clear();

            if (desktops.Count > 0)
                return true;
            else
                return false;
        }
Ejemplo n.º 4
0
        public static int? equipmentExistReturnID(string serialNo)
        {
            StringBuilder message = new StringBuilder();
            SqlConnection dbConn;
            string sConnection;
            SqlCommand dbCmd;
            SqlDataReader dbReader;

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

            try
            {
                string 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<Computer> desktops = new List<Computer>();

                while (dbReader.Read())
                {
                    Computer comp = new Computer();
                    comp.SerialNo = dbReader["SerialNo"].ToString();
                    desktops.Add(comp);
                }
                dbReader.Close();
                dbCmd.Parameters.Clear();

                if (desktops.Count > 0)
                    return EquipmentDA.getInvID(dbCmd, serialNo);
                else
                    return null;
            }

            catch (Exception ex)
            {
                ex.ToString();
                return null;
            }
        }
Ejemplo n.º 5
0
        public static Group getGroupComputers(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())
                {
                    Computer comp = new Computer();
                    comp.SerialNo = dbReader["SerialNo"].ToString();
                    comp.InvID = Convert.ToInt32(dbReader["InvID"]);
                    group.Computers.Add(comp);
                }
                dbReader.Close();
                dbCmd.Parameters.Clear();

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

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                transaction.Rollback();
                dbConn.Close();
                return null;
            }
        }
Ejemplo n.º 6
0
        public static string updateComputers(List<Computer> computers)
        {
            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 < computers.Count; i++)
                {
                    Computer comp = new Computer();
                    comp = (Computer)computers[i];

                    Computer oComp = ComputerDA.getComputer(dbCmd, comp.SerialNo);

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

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

                    sqlCommand.Remove((sqlCommand.Length - 1), 1);
                    sqlCommand.Append(" WHERE InvID = @InvID");
                    dbCmd.Parameters.AddWithValue("InvID", oComp.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 Computer SET ");
                    if (comp.CPU != "")
                    {
                        sqlCommand.Append("CPU = @CPU,");
                        dbCmd.Parameters.AddWithValue("CPU", comp.CPU);
                    }
                    if (comp.VideoCard != "")
                    {
                        sqlCommand.Append("VideoCard = @VideoCard,");
                        dbCmd.Parameters.AddWithValue("VideoCard", comp.VideoCard);
                    }
                    if (comp.HardDrive != "")
                    {
                        sqlCommand.Append("HardDrive = @HardDrive,");
                        dbCmd.Parameters.AddWithValue("HardDrive", comp.HardDrive);
                    }
                    if (comp.Memory != "")
                    {
                        sqlCommand.Append("Memory = @Memory,");
                        dbCmd.Parameters.AddWithValue("Memory", comp.Memory);
                    }
                    if (comp.OpticalDrive != "")
                    {
                        sqlCommand.Append("OpticalDrive = @OpticalDrive,");
                        dbCmd.Parameters.AddWithValue("OpticalDrive", comp.OpticalDrive);
                    }
                    if (comp.RemovableMedia != "")
                    {
                        sqlCommand.Append("RemovableMedia = @RemovableMedia,");
                        dbCmd.Parameters.AddWithValue("RemovableMedia", comp.RemovableMedia);
                    }

                    int? ports = comp.USBports;
                    if (ports.HasValue)
                    {
                        sqlCommand.Append("USBports = @USBports,");
                        dbCmd.Parameters.AddWithValue("USBports", comp.USBports);
                    }
                    if (comp.OtherConnectivity != "")
                    {
                        sqlCommand.Append("OtherConnectivity = @OtherConnectivity,");
                        dbCmd.Parameters.AddWithValue("OtherConnectivity", comp.OtherConnectivity);
                    }
                    if (comp.Size != "")
                    {
                        sqlCommand.Append("FormFactor = @FormFactor,");
                        dbCmd.Parameters.AddWithValue("FormFactor", comp.Size);
                    }
                    if (comp.Type != "")
                    {
                        sqlCommand.Append("Type = @Type,");
                        dbCmd.Parameters.AddWithValue("Type", comp.Type);
                    }

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

                    dbCmd.CommandText = sqlCommand.ToString();

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

                    dbCmd.Parameters.Clear();

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

                    message.Append("Computer with Service Tag " + comp.SerialNo + " updated successfully!<bR>");
                }
                transaction.Commit();
                dbConn.Close();
            }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    message.Append(ex.ToString() + "<bR>");
                    transaction.Rollback();
                }
            return message.ToString();
        }
Ejemplo n.º 7
0
        public static string updateComputer(Computer oComp, Computer comp)
        {
            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 (comp.SerialNo.ToUpper() != oComp.SerialNo.ToUpper() && computerExist(comp.SerialNo))
            {
                message.Append("That Service tag 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", comp.SMSUtag);
                    dbCmd.Parameters.AddWithValue("SerialNo", comp.SerialNo);
                    dbCmd.Parameters.AddWithValue("Manufacturer", comp.Manufacturer);
                    dbCmd.Parameters.AddWithValue("Model", comp.Model);
                    dbCmd.Parameters.AddWithValue("PurchasePrice", comp.PurchasePrice);
                    dbCmd.Parameters.AddWithValue("Notes", comp.Notes);
                    dbCmd.Parameters.AddWithValue("Status", comp.Status);
                    dbCmd.Parameters.AddWithValue("InvID", comp.InvID);
                    dbCmd.Parameters.AddWithValue("PhysicalAddress", comp.PhysicalAddress);

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

                    sqlCommand = "UPDATE Computer SET CPU = @CPU, VideoCard = @VideoCard, HardDrive = @HardDrive, Memory = @Memory, OpticalDrive = @OpticalDrive, " +
                        "RemovableMedia = @RemovableMedia, USBPorts = @USBPorts, OtherConnectivity = @OtherConnectivity, FormFactor = @FormFactor, Type = @Type WHERE " +
                        "InvID = @InvID";

                    dbCmd.Parameters.AddWithValue("InvID", comp.InvID);
                    dbCmd.Parameters.AddWithValue("CPU", comp.CPU);
                    dbCmd.Parameters.AddWithValue("VideoCard", comp.VideoCard);
                    dbCmd.Parameters.AddWithValue("HardDrive", comp.HardDrive);
                    dbCmd.Parameters.AddWithValue("Memory", comp.Memory);
                    dbCmd.Parameters.AddWithValue("OpticalDrive", comp.OpticalDrive);
                    dbCmd.Parameters.AddWithValue("RemovableMedia", comp.RemovableMedia);
                    dbCmd.Parameters.AddWithValue("USBPorts", comp.USBports);
                    dbCmd.Parameters.AddWithValue("OtherConnectivity", comp.OtherConnectivity);
                    dbCmd.Parameters.AddWithValue("FormFactor", comp.Size);
                    dbCmd.Parameters.AddWithValue("Type", comp.Type);

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

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

                    if (oComp.PO.ID != comp.PO.ID)
                    {
                        PODA.deleteLink(dbCmd, comp.InvID);
                        PODA.addLink(dbCmd, comp.InvID, comp.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();
        }
Ejemplo n.º 8
0
        public static Computer getComputer(SqlCommand cmd, int invID)
        {
            SqlDataReader dbReader;

            string sql = "SELECT SerialNo, CompID, SMSUTag, Manufacturer, Model, PurchasePrice, Notes, CPU, VideoCard, "+
                "HardDrive, Memory, OpticalDrive, RemovableMedia, USBPorts, OtherConnectivity, FormFactor, Type, Inventory.Status, Building, Room, PrimaryUser, Name "+
                "FROM Inventory, Computer, Logistics WHERE Inventory.InvID = Computer.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();
            Computer comp = new Computer();

            while (dbReader.Read())
            {
                comp.CompID = Convert.ToInt32(dbReader["CompID"]);
                comp.SMSUtag = dbReader["SMSUtag"].ToString();
                comp.SerialNo = dbReader["SerialNo"].ToString();
                comp.Manufacturer = dbReader["Manufacturer"].ToString();
                comp.Model = dbReader["Model"].ToString();
                comp.PurchasePrice = Convert.ToDouble(dbReader["PurchasePrice"]);
                comp.Notes = dbReader["Notes"].ToString();
                comp.CPU = dbReader["CPU"].ToString();
                comp.VideoCard = dbReader["VideoCard"].ToString();
                comp.HardDrive = dbReader["HardDrive"].ToString();
                comp.Memory = dbReader["Memory"].ToString();
                comp.OpticalDrive = dbReader["OpticalDrive"].ToString();
                comp.RemovableMedia = dbReader["RemovableMedia"].ToString();
                comp.USBports = Convert.ToInt32(dbReader["USBports"]);
                comp.OtherConnectivity = dbReader["OtherConnectivity"].ToString();
                comp.Size = dbReader["FormFactor"].ToString();
                comp.Type = dbReader["Type"].ToString();
                comp.Status = dbReader["Status"].ToString();
                comp.CurrentLocation.Building = dbReader["Building"].ToString();
                comp.CurrentLocation.Room = dbReader["Room"].ToString();
                comp.CurrentLocation.PrimaryUser = dbReader["PrimaryUser"].ToString();
                comp.CurrentLocation.Name = dbReader["Name"].ToString();

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

            comp.Monitors = MonitorDA.getMonitor(cmd, comp.CompID);
            comp.PO = PODA.getPODetails(cmd, comp.InvID);
            comp.Groups = GroupDA.getGroups(cmd, comp.InvID);

            return comp;
        }
Ejemplo n.º 9
0
        protected void btnSelectGroup_Click(object sender, EventArgs e)
        {
            foreach (int i in lstBoxGroups.GetSelectedIndices())
            {
                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)
                    {
                        ListItem li = new ListItem(comp.SerialNo.ToUpper(), comp.InvID.ToString());
                        lstBoxSerialNos.Items.Add(li);
                        lstBoxSerialNos.SelectedValue = li.Value;
                    }
                }
            }
        }
Ejemplo n.º 10
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();
                        }
                    }
                }
            }
        }
Ejemplo n.º 11
0
 public static string updateComputer(Computer oComp, Computer comp)
 {
     return ComputerDA.updateComputer(oComp, comp);
 }
Ejemplo n.º 12
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["CurrentComputer"] = 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");
                }

                Computer comp = new Computer();
                comp = Computer.getComputer(invID);

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

                if (comp.InvID == 0 || comp.InvID == null)
                {
                    Response.Redirect("~/PageNotFound.aspx");
                }

                Session["CurrentComputerID"] = comp.CompID;

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

                txtBoxServiceTag.Text = comp.SerialNo;
                txtBoxSMSUTag.Text = comp.SMSUtag;
                bool containsManufacturer = false;
                ddlManufacturer.DataBind();
                for (int i = 0; i < ddlManufacturer.Items.Count; i++)
                {
                    if (ddlManufacturer.Items[i].Text == comp.Manufacturer)
                    {
                        containsManufacturer = true;
                    }
                }
                if (containsManufacturer == false)
                {
                    ddlManufacturer.Items.Add(comp.Manufacturer);
                    ddlManufacturer.Text = comp.Manufacturer;
                }
                else
                {
                    ddlManufacturer.Text = comp.Manufacturer;
                }
                txtBoxModel.Text = comp.Model;

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

                txtBoxRoomNumber.Text = comp.CurrentLocation.Room;
                txtBoxPrimaryUser.Text = comp.CurrentLocation.PrimaryUser;
                txtBoxName.Text = comp.CurrentLocation.Name;
                txtBoxPurchasePrice.Text = comp.PurchasePrice.ToString();
                txtBoxCPU.Text = comp.CPU;
                txtBoxVideoCard.Text = comp.VideoCard;
                txtBoxHardDrive.Text = comp.HardDrive;
                txtBoxMemory.Text = comp.Memory;
                txtBoxOpticalDrive.Text = comp.OpticalDrive;
                txtBoxRemovableMedia.Text = comp.RemovableMedia;
                ddlUSBPorts.SelectedValue = comp.USBports.ToString();
                txtBoxOtherConnectivity.Text = comp.OtherConnectivity;
                txtBoxSize.Text = comp.Size;
                txtBoxPhysicalAddress.Text = comp.PhysicalAddress;
                txtBoxNotes.Text = comp.Notes;
                ddlType.Text = comp.Type;
                ddlPONO.SelectedValue = comp.PO.ID.ToString();

                if (comp.Status != "Transferred")
                {
                    ddlStatus.Text = comp.Status;
                }
                else
                {
                    ddlStatus.Items.Add("Transferred");
                    ddlStatus.Text = "Transferred";
                    ddlStatus.Enabled = false;
                }

                List<Group> groups = new List<Group>();
                groups = Group.getAllComputerGroups();
                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 < comp.Groups.Count; j++)
                        {
                            Group compGroup = new Group();
                            compGroup = (Group)comp.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 < comp.Groups.Count; j++)
                        {
                            Group compGroup = new Group();
                            compGroup = (Group)comp.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 < comp.Groups.Count; j++)
                        {
                            Group compGroup = new Group();
                            compGroup = (Group)comp.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 < comp.Groups.Count; j++)
                        {
                            Group compGroup = new Group();
                            compGroup = (Group)comp.Groups[j];
                            if (compGroup.Name == group.Name)
                            {
                                chkBoxLstGroups4.Items[chkBoxLstGroups1.Items.Count - 1].Selected = true;
                            }
                        }
                    }
                }
                if (comp.Status == "Transferred")
                {
                    btnAddMonitor.Enabled = false;
                    btnRemoveMonitor.Enabled = false;
                    btnEditGroups.Enabled = false;
                    btnAddLicense.Enabled = false;
                    btnRemoveLicense.Enabled = false;
                    btnAddMaintenance.Enabled = false;
                    btnAddWarranty.Enabled = false;
                    btnUpdateDesktop.Enabled = false;
                    gvWarranties.Enabled = false;
                }
                if (Session["Authenticated"].ToString() != "True")
                {
                    panelLicenses.Visible = false;
                }
            }
        }
Ejemplo n.º 13
0
        protected void btnUpdateDesktop_Click(object sender, EventArgs e)
        {
            int compID = Convert.ToInt32(Session["CurrentComputer"]);

            oComp = Computer.getComputer(compID);

            Computer comp = new Computer();
            comp.InvID = Convert.ToInt32(compID);
            comp.SerialNo = txtBoxServiceTag.Text.ToUpper();
            comp.SMSUtag = txtBoxSMSUTag.Text;
            comp.Manufacturer = ddlManufacturer.Text;
            comp.Model = txtBoxModel.Text;
            comp.CurrentLocation.Building = ddlBuilding.Text;
            comp.CurrentLocation.Room = txtBoxRoomNumber.Text;
            comp.CurrentLocation.PrimaryUser = txtBoxPrimaryUser.Text;
            comp.CurrentLocation.Name = txtBoxName.Text;
            comp.PurchasePrice = Convert.ToDouble(txtBoxPurchasePrice.Text);
            comp.CPU = txtBoxCPU.Text;
            comp.VideoCard = txtBoxVideoCard.Text;
            comp.HardDrive = txtBoxHardDrive.Text;
            comp.Memory = txtBoxMemory.Text;
            comp.OpticalDrive = txtBoxOpticalDrive.Text;
            comp.RemovableMedia = txtBoxRemovableMedia.Text;
            comp.USBports = Convert.ToInt32(ddlUSBPorts.SelectedValue);
            comp.OtherConnectivity = txtBoxOtherConnectivity.Text;
            comp.Size = txtBoxSize.Text;
            comp.Status = ddlStatus.Text;
            comp.Notes = txtBoxNotes.Text;
            comp.Type = ddlType.Text;
            comp.PhysicalAddress = txtBoxPhysicalAddress.Text.ToUpper();

            if (ddlStatus.Enabled == false)
            {
                comp.Status = "Transferred";
            }
            else
            {
                comp.Status = ddlStatus.Text;
            }

            comp.PO = new PurchaseOrder();
            comp.PO.ID = Convert.ToInt32(ddlPONO.SelectedValue);

            for (int i = 0; i<lstBoxMonitors.Items.Count; i++)
            {
                Monitor mon = new Monitor();
                mon.ID = Convert.ToInt32(lstBoxMonitors.Items[i].Value);
                comp.Monitors.Add(mon);
            }

            lblMessage.Text = Computer.updateComputer(oComp ,comp);
            btnClear.Visible = true;

            GridView2.DataBind();
        }
Ejemplo n.º 14
0
        public static string massUpdateLogisticsComputer(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];

                Computer comp = new Computer();
                comp = ComputerDA.getComputer(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", comp.CurrentLocation.Building);
                    }
                    else
                    {
                        dbCmd.Parameters.AddWithValue("Building", logs.Building);
                    }

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

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

                    if (logs.Name == "")
                    {
                        dbCmd.Parameters.AddWithValue("Name", comp.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 " + comp.SerialNo + "!<bR>");

                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    message.Append(ex.ToString());
                    transaction.Rollback();
                }
            }
            transaction.Commit();
            dbConn.Close();
            return message.ToString();
        }
Ejemplo n.º 15
0
        public static Computer getComputer(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 CompID, SMSUTag, SerialNo, Manufacturer, Model, PurchasePrice, Notes, PhysicalAddress, CPU, VideoCard, HardDrive, Memory, OpticalDrive, RemovableMedia, USBports,"+
                    " OtherConnectivity, FormFactor, Type, Inventory.Status, Building, Room, PrimaryUser, Name FROM Inventory, Computer, Logistics WHERE Inventory.InvID = Computer.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();
                Computer comp = new Computer();

                while (dbReader.Read())
                {
                    comp.InvID = Convert.ToInt32(invID);
                    comp.CompID = Convert.ToInt32(dbReader["CompID"]);
                    comp.SMSUtag = dbReader["SMSUtag"].ToString();
                    comp.SerialNo = dbReader["SerialNo"].ToString();
                    comp.Manufacturer = dbReader["Manufacturer"].ToString();
                    comp.Model = dbReader["Model"].ToString();
                    comp.PurchasePrice = Convert.ToDouble(dbReader["PurchasePrice"]);
                    comp.Notes = dbReader["Notes"].ToString();
                    comp.PhysicalAddress = dbReader["PhysicalAddress"].ToString();
                    comp.CPU = dbReader["CPU"].ToString();
                    comp.VideoCard = dbReader["VideoCard"].ToString();
                    comp.HardDrive = dbReader["HardDrive"].ToString();
                    comp.Memory = dbReader["Memory"].ToString();
                    comp.OpticalDrive = dbReader["OpticalDrive"].ToString();
                    comp.RemovableMedia = dbReader["RemovableMedia"].ToString();
                    comp.USBports = Convert.ToInt32(dbReader["USBports"]);
                    comp.OtherConnectivity = dbReader["OtherConnectivity"].ToString();
                    comp.Size = dbReader["FormFactor"].ToString();
                    comp.Type = dbReader["Type"].ToString();
                    comp.Status = dbReader["Status"].ToString();
                    comp.CurrentLocation.Building = dbReader["Building"].ToString();
                    comp.CurrentLocation.Room = dbReader["Room"].ToString();
                    comp.CurrentLocation.PrimaryUser = dbReader["PrimaryUser"].ToString();
                    comp.CurrentLocation.Name = dbReader["Name"].ToString();

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

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

                comp.Monitors = MonitorDA.getMonitor(dbCmd,comp.CompID);
                comp.PO = PODA.getPODetails(dbCmd, comp.InvID);
                comp.Groups = GroupDA.getGroups(dbCmd, comp.InvID);

                dbReader.Close();

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

                return comp;
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                transaction.Rollback();
                return null;
            }
        }
Ejemplo n.º 16
0
        public static string addLicensesComputer(List<int> ids, int licenseID)
        {
            SqlConnection dbConn;
            string sConnection;
            SqlCommand dbCmd;
            SqlTransaction transaction;

            sConnection = GlobalVars.ConnectionString;
            dbConn = new SqlConnection(sConnection);
            dbConn.Open();
            dbCmd = dbConn.CreateCommand();
            transaction = dbConn.BeginTransaction("Transaction");
            dbCmd.Transaction = transaction;
            dbCmd.Connection = dbConn;
            StringBuilder message = new StringBuilder();
            try
            {
                for (int i = 0; i < ids.Count; i++)
                {
                    int invID = ids[i];
                    License lic = new License();
                    Computer comp = new Computer();
                    comp = ComputerDA.getComputer(dbCmd, invID);
                    lic = LicenseDA.getLicense(dbCmd, licenseID);
                    if (LicenseDA.licenseExist(dbCmd, lic, invID) == true)
                    {
                        message.Append("Computer with Serial Number " + comp.SerialNo + " already has that license<bR>");
                    }
                    else
                    {
                        string sqlCommand = "INSERT INTO LicenseInventory (LicID, InvID) VALUES (@LicID, @InvID)";

                        dbCmd.CommandText = sqlCommand;

                        dbCmd.Parameters.AddWithValue("LicID", licenseID);
                        dbCmd.Parameters.AddWithValue("InvID", invID);

                        dbCmd.ExecuteNonQuery();
                        dbCmd.Parameters.Clear();
                    }
                }
                transaction.Commit();
                dbConn.Close();
                message.Append("License added successfully<bR>");
                return message.ToString();
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                message.Append(ex.ToString() + "<bR>");
                transaction.Rollback();
                return message.ToString();
            }
        }
Ejemplo n.º 17
0
        protected void btnAddDesktop_Click(object sender, EventArgs e)
        {
            List<Group> groupList = new List<Group>();
            List<Computer> computers = new List<Computer>();

            for(int i=0; i < chkBoxListGroups1.Items.Count; i++)
            {
                if (chkBoxListGroups1.Items[i].Selected == true)
                {
                    Group group = new Group();
                    group.Name = chkBoxListGroups1.Items[i].ToString();
                    groupList.Add(group);
                }
            }
            for (int i = 0; i < chkBoxListGroups2.Items.Count; i++)
            {
                if (chkBoxListGroups2.Items[i].Selected == true)
                {
                    Group group = new Group();
                    group.Name = chkBoxListGroups1.Items[i].ToString();
                    groupList.Add(group);
                }
            }
            for (int i = 0; i < chkBoxListGroups3.Items.Count; i++)
            {
                if (chkBoxListGroups3.Items[i].Selected == true)
                {
                    Group group = new Group();
                    group.Name = chkBoxListGroups1.Items[i].ToString();
                    groupList.Add(group);
                }
            }
            for (int i = 0; i < chkBoxListGroups4.Items.Count; i++)
            {
                if (chkBoxListGroups4.Items[i].Selected == true)
                {
                    Group group = new Group();
                    group.Name = chkBoxListGroups1.Items[i].ToString();
                    groupList.Add(group);
                }
            }

            for (int i = 0; i < lstBoxSerialNos.Items.Count; i++)
            {
                Computer comp = new Computer();
                comp.SerialNo = lstBoxSerialNos.Items[i].Text.ToUpper();
                comp.SMSUtag = txtBoxSMSUTag.Text;
                comp.Manufacturer = ddlManufacturer.Text;
                comp.Model = txtBoxModel.Text;
                comp.CurrentLocation.Building = ddlBuilding.Text;
                comp.CurrentLocation.Room = txtBoxRoomNumber.Text;
                comp.CurrentLocation.PrimaryUser = txtBoxPrimaryUser.Text;

                if (txtBoxPurchasePrice.Text == "")
                    comp.PurchasePrice = 0;
                else
                    comp.PurchasePrice = Convert.ToDouble(txtBoxPurchasePrice.Text);

                comp.CurrentLocation.Name = txtBoxName.Text;
                comp.CPU = txtBoxCPU.Text;
                comp.VideoCard = txtBoxVideoCard.Text;
                comp.HardDrive = txtBoxHardDrive.Text;
                comp.Memory = txtBoxMemory.Text;
                comp.OpticalDrive = txtBoxOpticalDrive.Text;
                comp.RemovableMedia = txtBoxRemovableMedia.Text;
                comp.USBports = Convert.ToInt32(ddlUSBports.Text);
                comp.OtherConnectivity = txtBoxOtherConnectivity.Text;
                comp.Size = txtBoxSize.Text;
                comp.Notes = txtBoxNotes.Text;
                comp.Type = ddlType.Text;
                comp.PO = PurchaseOrder.getPO(ddlPONO.SelectedValue.ToString());
                comp.Status = ddlStatus.Text;
                comp.Groups = groupList;
                comp.PhysicalAddress = txtBoxPhysicalAddress.Text.ToUpper();

                for (int j = 0; j < lstBoxMonitors.Items.Count; j++)
                {
                    Monitor mon = new Monitor();
                    mon.ID = Convert.ToInt32(lstBoxMonitors.Items[j].Value);
                    comp.Monitors.Add(mon);
                }

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

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

                computers.Add(comp);
            }

            lblMessage.Text = Computer.saveComputers(computers);
            if (lblMessage.Text == "Operation successfull!<bR>")
            {
                lstBoxSerialNos.Items.Clear();
            }
            btnClearMessage.Visible = true;

            btnPopUpExtender_ModalPopupExtender.Show();
        }