Exemple #1
0
        protected void btnAddMonitor_Click(object sender, EventArgs e)
        {
            if (btnAddMonitor.Text == "Add Monitor")
            {
                Monitor mon = new Monitor();
                mon.Brand = txtBoxBrand.Text;
                mon.Connectors = txtBoxConnectors.Text;
                mon.DisplayText = txtBoxDisplayText.Text;
                mon.Model = txtBoxModel.Text;
                mon.Resolution = txtBoxResolution.Text;
                mon.Size = txtBoxResolution.Text;

                lblMessage.Text = Monitor.saveMonitor(mon);

                refresh();

            }
            else if (btnAddMonitor.Text == "Update Monitor")
            {
                Monitor mon = new Monitor();
                mon = (Monitor)Session["SelectedMonitor"];
                mon.Brand = txtBoxBrand.Text;
                mon.Connectors = txtBoxConnectors.Text;
                mon.DisplayText = txtBoxDisplayText.Text;
                mon.Model = txtBoxModel.Text;
                mon.Resolution = txtBoxResolution.Text;
                mon.Size = txtBoxResolution.Text;
                lblMessage.Text = Monitor.updateMonitor(mon);

                btnAddMonitor.Text = "Add Monitor";
                btnCancel.Visible = false;

                refresh();

                txtBoxSize.Text = "";
                txtBoxBrand.Text = "";
                txtBoxModel.Text = "";
                txtBoxResolution.Text = "";
                txtBoxConnectors.Text = "";
                txtBoxDisplayText.Text = "";

                lstBoxMonitor.SelectedIndex = 0;
            }
        }
Exemple #2
0
        public static string updateMonitor(Monitor mon)
        {
            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
            {
                string sql = "UPDATE Monitor SET Size = @Size, Brand = @Brand, Resolution = @Resolution, Connectors = @Connectors, Model = @Model, " +
                    " Display = @Display WHERE MonID= @MonID";

                dbCmd.CommandText = sql;

                dbCmd.Parameters.AddWithValue("Size", mon.Size);
                dbCmd.Parameters.AddWithValue("Brand", mon.Brand);
                dbCmd.Parameters.AddWithValue("Resolution", mon.Resolution);
                dbCmd.Parameters.AddWithValue("Connectors", mon.Connectors);
                dbCmd.Parameters.AddWithValue("Model", mon.Model);
                dbCmd.Parameters.AddWithValue("Display", mon.DisplayText);
                dbCmd.Parameters.AddWithValue("MonID", mon.ID);

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

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

                message.Append("Monitor updated successfully!");
                return message.ToString();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                transaction.Rollback();
                message.Append(ex.ToString());
                return message.ToString();
            }
        }
Exemple #3
0
        public static string saveMonitor(Monitor mon)
        {
            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
            {
                String sqlCommand = "INSERT INTO Monitor (Size, Brand, Resolution, Connectors, Model, Display) " +
                    "VALUES (@Size, @Brand, @Resolution, @Connectors, @Model, @Display)";

                dbCmd.CommandText = sqlCommand;

                dbCmd.Parameters.AddWithValue("Size", mon.Size);
                dbCmd.Parameters.AddWithValue("Brand", mon.Brand);
                dbCmd.Parameters.AddWithValue("Resolution", mon.Resolution);
                dbCmd.Parameters.AddWithValue("Connectors", mon.Connectors);
                dbCmd.Parameters.AddWithValue("Model", mon.Model);
                dbCmd.Parameters.AddWithValue("Display", mon.DisplayText);

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

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                message.Append(ex.ToString());
                transaction.Rollback();
            }
            return message.ToString();
        }
Exemple #4
0
        public static List<Monitor> getMonitors()
        {
            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; ;

            string sql = "SELECT MonID, Size, Brand, Resolution, Connectors, Model FROM Monitor";

            dbCmd.CommandText = sql;

            dbReader = dbCmd.ExecuteReader();

            List<Monitor> monitorList = new List<Monitor>();

            while (dbReader.Read())
            {
                Monitor mon = new Monitor();
                mon.ID = Convert.ToInt32(dbReader["MonID"]);
                mon.Size = dbReader["Size"].ToString();
                mon.Brand = dbReader["Brand"].ToString();
                mon.Resolution = dbReader["Resolution"].ToString();
                mon.Connectors = dbReader["Connectors"].ToString();
                mon.Model = dbReader["Model"].ToString();
                monitorList.Add(mon);
            }
            dbReader.Close();
            dbCmd.Parameters.Clear();

            return monitorList;
        }
Exemple #5
0
        public static Monitor getMonitor(int monID)
        {
            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 MonID, Size, Brand, Resolution, Connectors, Model, Display FROM Monitor WHERE MonID = @MonID";

                dbCmd.CommandText = sql;

                dbCmd.Parameters.AddWithValue("MonID", monID);

                dbReader = dbCmd.ExecuteReader();

                Monitor mon = new Monitor();

                while (dbReader.Read())
                {
                    mon.ID = Convert.ToInt32(dbReader["MonID"]);
                    mon.Size = dbReader["Size"].ToString();
                    mon.Brand = dbReader["Brand"].ToString();
                    mon.Resolution = dbReader["Resolution"].ToString();
                    mon.Connectors = dbReader["Connectors"].ToString();
                    mon.Model = dbReader["Model"].ToString();
                    mon.DisplayText = dbReader["Display"].ToString();
                }
                dbReader.Close();
                dbCmd.Parameters.Clear();
                transaction.Commit();
                dbConn.Close();

                return mon;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                transaction.Rollback();
                return null;
            }
        }
