Пример #1
0
        private void txt_Item_Name_TextChanged(object sender, EventArgs e)
        {
            Tbl_Item Item = new Tbl_Item();
            AutoCompleteStringCollection MyCollection = new AutoCompleteStringCollection();

            var x_text = brada.Tbl_Items.Select(s => s.Item_Name).ToList();

            foreach (var item in x_text)
            {
                MyCollection.Add(item);
            }

            txt_Item_Name.AutoCompleteMode   = AutoCompleteMode.Suggest;
            txt_Item_Name.AutoCompleteSource = AutoCompleteSource.CustomSource;
            AutoCompleteStringCollection DataCollection = (MyCollection);

            txt_Item_Name.AutoCompleteCustomSource = DataCollection;
            try
            {
                var details = brada.Tbl_Items.Where(s => s.Item_Name == txt_Item_Name.Text).Select(s => new { ID = s.ID, Name = s.Item_Name, Quantity2 = s.Quantity_Num, Packuprice = s.Packu_Price, PeicesNum = s.Peices_Number, ValidDate = s.Validation_Date, totcost = s.TotalCost }).SingleOrDefault();
                txt_Code_Item.Text       = details.ID.ToString();
                txt_Quantity_Number.Text = details.Quantity2.ToString();
                txt_Peices_Num.Text      = details.PeicesNum.ToString();
                txt_Packu_Cost.Text      = details.Packuprice.ToString();
                txt_Validation_date.Text = details.ValidDate.ToShortDateString();
                txt_TotalCost.Text       = details.totcost.ToString();
            }
            catch (Exception)
            {
                if (txt_Item_Name.Text == "")
                {
                    MessageBox.Show("Retry Typing Item's Name Correctly\nأعد كتابة إسم الصنف بطريقة صحيحة");
                }
            }
        }
        public ActionResult DeleteConfirmed(string id)
        {
            Tbl_Item tbl_Item = db.Tbl_Item.Find(id);

            db.Tbl_Item.Remove(tbl_Item);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Tbl_Item item = new Tbl_Item();

        item.CategoryID_N   = Convert.ToInt32(UC_CategoryList.SelectedValue.ToString());
        item.CategoryName_V = txtCategory.Text.Trim();
        item.merchantname   = txtMerchant.Text.Trim();
        clsAddItems.AddMasterItem(item);
        GetAllItems();
    }
 public ActionResult Edit([Bind(Include = "ID,Item_Name,Item_Description,Item_Image,Item_Location,CategoryID,UserID")] Tbl_Item tbl_Item)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_Item).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoryID = new SelectList(db.Tbl_Categories, "ID", "CategoryName", tbl_Item.CategoryID);
     ViewBag.UserID     = new SelectList(db.Tbl_Users, "ID", "UserName", tbl_Item.UserID);
     return(View(tbl_Item));
 }
        //public ActionResult GetItemsByName()
        //{
        //    // var jobs = db.ApplyForJobs.Where(a => a.UserId == UserId);
        //    //var tbl_Item = db.Tbl_Item.Where(item => item.;
        //    return View(tbl_Item.ToList());
        //}

        // GET: Tbl_Item/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tbl_Item tbl_Item = db.Tbl_Item.Find(id);

            if (tbl_Item == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_Item));
        }
        // GET: Tbl_Item/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tbl_Item tbl_Item = db.Tbl_Item.Find(id);

            if (tbl_Item == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CategoryID = new SelectList(db.Tbl_Categories, "ID", "CategoryName", tbl_Item.CategoryID);
            ViewBag.UserID     = new SelectList(db.Tbl_Users, "ID", "UserName", tbl_Item.UserID);
            return(View(tbl_Item));
        }
Пример #7
0
 public static Item MapFrom(this Tbl_Item item)
 {
     return(new Item
     {
         Id = item.Id,
         Name = item.Name,
         CategoryId = item.CategoryId,
         CategoryName = item.Tbl_Category?.Name ?? string.Empty,
         SalePrice = item.SalePrice,
         PurchasePrice = item.PurchasePrice,
         IsEnabled = item.IsEnabled,
         Created_At = item.Created_At,
         Updated_At = item.Updated_At,
         TaxId = item.TaxId,
         TaxName = item.Tbl_Tax?.Name ?? string.Empty,
         Description = item.Description,
         Picture = item.Picture
     });
 }
