예제 #1
0
        public void UpdateConsignor_Verify()
        {
            // SETUP
            Consignor c = new Consignor();
            ConsignorUtilitiesTesting cu = new ConsignorUtilitiesTesting();
            c.Address1City = ConsignorCity;
            c.Address1State = ConsignorState;
            c.Address1Street = ConsignorStreet;
            c.Address1Zip = ConsignorZip;
            c.CellPhone = ConsignorCellPhone;
            c.Comments = ConsignorComments;
            c.CreateBy = ConsignorCreateBy;
            c.Donate = ConsignorDonate;
            c.EmailAddress = ConsignorEmail;
            c.FirstName = ConsignorNameFirst;
            c.HomePhone = ConsignorHomePhone;
            c.LastName = ConsignorNameLast;
            c.WorkPhone = ConsignorWorkPhone;

            // TRIGGER
            bool result = cu.Consignor_Update(c);

            // VALIDATE
            Assert.IsTrue(result);
        }
예제 #2
0
        public void UpdateConsignor()
        {
            // SETUP
            ConsignorClasses.Consignor c = new Consignor();
            ConsignorClasses.ConsignorUtilities u = new ConsignorUtilities();
            c.Address1City = testAddressCity;
            c.Address1State = testAddressState;
            c.Address1Street = testStreet;
            c.Address1Zip = testZip;
            c.CellPhone = testCell;
            c.Comments = testComments;
            c.ConsignorID = GetMaxConsignorID();
            c.Donate = true;
            c.EmailAddress = testEmail;
            c.FirstName = testUpdatedFirstName;
            c.HomePhone = testHomePhone;
            c.LastName = testUpdatedLastName;
            c.WorkPhone = testWorkPhone;

            // TRIGGER
            bool updateResult = u.Consignor_Update(c);
            ConsignorClasses.Consignor updated = new Consignor();
            updated = u.GetExistingConsignor(GetMaxConsignorID());

            // VALIDATE
            Assert.AreEqual(true, updateResult, "expected different result");
            Assert.AreEqual(c.LastName, updated.LastName, "expected same updated last name");
            Assert.AreEqual(c.FirstName, updated.FirstName, "expected same updated first name");
        }
예제 #3
0
        private bool ConsignorUpdate()
        {
            ConsignorClasses.Consignor c = new ConsignorClasses.Consignor();
            ConsignorClasses.ConsignorUtilities cu = new ConsignorClasses.ConsignorUtilities();

            // set the updated consignor
            c.Address1City = txtCity.Text;
            c.Address1State = txtState.Text;
            c.Address1Street = txtAddress.Text;
            c.Address1Zip = txtZipCode.Text;
            c.CellPhone = txtCellPhone.Text;
            c.Comments = txtComments.Text;
            c.ConsignorID = int.Parse(txtConsignorID.Text);
            c.Donate = ckDonate.Checked;
            c.EmailAddress = txtemail.Text;
            c.FirstName = txtFirstName.Text;
            c.HomePhone = txtHomePhone.Text;
            c.LastName = txtLastName.Text;
            c.WorkPhone = txtWorkPhone.Text;

            // update the consignor
            bool result = cu.Consignor_Update(c);
            ClearConsignor();
            return result;
        }
