Beispiel #1
0
        private void btnAddVendor_Click(object sender, RoutedEventArgs e)
        {
            VendorsModel model = new VendorsModel()
            {
                Address     = txtAddress.Text,
                City        = txtCity.Text,
                PhoneNumber = txtPhoneNumber.Text,
                State       = txtState.Text,
                VendorName  = txtName.Text,
                Website     = txtWebsite.Text,
                ZipCode     = txtZipCode.Text
            };

            dbConnectt.AddVendor(model);

            txtAddress.Text     = "";
            txtCity.Text        = "";
            txtPhoneNumber.Text = "";
            txtState.Text       = "";
            txtName.Text        = "";
            txtWebsite.Text     = "";
            txtZipCode.Text     = "";

            MessageBox.Show("Vendor added successfully");
        }
Beispiel #2
0
        public ActionResult Index(bool noLayout = false)
        {
            if (D2Cache == null || D2Cache.CacheExpired)
            {
                D2Cache = new VendorsModel()
                {
                    XurInTower  = XurManager.InTower(2),
                    XurSales    = XurManager.GetD2CurrentItems(),
                    XurLocation = XurManager.GetD2CurrentLocation(),

                    ExpiryTime = DateTime.Now.AddMinutes(30),
                    StartTime  = DateTime.Now
                };
            }

            if (noLayout)
            {
                return(View("PartialIndex", D2Cache));
            }
            else
            {
                ViewBag.HtmlTagOverride = @"data-redirect=""/#vendors""";
                return(View("Index", D2Cache));
            }
        }
        public void UpdateVendor(VendorsModel vendorModel)
        {
            string    connectionString = CreateDatabase();
            DataTable dt = new DataTable();

            using (SqlCeCommand comm = new SqlCeCommand())
            {
                comm.Connection  = new SqlCeConnection(connectionString);
                comm.CommandType = CommandType.Text;
                comm.CommandText = "UPDATE Vendors SET VendorName = @VendorName, Address = @Address, " +
                                   "City = @City, State = @State, ZipCode = @ZipCode, Phone = @Phone, WebSite = @Website " +
                                   "Where VendorId = @VendorId";

                comm.Parameters.AddWithValue("@VendorId", vendorModel.VendorId);
                comm.Parameters.AddWithValue("@VendorName", vendorModel.VendorName);
                comm.Parameters.AddWithValue("@Address", vendorModel.Address);
                comm.Parameters.AddWithValue("@City", vendorModel.City);
                comm.Parameters.AddWithValue("@State", vendorModel.State);
                comm.Parameters.AddWithValue("@ZipCode", vendorModel.ZipCode);
                comm.Parameters.AddWithValue("@Phone", vendorModel.PhoneNumber);
                comm.Parameters.AddWithValue("@Website", vendorModel.Website);

                comm.Connection.Open();
                comm.ExecuteNonQuery();
                comm.Connection.Close();
            }
        }
Beispiel #4
0
        private void btnEditVendor_Click(object sender, RoutedEventArgs e)
        {
            VendorsModel vendorInfo = ((FrameworkElement)sender).DataContext as VendorsModel;

            EditVendor editVendor = new EditVendor(vendorInfo.VendorId);

            editVendor.Show();
            this.Close();
        }
Beispiel #5
0
        /// <summary>
        /// Create new vendor.
        /// </summary>
        public static void SaveNewVendor(VendorsModel vendor)
        {
            var newVendor = new Vendor
            {
                Name    = vendor.Name,
                Address = vendor.Address,
                Phone   = vendor.Phone,
                Email   = vendor.Email
            };

            OimsDataContext.Add(newVendor);
            OimsDataContext.SaveChanges();
        }
Beispiel #6
0
        private void btnVendorProducst_Click(object sender, RoutedEventArgs e)
        {
            VendorsModel vendorInfo = ((FrameworkElement)sender).DataContext as VendorsModel;

            IEnumerable <VendorProductsModel> vendorProducts = dbConnect.GetVendorProducts(vendorInfo.VendorId);

            dgVendorProducts.Visibility  = Visibility.Visible;
            lblVendorProducts.Visibility = Visibility.Visible;
            btnAddProduct.Visibility     = Visibility.Visible;
            lblVendorProducts.Content    = "Vendor Products for Vendor: " + vendorInfo.VendorName;
            lblVendorID.Content          = vendorInfo.VendorId.ToString();

            dgVendorProducts.ItemsSource = vendorProducts;
        }
Beispiel #7
0
        /// <summary>
        /// Update vendor.
        /// </summary>
        public static void UpdateVendor(VendorsModel vendor)
        {
            var editVendor = GetEditableVendor(vendor.Name);

            if (editVendor == null)
            {
                return;
            }

            editVendor.Address = vendor.Address;
            editVendor.Email   = vendor.Email;
            editVendor.Phone   = vendor.Phone;

            OimsDataContext.SaveChanges();
        }
