public Boolean DeactivateTerm(ShippingTerm shippingTerm)
 {
     if (shippingTerm == null)
     {
         throw new ArgumentException("The shipping term was null, therefore it cannot be set to inactive.");
     }
     return(ShippingTermDAL.DeactivateTerm(shippingTerm, _connection));
 }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            ShippingTerm shippingterm = await db.ShippingTerm.FindAsync(id);

            db.ShippingTerm.Remove(shippingterm);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
示例#3
0
        }//end GetShippingTermsById

        public static List <ShippingTerm> GetAllShippingTerms(SqlConnection myConnection)
        {
            var shippingTermList = new List <ShippingTerm>();

            myConnection = myConnection ?? GetInventoryDbConnection();
            try
            {
                var mySqlCommand = new SqlCommand("proc_GetAllShippingTerms", myConnection)
                {
                    CommandType = CommandType.StoredProcedure
                };

                myConnection.Open();

                var mySqlReader = mySqlCommand.ExecuteReader();
                if (mySqlReader.HasRows)
                {
                    while (mySqlReader.Read())
                    {
                        var shippingTerm = new ShippingTerm(mySqlReader.GetInt32(0))
                        {
                            ShippingVendorId   = mySqlReader.GetInt32(1),
                            Description        = mySqlReader.GetString(2),
                            ShippingVendorName = mySqlReader.GetString(3),
                            Active             = mySqlReader.GetBoolean(4)
                        };
                        //Add item to list
                        shippingTermList.Add(shippingTerm);
                    }
                }
                mySqlReader.Close();
            }
            catch (DataException ex)
            {
                Console.WriteLine(ex.Message);
                throw new ApplicationException(Messeges.GetMessage("DatabaseException"), ex);
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
                throw new ApplicationException(Messeges.GetMessage("SqlException"), ex);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw new ApplicationException(Messeges.GetMessage("Exception"), ex);
            }
            finally
            {
                myConnection.Close();
            }

            return(shippingTermList);
        }//end GetAllShippingTerms
        public async Task <ActionResult> Edit([Bind(Include = "ShippingTermID,Updated,Updator,ShippingTermName,ShippingTermDescription")] ShippingTerm shippingterm)
        {
            if (ModelState.IsValid)
            {
                db.Entry(shippingterm).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(shippingterm));
        }
示例#5
0
        }// end UpdateShippingTerms

        public static ShippingTerm GetShippingTermsById(int id, SqlConnection myConnection)
        {
            var shippingTerm = new ShippingTerm();

            myConnection = myConnection ?? GetInventoryDbConnection();
            try
            {
                var mySqlCommand = new SqlCommand("proc_GetShippingTermsByID", myConnection)
                {
                    CommandType = CommandType.StoredProcedure
                };
                mySqlCommand.Parameters.AddWithValue("@shippingTermID", id);
                myConnection.Open();

                var mySqlReader = mySqlCommand.ExecuteReader();
                if (mySqlReader.HasRows)
                {
                    while (mySqlReader.Read())
                    {
                        shippingTerm = new ShippingTerm(mySqlReader.GetInt32(0))
                        {
                            ShippingVendorId   = mySqlReader.GetInt32(1),
                            Description        = mySqlReader.GetString(2),
                            ShippingVendorName = mySqlReader.GetString(3),
                            Active             = mySqlReader.GetBoolean(10)
                        };
                    }
                }

                mySqlReader.Close();
            }
            catch (DataException ex)
            {
                Console.WriteLine(ex.Message);
                throw new ApplicationException(Messeges.GetMessage("DatabaseException"), ex);
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
                throw new ApplicationException(Messeges.GetMessage("SqlException"), ex);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw new ApplicationException(Messeges.GetMessage("Exception"), ex);
            }
            finally
            {
                myConnection.Close();
            }

            return(shippingTerm);
        }//end GetShippingTermsById
        public async Task <ActionResult> Create([Bind(Include = "ShippingTermID,Updated,Updator,ShippingTermName,ShippingTermDescription")] ShippingTerm shippingterm)
        {
            if (ModelState.IsValid)
            {
                db.ShippingTerm.Add(shippingterm);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(shippingterm));
        }
示例#7
0
        public FrmUpdateShippingTerm(ShippingTerm term, AccessToken _myAccessToken)
        {
            InitializeComponent();
            var RoleAccess = new RoleAccess(_myAccessToken, this);

            _myShippingTermManager   = new ShippingTermManager();
            _myShippingVendorManager = new ShippingVendorManager();
            vendors       = _myShippingVendorManager.GetVendors();
            _originalTerm = term;
            PopulateVendorCombo();
            txtDesc.Text = term.Description;
            this.Text    = "Shipping Term: " + term.Id;
        }//End of FrmUpdateShippingTerm(.)
        // GET: /ShippingTerm/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ShippingTerm shippingterm = await db.ShippingTerm.FindAsync(id);

            if (shippingterm == null)
            {
                return(HttpNotFound());
            }
            return(View(shippingterm));
        }