예제 #4
0
        public void AddConsignor()
        {
            // SETUP
            int nextConsignor = GetMaxConsignorID() + 1;
            ConsignorClasses.Consignor c = new Consignor();
            ConsignorClasses.ConsignorUtilities u = new ConsignorUtilities();
            c.Address1City = testAddressCity;
            c.Address1State = testAddressState;
            c.Address1Street = testStreet;
            c.Address1Zip = testZip;
            c.CellPhone = testCell;
            c.Comments = testComments;
            c.ConsignorID = 0;
            c.Donate = true;
            c.EmailAddress = testEmail;
            c.FirstName = testFirstName;
            c.HomePhone = testHomePhone;
            c.LastName = testLastName;
            c.WorkPhone = testWorkPhone;

            // TRIGGER
            int newConsignorID = u.AddNewConsignor(c);

            // VALIDATE
            Assert.AreEqual(nextConsignor, newConsignorID, "expected different number");
        }
 /// <summary>
 /// Navigate to the report when list box items have been selected
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmdGo_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedItems.Count != 0)
     {
         List<string> collection = ParseSelectedItems(listBox1.SelectedItems);
         string sqlParams = ConvertToSqlParam(collection);
         ConsignorClasses.ConsignorUtilities cu = new ConsignorClasses.ConsignorUtilities();
         ConsignorClasses.Consignor c = new ConsignorClasses.Consignor();
         c = cu.GetExistingConsignor(GlobalClass.ConsignerID);
         ConsignorID = c.ConsignorID;
         LoadReport(c.ConsignorID, sqlParams);
     }
 }
 /// <summary>
 /// load the active only to start
 /// </summary>
 private void LoadActiveOnly()
 {
     string sqlParams = ConvertToSqlParam(ActiveOnlyStatus);
     ConsignorClasses.ConsignorUtilities cu = new ConsignorClasses.ConsignorUtilities();
     ConsignorClasses.Consignor c = new ConsignorClasses.Consignor();
     c = cu.GetExistingConsignor(GlobalClass.ConsignerID);
     ConsignorID = c.ConsignorID;
     LoadReport(c.ConsignorID, sqlParams);
 }
        /// <summary>
        /// load up the report
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Report_ConsignorDetailReport_Load(object sender, EventArgs e)
        {
            this.soldStatus_Select1TableAdapter.Fill(this.doubletakeDataSet.SoldStatus_Select1);
            ConsignorClasses.ConsignorUtilities cu = new ConsignorClasses.ConsignorUtilities();
            ConsignorClasses.Consignor c = new ConsignorClasses.Consignor();
            c = cu.GetExistingConsignor(GlobalClass.ConsignerID);
            ConsignorID = c.ConsignorID;
            lblConsignorName.Text = string.Format("{0} {1}", c.FirstName, c.LastName);

            // check if this is coming from the right click on the search
            if (string.IsNullOrEmpty(GlobalClass.WhateverString))
            {
                listBox1.SelectedItems.Clear();
            }
            else
            {
                LoadReport(c.ConsignorID, GlobalClass.WhateverString);
            }
        }
 public override bool Consignor_Update(Consignor c)
 {
     return true;
 }
 public override int AddNewConsignor(Consignor newcon)
 {
     return 5;
 }
예제 #10
0
        /// <summary>
        /// Add a consignor to the database
        /// </summary>
        /// <param name="newconsignor"></param>
        /// <returns>New Consignor ID</returns>
        public virtual int AddNewConsignor(Consignor newconsignor)
        {
            int count;
            var d = new Decode();
            SqlConnection cn = new SqlConnection(d.ConnectionString);
            SqlCommand cmd = new SqlCommand("DTUSER.NewConsignor_Insert");
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32);
            returnValue.Direction = ParameterDirection.ReturnValue;
            cmd.Parameters.Add(returnValue);

            try
            {
                cn.Open();
                cmd.Connection = cn;
                cmd.Parameters.Add("@pLastName", SqlDbType.NVarChar).Value = newconsignor.LastName;
                cmd.Parameters.Add("@pFirstName", SqlDbType.NVarChar).Value = newconsignor.FirstName;
                cmd.Parameters.Add("@pAddress1Street", SqlDbType.NVarChar).Value = newconsignor.Address1Street;
                cmd.Parameters.Add("@pAddress1City", SqlDbType.NVarChar).Value = newconsignor.Address1City;
                cmd.Parameters.Add("@pAddress1State", SqlDbType.NVarChar).Value = newconsignor.Address1State;
                cmd.Parameters.Add("@pAddress1Zip", SqlDbType.NVarChar).Value = newconsignor.Address1Zip;
                cmd.Parameters.Add("@pHomePhone", SqlDbType.NVarChar).Value = newconsignor.HomePhone;
                cmd.Parameters.Add("@pWorkPhone", SqlDbType.NVarChar).Value = newconsignor.WorkPhone;
                cmd.Parameters.Add("@pCellPhone", SqlDbType.NVarChar).Value = newconsignor.CellPhone;
                cmd.Parameters.Add("@pEmailAddress", SqlDbType.NVarChar).Value = newconsignor.EmailAddress;
                cmd.Parameters.Add("@pComments", SqlDbType.NVarChar).Value = newconsignor.Comments;
                cmd.Parameters.Add("@pDonate", SqlDbType.Bit).Value = newconsignor.Donate;
                cmd.Parameters.Add("@pCreateBy", SqlDbType.NVarChar).Value = "NewConsignor";

                cmd.ExecuteNonQuery();
                count = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString());
            }
            catch (SqlException sx)
            {
                Console.WriteLine(sx);
                count = -1;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                count = -2;
            }
            finally
            {
                if (cn.State != ConnectionState.Closed)
                {
                    cn.Close();
                }
            }
            return count;
        }
