Ejemplo n.º 1
0
        protected void btnAddGroup_Click(object sender, EventArgs e)
        {
            Group group = new Group();
            group.Name = txtBoxName.Text;
            group.Notes = txtBoxNotes.Text;
            group.Type = ddlType.Text;

            lblMessage.Text = Group.saveGroup(group);
            lblMessage.Visible = true;
        }
Ejemplo n.º 2
0
        protected void btnAddGroup_Click(object sender, EventArgs e)
        {
            Group group = new Group();
            group.Name = txtBoxName.Text;
            group.Notes = txtBoxNotes.Text;
            group.Type = ddlType.Text;

            lblMessage.Text = Group.saveGroup(group);
            lblMessage.Visible = true;

            if (lblMessage.Text == "Group created successfully<bR>")
            {
                GridView1.DataBind();
                GridView2.DataBind();
                panelAddGroup.Visible = false;
                btnAddNewGroup.Visible = true;
                txtBoxName.Text = "";
                txtBoxNotes.Text = "";
            }
        }
Ejemplo n.º 3
0
        public static void updateGroups(SqlCommand cmd, List<Group> groupList, int invID)
        {
            GroupDA.removeLinks(cmd, invID);

            for (int i = 0; i < groupList.Count; i++)
            {
                Group group = new Group();
                group = (Group)groupList[i];
                int groupID = GroupDA.getGroupID(cmd, group.Name);
                GroupDA.addLink(cmd, groupID, invID);
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Session["Warranties"] = new List<Warranty>();
                List<Monitor> monList = new List<Monitor>();
                monList = Monitor.getMonitors();
                ddlType.Text = "Please Select";
                ddlPONO.SelectedValue = "28";

                List<Group> groupList = new List<Group>();
                groupList = Group.getAllComputerGroups();
                int nextGroup = 1;

                for (int i = 0; i < groupList.Count; i++)
                {
                    Group group = new Group();
                    group = (Group)groupList[i];
                    if (nextGroup == 1)
                    {
                        chkBoxListGroups1.Items.Add(group.Name);
                        nextGroup = 2;
                    }
                    else if (nextGroup == 2)
                    {
                        chkBoxListGroups2.Items.Add(group.Name);
                        nextGroup = 3;
                    }
                    else if (nextGroup == 3)
                    {
                        chkBoxListGroups3.Items.Add(group.Name);
                        nextGroup = 4;
                    }
                    else if (nextGroup == 4)
                    {
                        chkBoxListGroups4.Items.Add(group.Name);
                        nextGroup = 1;
                    }
                }
                if (Session["Authenticated"].ToString() != "True")
                {
                    panelLicenses.Visible = false;
                }

                txtBoxSerialNo.Focus();
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ddlBuilding.DataBind();
                ddlBuilding.Items.Insert(0, "");
                ddlBuilding.SelectedIndex = 0;

                ddlManufacturer.DataBind();
                ddlManufacturer.Items.Insert(0, "");
                ddlManufacturer.SelectedIndex = 0;

                List<Group> groupList = new List<Group>();
                groupList = Group.getAllEquipmentGroups();

                for (int i = 0; i < groupList.Count; i++)
                {
                    Group group = new Group();
                    group = (Group)groupList[i];
                    lstBoxGroups.Items.Add(group.Name);
                }
                if (Session["Authenticated"].ToString() != "True")
                {
                    btnManageLicensing.Enabled = false;
                }
                txtBoxSerialNo.Focus();

                populateDDLs();
            }
            else
            {
                handleGridView();
            }
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Session["Warranties"] = new List<Warranty>();

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

                int counter = 0;
                for (int i = 0; i < groups.Count; i++)
                {
                    if (counter == 0)
                    {
                        Group group = new Group();
                        group = (Group)groups[i];
                        ListItem li = new ListItem(group.Name, group.ID.ToString());
                        chkBoxListGroups1.Items.Add(li);
                        counter = 1;
                    }
                    else if (counter == 1)
                    {
                        Group group = new Group();
                        group = (Group)groups[i];
                        ListItem li = new ListItem(group.Name, group.ID.ToString());
                        chkBoxListGroups2.Items.Add(li);
                        counter = 2;
                    }
                    else if (counter == 2)
                    {
                        Group group = new Group();
                        group = (Group)groups[i];
                        ListItem li = new ListItem(group.Name, group.ID.ToString());
                        chkBoxListGroups3.Items.Add(li);
                        counter = 3;
                    }
                    else if (counter == 3)
                    {
                        Group group = new Group();
                        group = (Group)groups[i];
                        ListItem li = new ListItem(group.Name, group.ID.ToString());
                        chkBoxListGroups4.Items.Add(li);
                        counter = 0;
                    }
                }
                if (Session["Authenticated"].ToString() != "True")
                {
                    panelLicenses.Visible = false;
                }
                txtBoxSerialNo.Focus();
            }
        }
