public ActionResult Edit(ModelProduct product, string sID)
        {
            ModelProduct cItemToEdit = cRepositoryProducts.Find(sID);

            if (cItemToEdit == null)
            {
                return(HttpNotFound());
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(cItemToEdit));
                }

                cItemToEdit.Category    = product.Category;
                cItemToEdit.Description = product.Description;
                cItemToEdit.Image       = product.Image;
                cItemToEdit.Name        = product.Name;
                cItemToEdit.Price       = product.Price;

                cRepositoryProducts.Commit();

                return(RedirectToAction("Index"));
            }
        }
        public DataTable CategoryComboList(ModelProduct modelProduct)
        {
            string        connection    = @"Server = AHO-BATIJA; DataBase = SmallBusinessManagementSystem; Integrated Security = True";
            SqlConnection sqlConnection = new SqlConnection(connection);
            string        query         = @"SELECT DISTINCT Name FROM Products WHERE CategoryName = '" + modelProduct.CategoryName + "'";
            SqlCommand    sqlCommand    = new SqlCommand(query, sqlConnection);

            sqlConnection.Open();

            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
            DataTable      dataTable      = new DataTable();

            sqlDataAdapter.Fill(dataTable);
            sqlConnection.Close();
            return(dataTable);

            //List<ModelProduct> productComboList = new List<ModelProduct>();
            //SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
            //while (sqlDataReader.Read())
            //{

            //    modelProduct.Name = sqlDataReader["Name"].ToString();

            //    productComboList.Add(modelProduct);
            //}

            //sqlConnection.Close();
            //return productComboList;
        }
        private void ProductComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                ProductManager _productManager = new ProductManager();
                ModelProduct   _modelProduct   = new ModelProduct();
                _modelProduct.Name = productComboBox.Text;
                _productManager.ProductComboList(_modelProduct);
                codeTextBox.Text = _modelProduct.Name + " ( " + _modelProduct.Code + " )";

                //int qty = 0;
                //int availableQty = 0;
                //for (int i = 0; i < _productManager.ProductComboList(_modelProduct).Count; i++)
                //{
                //    qty = i + _modelProduct.Constant;
                //    availableQty = qty + 1;
                //}

                //availAbleQtyTextBox.Text = availableQty.ToString();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Example #4