示例#9
0
        protected override void OnDeleteToolBarItem()
        {
            if (MessageBoxService.AskForDelete(_activeShippingTerm.Title) == true)
            {
                using (var dbContext = new FarnahadManufacturingDbContext())
                {
                    var shippingTerm = dbContext.ShippingTerms.Find(_activeShippingTerm.Id);
                    dbContext.ShippingTerms.Remove(shippingTerm);
                    dbContext.SaveChanges();
                }

                LoadSearchGridControl();
                _activeShippingTerm = new ShippingTerm();
                IsNotEditingAndAdding();
            }
        }
示例#10
0
        public void SetUp()
        {
            this.shippingTermId = 145;
            this.shippingTerm   = new ShippingTerm {
                Id = this.shippingTermId
            };

            this.ShippingTermFacadeService.GetById(this.shippingTermId)
            .Returns(new SuccessResult <ShippingTerm>(this.shippingTerm));

            this.Response = this.Browser.Get(
                $"/logistics/shipping-terms/{this.shippingTermId}",
                with =>
            {
                with.Header("Accept", "application/json");
            }).Result;
        }
示例#11
0
        }//End of btnUpdateTerm_Click(..)

        private void lvShippingTerms_Click_1(object sender, EventArgs e)
        {
            int          currentIndex = this.lvShippingTerms.SelectedItems[0].Index;
            ShippingTerm thisTerm     = _myTermManager.ShippingTerms[currentIndex];

            if (thisTerm.Active == true)
            {
                btnActivateTerm.Enabled   = false;
                btnDeactivateTerm.Enabled = true;
            }
            else
            {
                btnActivateTerm.Enabled   = true;
                btnDeleteTerm.Enabled     = true;
                btnDeactivateTerm.Enabled = false;
            }
            btnUpdateTerm.Enabled = true;
        }
示例#12
0
        public void SetUp()
        {
            this.shippingTerm1 = new ShippingTerm {
                Id = 1
            };
            this.shippingTerm2 = new ShippingTerm {
                Id = 2
            };

            this.ShippingTermFacadeService.GetAll().Returns(
                new SuccessResult <IEnumerable <ShippingTerm> >(
                    new List <ShippingTerm> {
                this.shippingTerm1, this.shippingTerm2
            }));

            this.Response = this.Browser.Get(
                "/logistics/shipping-terms",
                with => { with.Header("Accept", "application/json"); }).Result;
        }
示例#13
0
        public static Boolean DeleteTerm(ShippingTerm term, SqlConnection connection)
        {
            //?? Null-coalescing operator.
            //If the connection is null a new connection will be returned.
            SqlConnection conn = connection ?? GetInventoryDbConnection();

            try
            {
                //Establishes the connection.
                conn.Open();
                //Creates the command object, passing the SP and connection object.
                SqlCommand sqlCmd = new SqlCommand("proc_DeleteTerm", conn);
                sqlCmd.CommandType = CommandType.StoredProcedure;
                sqlCmd.Parameters.AddWithValue("@Id", term.Id);
                sqlCmd.Parameters.AddWithValue("@ShippingVendorId", term.ShippingVendorId);
                sqlCmd.Parameters.AddWithValue("@Active", term.Active);
                //If the procedure returns 1 set to true, if 0 remain false.
                if (sqlCmd.ExecuteNonQuery() == 1)
                {
                    return(true);
                }
            }
            catch (DataException ex)
            {
                Console.WriteLine(ex.Message);
                throw new ApplicationException(Messeges.GetMessage("DatabaseException"), ex);
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
                throw new ApplicationException(Messeges.GetMessage("SqlException"), ex);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw new ApplicationException(Messeges.GetMessage("Exception"), ex);
            }
            finally
            {
                conn.Close();
            }
            return(false);
        }
示例#14
0
        }//end AddShippingTerm

        public static bool UpdateShippingTerms(ShippingTerm shippingTerm, ShippingTerm origShippingTerm, SqlConnection myConnection)
        {
            myConnection = myConnection ?? GetInventoryDbConnection();
            try
            {
                var mySqlCommand = new SqlCommand("proc_UpdateShippingTerm", myConnection)
                {
                    CommandType = CommandType.StoredProcedure
                };
                mySqlCommand.Parameters.AddWithValue("@shippingVendorID", shippingTerm.ShippingVendorId);
                mySqlCommand.Parameters.AddWithValue("@description", shippingTerm.Description);

                mySqlCommand.Parameters.AddWithValue("@orig_ShippingTermID", origShippingTerm.Id);
                mySqlCommand.Parameters.AddWithValue("@orig_ShippingVendorID", origShippingTerm.ShippingVendorId);
                mySqlCommand.Parameters.AddWithValue("@orig_Description", origShippingTerm.Description);

                myConnection.Open();
                if (mySqlCommand.ExecuteNonQuery() == 1)
                {
                    return(true);
                }
            }
            catch (DataException ex)
            {
                Console.WriteLine(ex.Message);
                throw new ApplicationException(Messeges.GetMessage("DatabaseException"), ex);
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
                throw new ApplicationException(Messeges.GetMessage("SqlException"), ex);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw new ApplicationException(Messeges.GetMessage("Exception"), ex);
            }
            finally
            {
                myConnection.Close();
            }
            return(false);
        }// end UpdateShippingTerms