Ejemplo n.º 7
0
 public static string updateGroup(Group newGroup, int oldGroupID)
 {
     return GroupDA.updateGroup(newGroup, oldGroupID);
 }
Ejemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["CurrentGroup"] == null)
                {
                    Response.Redirect("~Groups/ManageGroups.aspx");
                }
                int groupID;
                groupID = Convert.ToInt16(Session["CurrentGroup"]);

                Group group = new Group();
                group = Group.getGroup(groupID);
                txtBoxName.Text = group.Name;
                txtBoxNotes.Text = group.Notes;

                populateDDLs();
            }
            else
            {
                handleGridView();
            }
        }
Ejemplo n.º 9
0
        public static Group getGroup(SqlCommand cmd, int groupID)
        {
            SqlDataReader dbReader;

            string sql = "SELECT GroupID, Name, Notes FROM Groups WHERE GroupID = @GroupID";

            cmd.CommandText = sql;

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

            dbReader = cmd.ExecuteReader();
            Group group = new Group();

            while (dbReader.Read())
            {
                group.ID = Convert.ToInt32(dbReader["GroupID"]);
                group.Name = dbReader["Name"].ToString();
                group.Notes = dbReader["Notes"].ToString();
            }
            dbReader.Close();
            cmd.Parameters.Clear();

            return group;
        }
Ejemplo n.º 10
0
        public static Group getGroup(int GroupID)
        {
            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
            {
                string sql = "SELECT GroupID, Name, Notes from Groups where GroupID = @GroupID";

                dbCmd.CommandText = sql;

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

                dbReader = dbCmd.ExecuteReader();
                Group group = new Group();

                while (dbReader.Read())
                {
                    group.ID = Convert.ToInt32(dbReader["GroupID"]);
                    group.Name = dbReader["Name"].ToString();
                    group.Notes = dbReader["Notes"].ToString();
                }
                dbReader.Close();
                dbCmd.Parameters.Clear();

                transaction.Commit();
                return group;
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                transaction.Rollback();
                return null;
            }
        }
Ejemplo n.º 11
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;
                }

            }
        }
Ejemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                List<Group> groupList = new List<Group>();
                groupList = Group.getAllGroups();

                for (int i = 0; i < groupList.Count; i++)
                {
                    Group group = new Group();
                    group = (Group)groupList[i];
                    lstBoxGroups.Items.Add(group.Name);
                }
                txtBoxSerialNo.Focus();

                populateComputerDDLs();
                populateEquipmentDDLs();
            }
            else
            {
                handleComputerGridView();
                handleEquipmentGridView();
            }
        }
Ejemplo n.º 13
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.º 14
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.º 15
0
        public static List<Group> getAllEquipmentGroups()
        {
            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;

            string sql = "SELECT GroupID, Name, Notes FROM Groups WHERE Type = 'Equipment'";

            dbCmd.CommandText = sql;

            dbReader = dbCmd.ExecuteReader();
            List<Group> groupList = new List<Group>();

            while (dbReader.Read())
            {
                Group group = new Group();
                group.ID = Convert.ToInt16(dbReader["GroupID"]);
                group.Name = dbReader["Name"].ToString();
                group.Notes = dbReader["Notes"].ToString();
                groupList.Add(group);
            }
            dbReader.Close();
            dbCmd.Parameters.Clear();

            return groupList;
        }