0
        public FrmStokYonetimi()
        {
            InitializeComponent();

            modelProduct = new ModelProduct();
            Init();
        }
        private void CategoryComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ProductManager _productManager = new ProductManager();
            ModelProduct   _modelProduct   = new ModelProduct();

            _modelProduct.CategoryName = categoryComboBox.Text;
            productComboBox.DataSource = _productManager.CategoryComboList(_modelProduct);
        }
        /// <summary>
        /// To the model.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        internal static ModelProduct ToModel(this EntityProduct entity)
        {
            var model = new ModelProduct();

            model.Id          = entity.Id;
            model.Name        = entity.Name;
            model.Description = entity.Description;
            model.Price       = entity.Price;

            return(model);
        }
        /// <summary>
        /// To the entity.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        internal static EntityProduct ToEntity(this ModelProduct model)
        {
            var entity = new EntityProduct();

            entity.Id          = model.Id;
            entity.Name        = model.Name;
            entity.Description = model.Description;
            entity.Price       = model.Price;

            return(entity);
        }
        public ActionResult Delete(string sID)
        {
            ModelProduct cItemToDelete = cRepositoryProducts.Find(sID);

            if (cItemToDelete == null)
            {
                return(HttpNotFound());
            }
            else
            {
                return(View(cItemToDelete));
            }
        }
        private void gridViewAvailableStock_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                bool   Status        = false;
                string StatusDetails = null;
                if (e.RowIndex >= 0)
                {
                    DataGridViewRow Row = this.gridViewAvailableStock.Rows[e.RowIndex];
                    labelBarcode.Text        = Row.Cells["Barcode"].Value.ToString();
                    labelCategory.Text       = Row.Cells["CategoryName"].Value.ToString();
                    labelType.Text           = Row.Cells["ProductType"].Value.ToString();
                    labelBrand.Text          = Row.Cells["ProductBrand"].Value.ToString();
                    labelSize.Text           = Row.Cells["ProductSize"].Value.ToString();
                    labelColor.Text          = Row.Cells["ProductColor"].Value.ToString();
                    labelDate.Text           = Row.Cells["PurchaseDate"].Value.ToString();
                    labelAvailableStock.Text = Row.Cells["AvailableQty"].Value.ToString();
                    labelCousumeStock.Text   = Row.Cells["SoldQty"].Value.ToString();

                    ModelProduct mp = new ModelProduct();
                    mp.ProductID = Convert.ToInt32(Row.Cells["ProductID"].Value.ToString());
                    DataTable ddt = MainClass.POS.usp_GetProduct_withImage(mp, out Status, out StatusDetails);
                    if (Status)
                    {
                        string pImage = ddt.Rows[0]["ProductPicture"].ToString();
                        if (pImage == "ImageClass.GetImageFromBase64(Row.Cells[ProductImage].Value.ToString())' threw an exception of type 'System.FormatException" || pImage == "" || pImage == "NoImage")
                        {
                            labelAfterHiddenImage.Visible = true;
                            labelAfterHiddenImage.Text    = "NoImage";
                            pictureBoxAvailable.Visible   = false;
                        }
                        else
                        {
                            pictureBoxAvailable.Visible   = true;
                            labelAfterHiddenImage.Visible = false;
                            pictureBoxAvailable.Image     = ImageClass.GetImageFromBase64(ddt.Rows[0]["ProductPicture"].ToString());
                        }
                        udmGetQtySumFromGridViewDown();
                    }
                    else
                    {
                        MessageBox.Show(StatusDetails, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (Exception ex)
            {
                JIMessageBox.ErrorMessage(ex.Message);
            }
        }
        public ActionResult Create(ModelProduct product)
        {
            if (!ModelState.IsValid)
            {
                return(View(product));
            }
            else
            {
                cRepositoryProducts.Insert(product);
                cRepositoryProducts.Commit();

                return(RedirectToAction("Index"));
            }
        }
        public List <ModelProduct> UpdateProduct(ModelProduct modelProduct)
        {
            string        connection    = @"Server = AHO-BATIJA; DataBase = SmallBusinessManagementSystem; Integrated Security = True";
            SqlConnection sqlConnection = new SqlConnection(connection);
            string        query         = @"UPDATE Products SET CategoryName='" + modelProduct.CategoryName + "', Code='" + modelProduct.Code + "', Name='" + modelProduct.Name + "', ReOrder=" + modelProduct.ReOrder + ", Description='" + modelProduct.Description + "' WHERE Id = " + modelProduct.Id + "";
            SqlCommand    sqlCommand    = new SqlCommand(query, sqlConnection);

            sqlConnection.Open();
            List <ModelProduct> modelProductList = new List <ModelProduct>();
            SqlDataReader       sqlDataReader    = sqlCommand.ExecuteReader();

            modelProductList.Add(modelProduct);
            sqlConnection.Close();
            return(modelProductList);
        }
        public ActionResult ConfirmDelete(string sID)
        {
            ModelProduct cItemToDelete = cRepositoryProducts.Find(sID);

            if (cItemToDelete == null)
            {
                return(HttpNotFound());
            }
            else
            {
                cRepositoryProducts.Delete(sID);
                cRepositoryProducts.Commit();
                return(RedirectToAction("Index"));
            }
        }
Example #13
0
        /// <summary>
        ///     A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public Response FunctionHandler(Request input, ILambdaContext context)
        {
            var dba = new DBAccess();

            if (input.Body.IsPing)
            {
                return new Response {
                           StatusCode = 200, Message = dba.Test()
                }
            }
            ;


            try
            {
                //validate require role
                if (!input.SourceUser.HasRole("Model"))
                {
                    return new Response {
                               StatusCode = 401, Message = "Access denied, requires Model role"
                    }
                }
                ;


                var modelProduct = new ModelProduct
                {
                    ModelId   = input.Body.ModelId,
                    ProductId = input.Body.ProductId
                };
                modelProduct.Delete(dba.Connection);


                var r = new Response
                {
                    StatusCode = 200,
                    Message    = "ok"
                };
                return(r);
            }
            catch (Exception e)
            {
                var r = new Response();
                r.SetError(400, e);
                return(r);
            }
        }
    }
        private void udmKeyPress()
        {
            try
            {
                bool   Status        = false;
                string StatusDetails = null;

                // Getting Index of Current Row
                int             index = gridViewAvailableStock.CurrentRow.Index;
                DataGridViewRow Row   = this.gridViewAvailableStock.Rows[index];

                labelBarcode.Text        = Row.Cells["Barcode"].Value.ToString();
                labelCategory.Text       = Row.Cells["CategoryName"].Value.ToString();
                labelType.Text           = Row.Cells["ProductType"].Value.ToString();
                labelBrand.Text          = Row.Cells["ProductBrand"].Value.ToString();
                labelSize.Text           = Row.Cells["ProductSize"].Value.ToString();
                labelColor.Text          = Row.Cells["ProductColor"].Value.ToString();
                labelDate.Text           = Row.Cells["PurchaseDate"].Value.ToString();
                labelAvailableStock.Text = Row.Cells["AvailableQty"].Value.ToString();
                labelCousumeStock.Text   = Row.Cells["SoldQty"].Value.ToString();

                ModelProduct mp = new ModelProduct();
                mp.ProductID = Convert.ToInt32(Row.Cells["ProductID"].Value.ToString());
                DataTable ddt = MainClass.POS.usp_GetProduct_withImage(mp, out Status, out StatusDetails);
                if (Status)
                {
                    string pImage = ddt.Rows[0]["ProductPicture"].ToString();
                    if (pImage == "ImageClass.GetImageFromBase64(Row.Cells[ProductImage].Value.ToString())' threw an exception of type 'System.FormatException" || pImage == "" || pImage == "NoImage")
                    {
                        labelAfterHiddenImage.Visible = true;
                        labelAfterHiddenImage.Text    = "NoImage";
                        pictureBoxAvailable.Visible   = false;
                    }
                    else
                    {
                        pictureBoxAvailable.Visible   = true;
                        labelAfterHiddenImage.Visible = false;
                        pictureBoxAvailable.Image     = ImageClass.GetImageFromBase64(ddt.Rows[0]["ProductPicture"].ToString());
                    }
                    udmGetQtySumFromGridViewDown();
                }
            }
            catch (Exception ex)
            {
                JIMessageBox.ErrorMessage(ex.Message);
            }
        }
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            var modelProduct = new ModelProduct();

            string message = string.Empty;

            // modelProduct.TextBoslukKontrol_DevExpress(t,dxErrorProvider1,"Stok adı alanı boş olmaz!");

            if (!dxValidationProvider1.Validate())
            {
                return;
            }
            int pid     = 0;
            var product = new PRODUCT
            {
                BRAND_ID       = _brand.BRAND_ID,
                PRODUCT_NAME   = txtUrunAd.Text,
                PRODUCT_CATID  = _urunKategori.PRODUCT_CATID,
                SHORT_CODE_ID  = _model.MODEL_ID,
                PRODUCT_CODE   = "123456",
                PRODUCT_CODE_2 = "1234567",
                PRODUCT_STATUS = true
            };

            var productUnit = new PRODUCT_UNIT
            {
                ADD_UNIT            = _birim.UNIT,
                MAIN_UNIT           = _birim.UNIT,
                MAIN_UNIT_ID        = _birim.UNIT_ID,
                MULTIPLIER          = 1,
                IS_MAIN             = true,
                PRODUCT_UNIT_STATUS = true
            };
            var priceStandart = new PRICE_STANDART
            {
                PRICE                = double.Parse(txtStandartSatis.Text),
                PRICE_KDV            = double.Parse(txtStandartSatis.Text),
                PRICESTANDART_STATUS = true
            };


            modelProduct.AddProduct(product, productUnit, new STOCKS(), priceStandart);

            toastNotificationsManager1.ShowNotification(toastNotificationsManager1.Notifications[1]);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        public ActionResult Edit(string sID)
        {
            ModelProduct cItem = cRepositoryProducts.Find(sID);

            if (cItem == null)
            {
                return(HttpNotFound());
            }
            else
            {
                ViewModelProductManager viewModel = new ViewModelProductManager();
                viewModel.Product           = cItem;
                viewModel.ProductCategories = cRepositoryCategories.Collection();

                return(View(viewModel));
            }
        }
        public bool SaveProduct(ModelProduct modelProduct)
        {
            bool          isSaveProduct = false;
            string        connection    = @"Server = AHO-BATIJA; DataBase = SmallBusinessManagementSystem; Integrated Security = True";
            SqlConnection sqlConnection = new SqlConnection(connection);
            string        query         = @"INSERT INTO Products(CategoryName, Code, Name, ReOrder, Description)VALUES('" + modelProduct.CategoryName + "','" + modelProduct.Code + "' , '" + modelProduct.Name + "', " + modelProduct.ReOrder + ",'" + modelProduct.Description + "')";
            SqlCommand    sqlCommand    = new SqlCommand(query, sqlConnection);

            sqlConnection.Open();
            int isExecute = sqlCommand.ExecuteNonQuery();

            if (isExecute > 0)
            {
                isSaveProduct = true;
            }
            sqlConnection.Close();
            return(isSaveProduct);
        }
        public bool IsProductCodeExits(ModelProduct modelProduct)
        {
            bool          isCodeExits   = false;
            string        connection    = @"Server = AHO-BATIJA; DataBase = SmallBusinessManagementSystem; Integrated Security = True";
            SqlConnection sqlConnection = new SqlConnection(connection);
            string        query         = @"SELECT * FROM Products WHERE Code = '" + modelProduct.Code + "'";
            SqlCommand    sqlCommand    = new SqlCommand(query, sqlConnection);

            sqlConnection.Open();
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
            DataTable      dataTable      = new DataTable();

            sqlDataAdapter.Fill(dataTable);
            if (dataTable.Rows.Count > 0)
            {
                isCodeExits = true;
            }
            sqlConnection.Close();
            return(isCodeExits);
        }
        public List <ModelProduct> ProductComboList(ModelProduct modelProduct)
        {
            string        connection    = @"Server = AHO-BATIJA; DataBase = SmallBusinessManagementSystem; Integrated Security = True";
            SqlConnection sqlConnection = new SqlConnection(connection);
            string        query         = @"SELECT * FROM Products WHERE Name = '" + modelProduct.Name + "'";
            SqlCommand    sqlCommand    = new SqlCommand(query, sqlConnection);

            sqlConnection.Open();
            List <ModelProduct> productComboList = new List <ModelProduct>();
            SqlDataReader       sqlDataReader    = sqlCommand.ExecuteReader();

            while (sqlDataReader.Read())
            {
                modelProduct.Code = sqlDataReader["Code"].ToString();
                modelProduct.Name = sqlDataReader["Name"].ToString();
                productComboList.Add(modelProduct);
            }

            sqlConnection.Close();
            return(productComboList);
        }
Example #20
0
        // PUT: api/Products/5
        public IHttpActionResult Put(int id, ModelProduct product)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var productToUpdate = Mapper.Map <ModelProduct, Product>(product);
                    _productApp.Update(productToUpdate);


                    return(Ok(productToUpdate));
                }
                catch
                {
                    return(InternalServerError());
                }
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }
 public bool SaveProduct(ModelProduct modelProduct)
 {
     return(_productRepository.SaveProduct(modelProduct));
 }
