Beispiel #1
0
 public ActionResult Edit([Bind(Include = "id,code,name,categoryId,brandId,colorId,barCode")] tbl_ItemMaster tbl_itemmaster)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_itemmaster).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.brandId    = new SelectList(db.tbl_Brand, "id", "name", tbl_itemmaster.brandId);
     ViewBag.categoryId = new SelectList(db.tbl_Category, "id", "name", tbl_itemmaster.categoryId);
     ViewBag.colorId    = new SelectList(db.tbl_Color, "id", "name", tbl_itemmaster.colorId);
     return(View(tbl_itemmaster));
 }
Beispiel #2
0
        // GET: /ItemMaster/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_ItemMaster tbl_itemmaster = db.tbl_ItemMaster.Find(id);

            if (tbl_itemmaster == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_itemmaster));
        }
Beispiel #3
0
        // GET: /ItemMaster/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_ItemMaster tbl_itemmaster = db.tbl_ItemMaster.Find(id);

            if (tbl_itemmaster == null)
            {
                return(HttpNotFound());
            }
            ViewBag.brandId    = new SelectList(db.tbl_Brand, "id", "name", tbl_itemmaster.brandId);
            ViewBag.categoryId = new SelectList(db.tbl_Category, "id", "name", tbl_itemmaster.categoryId);
            ViewBag.colorId    = new SelectList(db.tbl_Color, "id", "name", tbl_itemmaster.colorId);
            return(View(tbl_itemmaster));
        }
Beispiel #4
0
        public JsonResult DeleteConfirmed(int id)
        {
            string success = string.Empty;
            // return Json(success, JsonRequestBehavior.AllowGet);
            tbl_ItemMaster tbl_itemmaster = db.tbl_ItemMaster.Find(id);

            db.tbl_ItemMaster.Remove(tbl_itemmaster);
            int result = db.SaveChanges();

            if (result > 0)
            {
                success = "Data delete successfully";
            }
            //  return Json(success, JsonRequestBehavior.AllowGet);

            return(Json(new { result = success }));
        }
Beispiel #5
0
        public ActionResult Create([Bind(Include = "id,code,name,categoryId,brandId,colorId,barCode")] tbl_ItemMaster tbl_itemmaster)
        {
            if (ModelState.IsValid)
            {
                db.tbl_ItemMaster.Add(tbl_itemmaster);
                ViewBag.message = "Item Inserted Succesfully";
                db.SaveChanges();


                //return View(tbl_itemmaster);
                return(RedirectToAction("Index"));
            }

            ViewBag.brandId    = new SelectList(db.tbl_Brand, "id", "name", tbl_itemmaster.brandId);
            ViewBag.categoryId = new SelectList(db.tbl_Category, "id", "name", tbl_itemmaster.categoryId);
            ViewBag.colorId    = new SelectList(db.tbl_Color, "id", "name", tbl_itemmaster.colorId);
            return(View(tbl_itemmaster));
        }
Beispiel #6
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            byte[] pic = null;
            try
            {
                if (CaptureBox.Image != null)
                {
                    MemoryStream stream = new MemoryStream();
                    CaptureBox.Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    pic = stream.ToArray();
                }

                if (txtWeight.Text == string.Empty && txtMelting.Text == string.Empty && txtQty.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtWeight, "Enter all details.");
                    txtWeight.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter all details.";
                }
                else if (txtWeight.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtWeight, "Enter weight.");
                    txtWeight.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter weight.";
                }
                else if (txtQty.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtQty, "Enter qty.");
                    txtQty.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter qty.";
                }
                else if (txtMelting.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtMelting, "Enter melting.");
                    txtMelting.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter melting.";
                }

                //else if (CaptureBox.Image == null)
                //{
                //    errorProvider1.Clear();
                //    errorProvider1.SetError(CaptureBox, "Select Image.");
                //    CaptureBox.Focus();
                //    panel3.Visible = true;
                //    lblError.Text = "Select Image.";
                //}
                else
                {
                    if (btnCreate.Text == "Create")
                    {
                        //insert Code

                        _entities = new MicroAccountsEntities1();

                        tbl_ItemMaster itemMaster = new tbl_ItemMaster();
                        //itemMaster.categoryId = Convert.ToInt32(cmbItemCategory.SelectedValue);
                        itemMaster.categoryId  = Convert.ToInt32(cmbItemCategory.SelectedValue);
                        itemMaster.photo       = pic;
                        itemMaster.itemCode    = lblItemCode.Text;
                        itemMaster.createdDate = DateTime.Now;

                        _entities.tbl_ItemMaster.Add(itemMaster);
                        _entities.SaveChanges();

                        tbl_StockItemDetails stockDetail = new tbl_StockItemDetails();
                        stockDetail.weight = Convert.ToDecimal(txtWeight.Text);

                        if (cmbKarat.SelectedIndex > 0)
                        {
                            stockDetail.carret = Convert.ToDecimal(cmbKarat.Text);
                        }
                        else
                        {
                            stockDetail.carret = 0;
                        }

                        stockDetail.qty         = Convert.ToDecimal(txtQty.Text);
                        stockDetail.unit        = cmbUnit.Text.ToString();
                        stockDetail.melting     = Convert.ToDecimal(txtMelting.Text);
                        stockDetail.remarks     = txtRemarks.Text.Trim().ToString();
                        stockDetail.itemId      = _entities.tbl_ItemMaster.OrderByDescending(x => x.id).FirstOrDefault().id;
                        stockDetail.createdDate = DateTime.Now;
                        stockDetail.upadtedDate = DateTime.Now;

                        _entities.tbl_StockItemDetails.Add(stockDetail);
                        _entities.SaveChanges();

                        MessageBox.Show("Record Successfully Saved!");
                    }
                    else
                    {
                        //Update Code
                        _entities = new MicroAccountsEntities1();

                        var itemData = (from a in _entities.tbl_ItemMaster
                                        join b in _entities.tbl_StockItemDetails on a.id equals b.itemId
                                        where a.id == itemIDGlobal
                                        select new { a, b }).FirstOrDefault();

                        itemData.a.categoryId = Convert.ToInt32(cmbItemCategory.SelectedValue);
                        itemData.a.photo      = pic;
                        itemData.a.itemCode   = lblItemCode.Text;
                        itemData.a.updateDate = DateTime.Now;

                        itemData.b.weight = Convert.ToDecimal(txtWeight.Text);
                        if (cmbKarat.SelectedIndex > 0)
                        {
                            itemData.b.carret = Convert.ToDecimal(cmbKarat.Text);
                        }
                        else
                        {
                            itemData.b.carret = 0;
                        }
                        itemData.b.qty     = Convert.ToDecimal(txtQty.Text);
                        itemData.b.unit    = cmbUnit.Text.ToString();
                        itemData.b.melting = Convert.ToDecimal(txtMelting.Text);
                        itemData.b.remarks = txtRemarks.Text.Trim().ToString();

                        itemData.b.upadtedDate = DateTime.Now;

                        _entities.SaveChanges();

                        MessageBox.Show("Record Successfully Updated!");
                    }
                    clear();
                }
            }
            catch (Exception x)
            {
                MessageBox.Show("Something went wrong. Contact your system administrator");
            }
        }