Exemple #6
0
        public static List<Monitor> getMonitor(SqlCommand cmd, int compID)
        {
            SqlDataReader dbReader;
            string sql = "SELECT Monitor.MonID, Size, Brand, Resolution, Connectors, Model, Display FROM MonitorComputer, Monitor WHERE MonitorComputer.MonID = Monitor.MonID AND MonitorComputer.CompID = @CompID";

            cmd.CommandText = sql;

            cmd.Parameters.AddWithValue("CompID", compID);

            dbReader = cmd.ExecuteReader();

            List<Monitor> monitors = new List<Monitor>();
            while (dbReader.Read())
            {
                Monitor mon = new Monitor();
                mon.ID = Convert.ToInt32(dbReader["MonID"]);
                mon.Size = dbReader["Size"].ToString();
                mon.Brand = dbReader["Brand"].ToString();
                mon.Resolution = dbReader["Resolution"].ToString();
                mon.Connectors = dbReader["Connectors"].ToString();
                mon.Model = dbReader["Model"].ToString();
                mon.DisplayText = dbReader["Display"].ToString();
                monitors.Add(mon);
            }
            dbReader.Close();
            cmd.Parameters.Clear();

            return monitors;
        }
Exemple #7
0
        public static string saveComputers(List<Computer> computers)
        {
            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 < computers.Count; i++)
                {
                    Computer comp = (Computer)computers[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", 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("PhysicalAddress", comp.PhysicalAddress);

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

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

                    //Insert Into Computer Table
                    sqlCommand = "INSERT INTO Computer (InvID, CPU, VideoCard, HardDrive, Memory, OpticalDrive, RemovableMedia, USBPorts, OtherConnectivity, FormFactor, Type) " +
                        "VALUES (@InvID, @CPU, @VideoCard, @HardDrive, @Memory, @OpticalDrive, @RemovableMedia, @USBPorts, @OtherConnectivity, @FormFactor, @Type)";

                    dbCmd.CommandText = sqlCommand;

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

                    comp.CompID = ComputerDA.getCompID(dbCmd, comp.InvID);

                    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", comp.InvID);
                    dbCmd.Parameters.AddWithValue("Building", comp.CurrentLocation.Building);
                    dbCmd.Parameters.AddWithValue("Room", comp.CurrentLocation.Room);
                    dbCmd.Parameters.AddWithValue("PrimaryUser", comp.CurrentLocation.PrimaryUser);
                    dbCmd.Parameters.AddWithValue("Name", comp.CurrentLocation.Name);
                    dbCmd.Parameters.AddWithValue("StartDate", DateTime.Now.ToShortDateString());
                    dbCmd.Parameters.AddWithValue("Status", "Active");
                    dbCmd.ExecuteNonQuery();
                    dbCmd.Parameters.Clear();

                    for (int j = 0; j < comp.Monitors.Count; j++)
                    {
                        sqlCommand = "INSERT INTO MonitorComputer (MonID, CompID) VALUES (@MonID, @CompID)";
                        dbCmd.CommandText = sqlCommand;

                        Monitor mon = new Monitor();
                        mon = (Monitor)comp.Monitors[j];

                        dbCmd.Parameters.AddWithValue("MonID", mon.ID);
                        dbCmd.Parameters.AddWithValue("CompID", comp.CompID);

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

                    }

                    PODA.addLink(dbCmd, comp.InvID, comp.PO.ID);
                    GroupDA.updateGroups(dbCmd, comp.Groups, comp.InvID);

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

                    for (int j = 0; j < comp.Warranties.Count; j++)
                    {
                        WarrantyDA.addWarranty(dbCmd, comp.InvID, (Warranty)comp.Warranties[j]);
                    }
                }
                transaction.Commit();
                dbConn.Close();
                message.Append("Operation successfull!<bR>");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                message.Append("Database Error: " + ex.ToString() + "<bR>");
                transaction.Rollback();
            }

            return message.ToString();
        }
Exemple #8
0
 public static string updateMonitor(Monitor mon)
 {
     return MonitorDA.updateMonitor(mon);
 }
Exemple #9
0
 public static string saveMonitor(Monitor mon)
 {
     return MonitorDA.saveMonitor(mon);
 }
Exemple #10
0
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                Monitor mon = new Monitor();
                mon = Monitor.getMonitor(Convert.ToInt32(lstBoxMonitor.SelectedValue));
                mon.ID = Convert.ToInt32(lstBoxMonitor.SelectedValue);
                txtBoxSize.Text = mon.Size;
                txtBoxBrand.Text = mon.Brand;
                txtBoxModel.Text = mon.Model;
                txtBoxResolution.Text = mon.Resolution;
                txtBoxConnectors.Text = mon.Connectors;
                txtBoxDisplayText.Text = mon.DisplayText;

                Session["SelectedMonitor"] = mon;

                btnAddMonitor.Text = "Update Monitor";
                btnCancel.Visible = true;
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Exemple #11
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();
        }
Exemple #12
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();
        }