예제 #11
0
 public Consignor GetExistingConsignor(int ConsignorID)
 {
     var returnConsignor = new Consignor();
     var d = new Decode();
     SqlConnection cn = new SqlConnection(d.ConnectionString);
     SqlCommand cmd = new SqlCommand("DTUSER.GetConsignor_Select");
     SqlDataReader dr;
     cmd.CommandType = CommandType.StoredProcedure;
     try
     {
         cn.Open();
         cmd.Connection = cn;
         cmd.Parameters.Add("@pConsignorID", SqlDbType.VarChar).Value = ConsignorID;
         dr = cmd.ExecuteReader();
         while (dr.Read())
         {
             returnConsignor.ConsignorID = ConsignorID;
             returnConsignor.LastName = dr.GetValue(0).ToString();
             returnConsignor.FirstName = dr.GetValue(1).ToString();
             returnConsignor.Address1Street = dr.GetValue(2).ToString();
             returnConsignor.Address1City = dr.GetValue(3).ToString();
             returnConsignor.Address1State = dr.GetValue(4).ToString();
             returnConsignor.Address1Zip = dr.GetValue(5).ToString();
             returnConsignor.HomePhone = dr.GetValue(6).ToString();
             returnConsignor.WorkPhone = dr.GetValue(7).ToString();
             returnConsignor.CellPhone = dr.GetValue(8).ToString();
             returnConsignor.EmailAddress = dr.GetValue(9).ToString();
             returnConsignor.Comments = dr.GetValue(10).ToString();
             returnConsignor.Donate = dr.GetBoolean(11);
         }
     }
     catch (SqlException sx)
     {
         // return an empty consingor
         var falseConsignor = new Consignor();
         returnConsignor.LastName = "SQL Exception";
         returnConsignor.Comments = sx.Message;
     }
     catch (Exception ex)
     {
         // return an empty consingor
         var falseConsignor = new Consignor();
         returnConsignor.LastName = "C# Exception";
         returnConsignor.Comments = ex.Message;
     }
     finally
     {
         if (cn.State != ConnectionState.Closed)
         {
             cn.Close();
         }
     }
     return returnConsignor;
 }
예제 #12
0
        /// <summary>
        /// Update an existing consignor based on consignor ID
        /// </summary>
        /// <param name="c"></param>
        /// <returns>Success or Failure</returns>
        public virtual bool Consignor_Update(Consignor c)
        {
            bool returnValue = false;
            var d = new Decode();
            SqlConnection cn = new SqlConnection(d.ConnectionString);
            SqlCommand cmd = new SqlCommand("DTUSER.Consignor_Update");
            cmd.CommandType = CommandType.StoredProcedure;

            try
            {
                cn.Open();
                cmd.Connection = cn;
                cmd.Parameters.Add("@pConsignorID", SqlDbType.Int).Value = c.ConsignorID;
                cmd.Parameters.Add("@pLastName", SqlDbType.NVarChar).Value = c.LastName;
                cmd.Parameters.Add("@pFirstName", SqlDbType.NVarChar).Value = c.FirstName;
                cmd.Parameters.Add("@pAddress1Street", SqlDbType.NVarChar).Value = c.Address1Street;
                cmd.Parameters.Add("@pAddress1City", SqlDbType.NVarChar).Value = c.Address1City;
                cmd.Parameters.Add("@pAddress1State", SqlDbType.NVarChar).Value = c.Address1State;
                cmd.Parameters.Add("@pAddress1Zip", SqlDbType.NVarChar).Value = c.Address1Zip;
                cmd.Parameters.Add("@pHomePhone", SqlDbType.NVarChar).Value = c.HomePhone;
                cmd.Parameters.Add("@pWorkPhone", SqlDbType.NVarChar).Value = c.WorkPhone;
                cmd.Parameters.Add("@pCellPhone", SqlDbType.NVarChar).Value = c.CellPhone;
                cmd.Parameters.Add("@pEmailAddress", SqlDbType.NVarChar).Value = c.EmailAddress;
                cmd.Parameters.Add("@pComments", SqlDbType.NVarChar).Value = c.Comments;
                cmd.Parameters.Add("@pDonate", SqlDbType.Bit).Value = c.Donate;
                cmd.ExecuteNonQuery();
                returnValue = true;
            }
            catch (SqlException sx)
            {
                Console.WriteLine(sx);
                returnValue = false;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                returnValue = false;
            }
            finally
            {
                if (cn.State != ConnectionState.Closed)
                {
                    cn.Close();
                }
            }
            return returnValue;
        }