Пример #8
0
    public static void AddMasterItem(Tbl_Item items)
    {
        using (cos_OtherEntities model = new cos_OtherEntities())
        {
            Tbl_Item item = new Tbl_Item();

            var original = model.Tbl_Items.Where(c => c.ItenName == items.ItenName).SingleOrDefault();

            if (original == null)
            {
                item.ItenName       = items.ItenName;
                item.ItemBrand      = items.ItemBrand;
                item.CategoryID_N   = items.CategoryID_N;
                item.CategoryName_V = items.CategoryName_V;
                item.merchantname   = items.merchantname;
                model.AddToTbl_Items(item);
                model.SaveChanges();
            }
        }
    }
Пример #9
0
        private void Btn_Add_Item_Click(object sender, EventArgs e)
        {
            TBL_Receive receive = new TBL_Receive();
            Tbl_Item    Item    = new Tbl_Item();

            if (txt_receive_date.Text == "" && txt_receive_num.Text == "")
            {
                txt_receive_date.Text = Convert.ToString(DateTime.Now);
                var maxid = brada.TBL_Receives.Max(s => s.recieve_num);
                txt_receive_num.Text = (maxid + 1).ToString();
            }
            txt_Packu_Cost.Clear();
            txt_Code_Item.Clear();
            txt_Item_Name.Clear();
            txt_Quantity_Int_Store.Visible = false;
            txt_Quantity_Number.Clear();
            txt_Peices_Num.Clear();
            txt_Validation_date.Clear();
            txt_TotalCost.Clear();
            Btn_Impleme_Update.Visible   = false;
            Btn_Delete_Confirm.Visible   = false;
            Btn_Add_Item_Confirm.Visible = true;
            Btn_Add_Item_Confirm.Text    = "تأكيد الإضافة";

            Combo_Hall_Name.Visible = false;
            label4.Visible          = false;

            label8.Visible = false;

            Btn_Decrease_Shlal.Visible = false;
            Btn_Increase_Shlal.Visible = false;
            label12.Visible            = false;
            label13.Visible            = false;

            txt_money_val.Visible        = false;
            txt_Store_Packu.Visible      = false;
            label15.Visible              = false;
            label17.Visible              = false;
            txt_Search_Store.Visible     = false;
            txt_Packu_Store_Cost.Visible = false;
        }
        private void Btn_Add_Item_Confirm_Click(object sender, EventArgs e)
        {
            Tbl_Item            Item        = new Tbl_Item();
            Tbl_Daily_operation DailyOperat = new Tbl_Daily_operation();
            Tbl_Import          Import      = new Tbl_Import();

            if (txt_Import_date.Text != "" && txt_receipt_num.Text != "")
            {
                if (search_ITems(txt_Item_Name.Text))
                {
                    if (search_daily(txt_Item_Name.Text))//Update
                    {
                        MessageBox.Show("Refused");
                        txt_Item_Name.Text = txt_Quantity_Number.Text = Lbl_TotalCost.Text = txt_Packu_Cost.Text = "";
                    }
                    else//Insert
                    {
                        if (txt_Item_Name.Text != "" && txt_Quantity_Number.Text != "" && txt_Packu_Cost.Text != "" && Lbl_TotalCost.Text != "")
                        {
                            var date        = Convert.ToDateTime(txt_Import_date.Text);
                            var receipt_num = Convert.ToInt32(txt_receipt_num.Text);
                            //--------------- Replace Subtracted values from Tbl_ITem Table---
                            var details               = brada.Tbl_Items.Where(s => s.Item_Name == txt_Item_Name.Text).Select(s => new { ID = s.ID, Quantity__Item_Num = s.Quantity_Num }).SingleOrDefault();
                            int item_Code             = details.ID;
                            int Quantity_tbl_Item_Num = details.Quantity__Item_Num;
                            int Quantity_Subtracted_DailyOPeration = Convert.ToInt32(txt_Quantity_Number.Text);
                            int Tbl_Item_Result_after_Subtract     = Quantity_tbl_Item_Num - Quantity_Subtracted_DailyOPeration;
                            var ID = details.ID;
                            brada.Subtract_Update_Tbl_Item_Daily(ID, Tbl_Item_Result_after_Subtract);

                            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
                            {
                                DataGridViewRow row  = dataGridView1.Rows[i];
                                var             cel0 = row.Cells[0].Value.ToString();
                                var             cel1 = row.Cells[1].Value.ToString();
                                var             cel2 = row.Cells[2].Value.ToString();
                                var             cel3 = row.Cells[3].Value.ToString();
                                //Insert values Directly from Gridview
                                //i=====>max+1 hالمفروض
                                brada.insert_Daily_Operation(i, item_Code, cel0, int.Parse(cel1), float.Parse(cel2), float.Parse(cel3), date, receipt_num);
                                brada.SubmitChanges();
                            }
                            label13.Text = "";
                            Btn_Add_Item_Confirm.Text = "تم الإضافة";
                            txt_receipt_num.Clear();
                        }
                        else
                        {
                            MessageBox.Show("برجاء املأ الخانات");
                        }
                        brada.SubmitChanges();
                        txt_Item_Name.Text = txt_Quantity_Number.Text = Lbl_TotalCost.Text = txt_Packu_Cost.Text = "";
                    }
                }
                else
                {
                    MessageBox.Show(" إلغى هذا ! سيؤدى ذلك لخراب السيستم على إيدك يا مفترى ");
                }
            }
            else
            {
                MessageBox.Show("Press Add Item,إضغط إضافة صنف");
            }
        }