Example #22
0
 public void Add(ModelProduct product)
 {
     _repository.Add(product);
 }
 public List <ModelProduct> ProductComboList(ModelProduct modelProduct)
 {
     return(_productRepository.ProductComboList(modelProduct));
 }
 public DataTable CategoryComboList(ModelProduct modelProduct)
 {
     return(_productRepository.CategoryComboList(modelProduct));
 }
 public bool IsProductCodeExits(ModelProduct modelProduct)
 {
     return(_productRepository.IsProductCodeExits(modelProduct));
 }
 public List <ModelProduct> UpdateProduct(ModelProduct modelProduct)
 {
     return(_productRepository.UpdateProduct(modelProduct));
 }
        public ItemForm()
        {
            InitializeComponent();

            m_model = new ModelProduct();
        }
Example #28
0
        /// <summary>
        ///     A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public Response FunctionHandler(Request input, ILambdaContext context)
        {
            var dba = new DBAccess();

            if (input.Body.IsPing)
            {
                return new Response {
                           StatusCode = 200, Message = dba.Test()
                }
            }
            ;

            try
            {
                //validate require role
                if (!input.SourceUser.HasRole("Model"))
                {
                    return new Response {
                               StatusCode = 401, Message = "Access denied, requires Model role"
                    }
                }
                ;


                //get user
                var user = User.LoadBySourceUser(input.SourceUser, dba.Connection);
                if (user == null)
                {
                    return new Response {
                               StatusCode = 404, Message = "User is not registered, hence cannot be a model"
                    }
                }
                ;


                //get model
                var model = Model.LoadByUser(user.Id, false, dba.Connection);
                if (model == null)
                {
                    return new Response
                           {
                               StatusCode = 404,
                               Message    = "User is not registered as a model, so cannot create a live session"
                           }
                }
                ;


                //check that the user is also  the model
                if (model.Id != input.Body.ModelId)
                {
                    return new Response
                           {
                               StatusCode = 404,
                               Message    = "This model does not match the model id provided in the request"
                           }
                }
                ;


                //create product
                var modelProduct = new ModelProduct
                {
                    ModelId   = model.Id,
                    ProductId = input.Body.ProductId
                };
                modelProduct.Save(dba.Connection);


                var r = new Response
                {
                    StatusCode = 200,
                    Message    = "ok"
                };
                return(r);
            }
            catch (Exception e)
            {
                var r = new Response();
                r.SetError(400, e);
                return(r);
            }
        }
    }
Example #29
0
 public ItemChartForm()
 {
     InitializeComponent();
     m_model        = new ModelProduct();
     m_report_model = new ModelReport();
 }