예제 #13
0
        private void NewConsignorInsert()
        {
            int count;
            ConsignorClasses.ConsignorUtilities cu = new ConsignorClasses.ConsignorUtilities();
            ConsignorClasses.Consignor c = new ConsignorClasses.Consignor();
            c.LastName = txtLastName.Text;
            c.FirstName = txtFirstName.Text;
            c.Address1Street = txtAddress.Text;
            c.Address1City = txtCity.Text;
            c.Address1State = txtState.Text;
            c.Address1Zip = txtZipCode.Text;
            c.HomePhone = txtHomePhone.Text;
            c.WorkPhone = txtWorkPhone.Text;
            c.CellPhone = txtCellPhone.Text;
            c.EmailAddress = txtemail.Text;
            c.Comments = txtComments.Text;
            c.Donate = ckDonate.Checked;
            c.CreateBy = "NewConsignor";

            count = cu.AddNewConsignor(c);

            switch (count)
            {
                case -1:
                    MessageBox.Show("There was a SQL Data Error", Properties.Settings.Default.MessageBoxTitle,  MessageBoxButtons.OK);
                    break;
                case -2:
                    MessageBox.Show("C# Error", Properties.Settings.Default.MessageBoxTitle, MessageBoxButtons.OK);
                    break;
                default:
                    txtConsignorID.Visible = true;
                    txtConsignorID.Text = count.ToString();
                    txtConsignorID.Enabled = false;
                    ClearConsignor();
                    break;
            }
        }
예제 #14
0
        private void GetConsignor(int ConsignorID)
        {
            ConsignorClasses.ConsignorUtilities u = new ConsignorClasses.ConsignorUtilities();
            var returnedConsignor = new ConsignorClasses.Consignor();
            returnedConsignor = u.GetExistingConsignor(ConsignorID);

            // check for C# exceptions
            if (returnedConsignor.LastName.Contains("SQL Exception"))
            {
                MessageBox.Show(returnedConsignor.Comments, "SQL Data Error", MessageBoxButtons.OK);
                ClearConsignor();
            }
            else if (returnedConsignor.LastName.Contains("C# Exception"))
            {
                MessageBox.Show(returnedConsignor.Comments, "C# Error", MessageBoxButtons.OK);
                ClearConsignor();
            }
            else
            {
                txtConsignorID.Text = ConsignorID.ToString();
                txtLastName.Text = returnedConsignor.LastName;
                txtFirstName.Text = returnedConsignor.FirstName;
                txtAddress.Text = returnedConsignor.Address1Street;
                txtCity.Text = returnedConsignor.Address1City;
                txtState.Text = returnedConsignor.Address1State;
                txtZipCode.Text = returnedConsignor.Address1Zip;
                txtHomePhone.Text = returnedConsignor.HomePhone;
                txtWorkPhone.Text = returnedConsignor.WorkPhone;
                txtCellPhone.Text = returnedConsignor.CellPhone;
                txtemail.Text = returnedConsignor.EmailAddress;
                txtComments.Text = returnedConsignor.Comments;
                ckDonate.Checked = returnedConsignor.Donate;
            }
            ClearConsignor();
        }