Пример #11
0
        private void Btn_Add_Item_Confirm_Click(object sender, EventArgs e)
        {
            TBL_Receive receive = new TBL_Receive();
            Tbl_Item    Item    = new Tbl_Item();

            if (txt_receive_date.Text != "" && txt_receive_num.Text != "")
            {
                if (!search(txt_Item_Name.Text))
                {
                    if (txt_Item_Name.Text != "" && txt_Quantity_Number.Text != "" && txt_Packu_Cost.Text != "" && txt_Validation_date.Text != "" && txt_TotalCost.Text != "")
                    {
                        if (txt_Item_Name.Text != "Empty !!" && txt_Quantity_Number.Text != "Empty !!" && txt_Packu_Cost.Text != "Empty !!" && txt_Validation_date.Text != "Empty !!" && txt_TotalCost.Text != "Empty !!")
                        {
                            receive.recieve_num  = int.Parse(txt_receive_num.Text);
                            receive.recieve_Date = DateTime.Parse(txt_receive_date.Text);
                            var   newnam            = txt_Item_Name.Text;
                            var   Quantity_num      = int.Parse(txt_Quantity_Number.Text);
                            int   Quantity_Num      = Convert.ToInt32(Quantity_num);
                            var   Peices_num        = int.Parse(txt_Peices_Num.Text);
                            int   Peices_Num        = Convert.ToInt32(Peices_num);
                            var   Price             = float.Parse(txt_Packu_Cost.Text);
                            float price             = Price;
                            var   date              = DateTime.Parse(txt_Validation_date.Text);
                            int   Quantity_Int      = Quantity_Num / Peices_Num;
                            int   Quantit_Int_Price = Convert.ToInt32(price * Peices_Num);
                            var   Quantity_int      = Quantity_Int;
                            var   total_cost        = float.Parse(txt_TotalCost.Text);
                            brada.TBL_Receives.InsertOnSubmit(receive);
                            brada.insert_tbl_Item2(newnam, Quantity_num, Price, Peices_num, Quantity_Int, date, total_cost, Quantit_Int_Price);
                            brada.SubmitChanges();
                            Btn_Add_Item_Confirm.Text = "تم الإضافة";

                            //string[] formats = { "MM/dd/yyyy", "M/d/yyyy", "M/dd/yyyy", "MM/d/yyyy" };
                            //foreach (var date in formats)
                            //{
                            //    if (txt_Validation_date.Text == date)
                            //    {

                            //    }
                            //    else
                            //    {
                            //        MessageBox.Show("Use MM/dd/yyyy formatting for date");
                            //    }
                            //}


                            //Item.ValidationDate = DateTime.Parse(txt_Validation_date.Text);
                            //string[] formats = { "MM/dd/yyyy", "M/d/yyyy", "M/dd/yyyy", "MM/d/yyyy" };
                            //string formats = "MM/dd/yyyy 00:00:00.000";
                            ////foreach (var date in formats)
                            ////{
                            //if (txt_Validation_date.Text == formats)
                            //{
                            //    Item.ValidationDate = DateTime.Parse(txt_Validation_date.Text);
                            //}
                            //else
                            //{
                            //    MessageBox.Show("Use MM/dd/yyyy formatting for date");
                            //}
                            //}
                            ////--------
                            //if (DateTime.TryParseExact(txt_Validation_date.Text, "MM/dd/yyyy", null, DateTimeStyles.None, out Test) == true)
                            //{
                            //}
                            //----
                            //DateTime dDate;
                            //if (DateTime.TryParse(txt_Validation_date.Text,out dDate) )
                            //{
                            //    String.Format("{0:d/MM/yyyy}", dDate);
                            //}
                        }
                        else
                        {
                            MessageBox.Show("برجاء املأ الخانات");
                        }
                    }
                    else
                    {
                        MessageBox.Show("برجاء املأ الخانات");
                    }
                    brada.SubmitChanges();
                    //txt_Item_Name.Text = txt_Quantity_Cost.Text = txt_Quantity_Integer.Text = txt_Quantity_Number.Text = txt_TotalCost.Text = txt_Validation_date.Text = "";
                }
                else
                {
                    MessageBox.Show("الاسم مكرر");
                }
            }
            else
            {
                MessageBox.Show("Press Add Item,إضغط إضافة صنف");
            }


            //else
            //{
            //    MessageBox.Show("Press Add Item,إضغط إضافة صنف");
            //}
            //-------------
            //-------------
            //if (txt_receive_date.Text!=""&&txt_receive_num.Text!="")
            //{
            //    if (txt_Item_Name.Text != "" && txt_Cost.Text != "" && txt_Quantity_Integer.Text != "" && txt_Quantity_Number.Text != "" && txt_TotalCost.Text != "" && txt_Validation_date.Text != "" && txt_receive_date.Text != "" && txt_receive_num.Text != "")
            //    {
            //        receive.recieve_num = int.Parse(txt_receive_num.Text);
            //        receive.recieve_Date = DateTime.Parse(txt_receive_date.Text);
            //        Item.Item_Name = txt_Item_Name.Text;
            //        Item.CostPrice = float.Parse(txt_Cost.Text);
            //        Item.QuantityInteger = int.Parse(txt_Quantity_Integer.Text);
            //        Item.QuantityNumber = int.Parse(txt_Quantity_Number.Text);
            //        Item.ValidationDate = DateTime.Parse(txt_Validation_date.Text);
            //        Item.TotalCost = float.Parse(txt_TotalCost.Text);

            //        brada.TBL_Receives.InsertOnSubmit(receive);
            //        brada.TblItems.InsertOnSubmit(Item);
            //        brada.SubmitChanges();
            //        Btn_Add_Item_Confirm.Text = "تم الإضافة";
            //    }
            //}

            label12.Visible = false;
            label13.Visible = false;

            txt_money_val.Visible   = false;
            txt_Store_Packu.Visible = false;

            label8.Visible = false;

            Btn_Decrease_Shlal.Visible   = false;
            Btn_Increase_Shlal.Visible   = false;
            label15.Visible              = false;
            label17.Visible              = false;
            txt_Search_Store.Visible     = false;
            txt_Packu_Store_Cost.Visible = false;
        }