Beispiel #8
0
        public EditVendor(int vendorId)
        {
            InitializeComponent();

            VendorsModel vendor = dbConnect.GetVendorById(vendorId);

            txtAddress.Text     = vendor.Address;
            txtCity.Text        = vendor.City;
            txtName.Text        = vendor.VendorName;
            txtPhoneNumber.Text = vendor.PhoneNumber;
            txtState.Text       = vendor.State;
            txtVendorId.Text    = vendor.VendorId.ToString();
            txtWebsite.Text     = vendor.Website;
            txtZipCode.Text     = vendor.ZipCode;
        }
Beispiel #9
0
        private void btnUpdateVendor_Click(object sender, RoutedEventArgs e)
        {
            VendorsModel model = new VendorsModel()
            {
                Address     = txtAddress.Text,
                City        = txtCity.Text,
                PhoneNumber = txtPhoneNumber.Text,
                State       = txtState.Text,
                VendorId    = Convert.ToInt32(txtVendorId.Text),
                VendorName  = txtName.Text,
                Website     = txtWebsite.Text,
                ZipCode     = txtZipCode.Text
            };

            dbConnect.UpdateVendor(model);

            MessageBox.Show("Vendor Updated Successfully");
        }
Beispiel #10
0
        /// <summary>
        /// Check if vendor name is unique.
        /// </summary>
        /// <param name="model">VendorsModel object.</param>
        /// <param name="action">Action enum.</param>
        /// <returns></returns>
        public static bool IsUniqueVendor(VendorsModel model, Action action)
        {
            var unique = false;

            switch (action)
            {
            case Action.New:
                var vendor = Vendors.FirstOrDefault(v => v.Name.Equals(model.Name));
                unique = vendor == null;
                break;

            case Action.Update:
                var nameRecord = Vendors.FirstOrDefault(v => v.Name.ToLower().Equals(model.Email.ToLower()));
                unique = nameRecord == null || nameRecord.Name.Equals(model.Name);
                break;
            }

            return(unique);
        }
Beispiel #11
0
        /// <summary>
        ///     Update row of grid.
        /// </summary>
        public ActionResult UpdateGridForVendors([ModelBinder(typeof(DevExpressEditorsBinder))] VendorsModel model)
        {
            try
            {
                if (VendorRepository.IsUniqueVendor(model, Action.Update))
                {
                    VendorRepository.UpdateVendor(model);
                }
                else
                {
                    TempData["ErrorMessage"] = Supervisor.VErrorMsgVendorExist;
                }
            }
            catch (Exception exc)
            {
                TempData["ErrorMessage"] = exc.Message;

                Logger.LogError(exc, "Error while updating vendors from Supervisor zone");
            }

            return(PartialView("Grid/_GridForVendors", VendorRepository.Vendors));
        }
        public void AddVendor(VendorsModel vendorModel)
        {
            string    connectionString = CreateDatabase();
            DataTable dt = new DataTable();

            using (SqlCeCommand comm = new SqlCeCommand())
            {
                comm.Connection  = new SqlCeConnection(connectionString);
                comm.CommandType = CommandType.Text;
                comm.CommandText = "insert into Vendors (VendorName, Address, City, State, ZipCode, Phone, Website) values (@VendorName, @Address, @City, @State, @ZipCode, @Phone, @WebSite)";

                comm.Parameters.AddWithValue("@VendorName", vendorModel.VendorName);
                comm.Parameters.AddWithValue("@Address", vendorModel.Address);
                comm.Parameters.AddWithValue("@City", vendorModel.City);
                comm.Parameters.AddWithValue("@State", vendorModel.State);
                comm.Parameters.AddWithValue("@ZipCode", vendorModel.ZipCode);
                comm.Parameters.AddWithValue("@Phone", vendorModel.PhoneNumber);
                comm.Parameters.AddWithValue("@Website", vendorModel.Website);

                comm.Connection.Open();
                comm.ExecuteNonQuery();
                comm.Connection.Close();
            }
        }
Beispiel #13
0
        public ActionResult VendorPost(VendorsModel model)
        {
            try
            {
                if (VendorRepository.IsUniqueVendor(model, Action.New))
                {
                    VendorRepository.SaveNewVendor(model);

                    TempData["ConfirmMessage"] = string.Format(Common.ConfirmDiv,
                                                               string.Format(Supervisor.VMsgVendorCreated, model.Name));
                }
                else
                {
                    TempData["ErrorMessage"] = string.Format(Common.ErrorDiv, Supervisor.VErrorMsgVendorExist);
                }
            }
            catch (Exception exc)
            {
                TempData["ErrorMessage"] = string.Format(Common.ErrorDiv, exc.Message);
                Logger.LogError(exc, "Error while saving new vendor from Supervisor zone");
            }

            return(PartialView("_Result"));
        }
Beispiel #14
0
        public ActionResult ItemsLog()
        {
            var model = new VendorsModel();

            return(PartialView("_ItemsLog", model));
        }