Ejemplo n.º 16
0
        protected void btnUpdateGroup_Click(object sender, EventArgs e)
        {
            Group group = new Group();
            group.Name = txtBoxName.Text;
            group.Notes = txtBoxNotes.Text;

            lblMessage.Visible = true;
            lblMessage.Text = Group.updateGroup(group, Convert.ToInt32(Session["CurrentGroup"]));

            if (lblMessage.Text == "Group updated successfully<bR>")
            {
                Panel1.Visible = false;
                DetailsView1.Visible = true;
                btnEditGroup.Visible = true;
                btnUpdateGroup.Visible = false;
                DetailsView1.DataBind();
            }
        }
Ejemplo n.º 17
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;
            }
        }
Ejemplo n.º 18
0
 public static string saveGroup(Group group)
 {
     return GroupDA.saveGroup(group);
 }
Ejemplo n.º 19
0
        public static List<Group> getGroups(SqlCommand cmd, int invID)
        {
            SqlDataReader dbReader;
            string sql;

            sql = "SELECT Name, Notes FROM GroupInventory, Groups WHERE GroupInventory.GroupID = Groups.GroupID AND InvID = @InvID";

            cmd.CommandText = sql;

            cmd.Parameters.AddWithValue("InvID", invID);

            dbReader = cmd.ExecuteReader();
            List<Group> groupList = new List<Group>();

            while (dbReader.Read())
            {
                Group group = new Group();
                group.Name = dbReader["Name"].ToString();
                group.Notes = dbReader["Notes"].ToString();
                groupList.Add(group);
            }
            dbReader.Close();
            cmd.Parameters.Clear();

            return groupList;
        }
Ejemplo n.º 20
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();
        }
Ejemplo n.º 21
0
        public static bool groupExist(string GroupName)
        {
            SqlConnection dbConn;
            string sConnection;
            SqlCommand dbCmd;
            SqlTransaction transaction;
            StringBuilder message = new StringBuilder();
            SqlDataReader dbReader;

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

            string sql = "SELECT GroupID, Notes FROM Groups WHERE Name = @Name";

            dbCmd.CommandText = sql;

            dbCmd.Parameters.AddWithValue("Name", GroupName);

            dbReader = dbCmd.ExecuteReader();

            List<Group> groupList = new List<Group>();

            while (dbReader.Read())
            {
                Group group = new Group();
                group.ID = Convert.ToInt32(dbReader["GroupID"]);
                group.Notes = dbReader["Notes"].ToString();
                groupList.Add(group);
            }
            dbReader.Close();
            dbCmd.Parameters.Clear();

            if (groupList.Count > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Ejemplo n.º 22
0
        public static string saveEquipment(List<Equipment> equipment)
        {
            StringBuilder message = new StringBuilder();

            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;
            try
            {
                for (int i = 0; i < equipment.Count; i++)
                {
                    Equipment equip = (Equipment)equipment[i];

                    //Insert Into Inventory Table
                    string sqlCommand = "INSERT INTO Inventory (SMSUTag, SerialNo, Manufacturer, Model, PurchasePrice, Notes, Status, PhysicalAddress) " +
                        "VALUES (@SMSUTag, @SerialNo, @Manufacturer, @Model, @PurchasePrice, @Notes, @Status, @PhysicalAddress)";

                    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("Status", equip.Status);
                    dbCmd.Parameters.AddWithValue("PhysicalAddress", equip.PhysicalAddress);

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

                    //Get InvID
                    equip.InvID = ComputerDA.getInvID(dbCmd, equip.SerialNo);

                    //Insert Into Computer Table
                    sqlCommand = "INSERT INTO Equipment (InvID, EquipmentType, Connectivity, NetworkCapable, Other) " +
                        "VALUES (@InvID, @EquipmentType, @Connectivity, @NetworkCapable, @Other)";

                    dbCmd.CommandText = sqlCommand;

                    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.ExecuteNonQuery();
                    dbCmd.Parameters.Clear();

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

                    dbCmd.CommandText = sqlCommand;

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

                    PODA.addLink(dbCmd, equip.InvID, equip.PO.ID);

                    for (int j = 0; j < equip.Groups.Count; j++)
                    {
                        Group grp = new Group();
                        grp = (Group)equip.Groups[j];
                        GroupDA.addLink(dbCmd, grp.ID, equip.InvID);
                    }

                    for (int j = 0; j < equip.Licenses.Count; j++)
                    {
                        License li = new License();
                        li = (License)equip.Licenses[j];
                        LicenseDA.addLicense(dbCmd, li.ID, equip.InvID);
                    }

                    for (int j = 0; j < equip.Warranties.Count; j++)
                    {
                        WarrantyDA.addWarranty(dbCmd, equip.InvID, (Warranty)equip.Warranties[j]);
                    }
                }
                transaction.Commit();
                dbConn.Close();

                message.Append("Operation successfull!<bR>");
                return message.ToString();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                message.Append("Database Error: " + ex.ToString() + "<bR>");
                transaction.Rollback();
                return message.ToString();
            }
        }
Ejemplo n.º 23
0
        public static bool groupExist(SqlCommand cmd, string groupName)
        {
            SqlDataReader dbReader;

            string sql = "SELECT GroupID, Notes FROM Groups WHERE Name = @GroupName";

            cmd.CommandText = sql;

            cmd.Parameters.AddWithValue("GroupName", groupName);

            dbReader = cmd.ExecuteReader();

            List<Group> groupList = new List<Group>();

            while (dbReader.Read())
            {
                Group group = new Group();
                group.ID = Convert.ToInt32(dbReader["GroupID"]);
                group.Notes = dbReader["Notes"].ToString();
                groupList.Add(group);
            }
            dbReader.Close();
            cmd.Parameters.Clear();

            if (groupList.Count > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Ejemplo n.º 24
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;
                    }
                }
            }
        }