示例#15
0
        public void SetUp()
        {
            this.code         = "Q.D";
            this.shippingTerm = new ShippingTerm {
                Id = 1, Code = this.code
            };

            this.ShippingTermFacadeService.Search(this.code)
            .Returns(new SuccessResult <IEnumerable <ShippingTerm> >(new List <ShippingTerm> {
                this.shippingTerm
            }));

            this.Response = this.Browser.Get(
                $"/logistics/shipping-terms/",
                with =>
            {
                with.Header("Accept", "application/json");
                with.Query("searchTerm", this.code);
            }).Result;
        }
示例#16
0
        }//End of btnCancel_Click(..)

        private void btnEdit_Click_1(object sender, EventArgs e)
        {
            ShippingTerm term;
            bool         validShippingTerm = true;
            string       errorMessage      = "Please correct the following errors:\n";

            if (Validation.IsNullOrEmpty(txtDesc.Text) || Validation.IsBlank(txtDesc.Text))
            {
                validShippingTerm = false;
                errorMessage     += "You must enter a description.";
                txtDesc.Focus();
            }
            if (txtDesc.TextLength > 250)
            {
                validShippingTerm = false;
                errorMessage     += "The description must be 250 characters or less.";
                txtDesc.Focus();
            }
            if (validShippingTerm)
            {
                term = new ShippingTerm()
                {
                    Description      = txtDesc.Text,
                    ShippingVendorId = ((KeyValuePair <int, string>)comboVendors.SelectedItem).Key,
                    Id = _originalTerm.Id
                };
                if (_myShippingTermManager.Update(term, _originalTerm))
                {
                    this.DialogResult = DialogResult.OK;
                    MessageBox.Show("Shipping term " + _originalTerm.Id + " was updated.");
                }
                else
                {
                    MessageBox.Show("The shipping term was not updated.");
                }
            }
            else
            {
                MessageBox.Show(errorMessage);
            }
        }//End of btnEdit_Click(..)
示例#17
0
 public ActionResult CreateEdit(ShippingTerm entity)
 {
     // TODO: Add insert logic here
     using (var context = new SCMSEntities())
     {
         entity.CountryProgrammeId = countryProg.Id;
         if (entity.Id.Equals(Guid.Empty))
         {
             entity.Id = Guid.NewGuid();
             context.ShippingTerms.Add(entity);
         }
         else
         {
             entity.CountryProgrammeId = countryProg.Id;
             context.ShippingTerms.Attach(entity);
             ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(entity, System.Data.EntityState.Modified);
         }
         context.SaveChanges();
     }
     return(ListView());
 }
示例#18
0
        public Shipment CreateShipment(DateTime shipDate, string trackingNo, ShippingTerm term = null)
        {
            if (term == null)
            {
                term = ShippingTerm;
            }

            if (Shipments == null)
            {
                Shipments = new HashSet <Shipment>();
            }

            var shipment = new Shipment()
            {
                Id         = Guid.NewGuid(),
                ShipDate   = shipDate,
                TrackingNo = trackingNo,
                Weight     = 0,
                Status     = ShipmentStatus.Prepare,
            };

            Shipments.Add(shipment);
            return(shipment);
        }
        }//End of ShippingTerm sets/gets.

        public bool Insert(ShippingTerm term)
        {
            //Need to do error checking.
            return(ShippingTermDAL.AddShippingTerm(term, _connection));
        }//End of Insert(.)
示例#20
0
 private void EditData(ShippingTerm shippingTerm)
 {
     _activeShippingTerm = shippingTerm;
     FillData(_activeShippingTerm);
     IsEditing();
 }
示例#21
0
 private void FillData(ShippingTerm shippingTerm)
 {
     NameTextEdit.Text        = shippingTerm.Title;
     DescriptionTextEdit.Text = shippingTerm.Description;
 }
示例#22
0
 private void ReadData(ShippingTerm shippingTerm)
 {
     shippingTerm.Title       = NameTextEdit.Text;
     shippingTerm.Description = DescriptionTextEdit.Text;
 }
示例#23
0
 protected override void OnAddToolBarItem()
 {
     _activeShippingTerm = new ShippingTerm();
     FillData(_activeShippingTerm);
     IsAdding();
 }
        }//End of Insert(.)

        public bool Update(ShippingTerm term, ShippingTerm originalTerm)
        {
            //Need to do error checking.
            return(ShippingTermDAL.UpdateShippingTerms(term, originalTerm, _connection));
        }//End of Update(..)
示例#25
0
 public ShippingTerm CreateNew(ShippingTerm term)
 {
     term.Id = Guid.NewGuid();
     erpNodeDBContext.ShippingTerms.Add(term);
     return(term);
 }
        }//End of Update(..)

        public ShippingTerm GetTermById(int termId)
        {
            //Need to do error checking.
            ShippingTerm = ShippingTermDAL.GetShippingTermsById(termId, _connection);
            return(ShippingTerm);
        }//End of GetTermById(.)