Ejemplo n.º 25
0
        public static string saveGroup(Group group)
        {
            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;

            if (GroupDA.groupExist(group.Name) == false)
            {

                try
                {
                    string sqlCommand = "INSERT INTO Groups (Name, Notes, Type) " +
                        "VALUES (@GroupName, @Notes, @Type)";

                    dbCmd.CommandText = sqlCommand;

                    dbCmd.Parameters.AddWithValue("GroupName", group.Name);
                    dbCmd.Parameters.AddWithValue("Notes", group.Notes);
                    dbCmd.Parameters.AddWithValue("Type", group.Type);

                    dbCmd.ExecuteNonQuery();
                    dbCmd.Parameters.Clear();
                    transaction.Commit();
                    dbConn.Close();
                    message.Append("Group created successfully<bR>");

                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    message.Append(ex.ToString());
                    transaction.Rollback();
                }
                return message.ToString();
            }
            else
            {
                message.Append("That group name already exists, choose another.<bR>");
                return message.ToString();
            }
        }
Ejemplo n.º 26
0
        public static string updateGroup(Group newGroup, int oldGroupID)
        {
            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;

            Group oldGroup = new Group();
            oldGroup = GroupDA.getGroup(dbCmd, oldGroupID);

            if (newGroup.Name == oldGroup.Name  || GroupDA.groupExist(dbCmd, newGroup.Name) == false)
            {

                try
                {
                    string sqlCommand = "UPDATE Groups SET " +
                        "Name = @Name, " +
                        "Notes = @Notes " +
                        "WHERE Name = @OldName";

                    dbCmd.CommandText = sqlCommand;

                    dbCmd.Parameters.AddWithValue("Name", newGroup.Name);
                    dbCmd.Parameters.AddWithValue("Notes", newGroup.Notes);
                    dbCmd.Parameters.AddWithValue("OldName", oldGroup.Name);

                    dbCmd.ExecuteNonQuery();
                    dbCmd.Parameters.Clear();
                    transaction.Commit();
                    dbConn.Close();
                    message.Append("Group updated successfully<bR>");

                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    message.Append(ex.ToString());
                    transaction.Rollback();
                }
                return message.ToString();
            }
            else
            {
                message.Append("That group name already exists, choose another.<bR>");
                return message.ToString();
            }
        }
Ejemplo n.º 27
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();
        }