static void Main(string[] args)
        {
            karyawanTetap karyawanTetap = new karyawanTetap();

            karyawanTetap.Nik         = "19.11.2770";
            karyawanTetap.Nama        = "Abiyu";
            karyawanTetap.GajiBulanan = 7000000;

            karyawanHarian karyawanHarian = new karyawanHarian();

            karyawanHarian.Nik            = "19.11.7270";
            karyawanHarian.Nama           = "Putra";
            karyawanHarian.JumlahJamKerja = 12;
            karyawanHarian.UpahPerJam     = 50000;

            sales sales = new sales();

            sales.Nik             = "19.11.2077";
            sales.Nama            = "Aronggear";
            sales.JumlahPenjualan = 100;
            sales.Komisi          = 100000;

            List <karyawan> listKaryawan = new List <karyawan>();

            listKaryawan.Add(karyawanTetap);
            listKaryawan.Add(karyawanHarian);
            listKaryawan.Add(sales);

            int noUrut = 1;

            foreach (karyawan karyawan in listKaryawan)
            {
                Console.WriteLine("{0}. Nik : {1}, Nama : {2}, Gaji : {3:N0}", noUrut, karyawan.Nik, karyawan.Nama, karyawan.Gaji());
            }
        }
Exemple #2
0
        //purchase product on btn click and save data to database
        protected void btnBuy_Click(object sender, EventArgs e)
        {
            try
            {
                using (sales db = new sales())
                {
                    DateTime today = DateTime.Now;

                    Order obj = new Order();
                    obj.productID = Convert.ToInt32(ddlProduct.SelectedValue);
                    obj.qty       = Convert.ToInt32(txtqty.Text);
                    obj.price     = 10000.00m;
                    obj.shipDate  = today;
                    obj.orderDate = today;
                    obj.tax       = .11;


                    //save
                    db.Orders.Add(obj);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Response.Redirect("/error.aspx");
            }
        }
 public ActionResult add(sales s)
 {
     ViewBag.i = new SelectList(new invoice().showall(), "in_id", "in_date");
     ViewBag.j = new SelectList(new product().showall(), "prd_id", "prd_name");
     s.add();
     return(RedirectToAction("show"));
 }
        protected void grdOrders_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                //connect
                using (sales db = new sales())
                {
                    //get order id from grid
                    Int32 orderID = Convert.ToInt32(grdOrders.DataKeys[e.RowIndex].Values["orderID"]);
                    //find order
                    var order = (from o in db.Orders
                                 where o.orderID == orderID
                                 select o).FirstOrDefault();

                    //delete it
                    db.Orders.Remove(order);
                    db.SaveChanges();

                    //reload
                    getOrders();
                }
            }
            catch (Exception ex)
            {
                Response.Redirect("/error.aspx");
            }
        }
Exemple #5
0
 private void Billing_FormClosing(object sender, FormClosingEventArgs e)
 {
     sales obj = new sales();
     obj.MdiParent = MdiParent;
     obj.Show();
     Hide();
 }
Exemple #6
0
        public JsonResult UpdateSale(sales sale)
        {
            if (ModelState.IsValid)
            {
                sales UpdatedRec = _context.Sales.Find(sale.Id);
                UpdatedRec.Customerid = sale.Customerid;
                UpdatedRec.Productid  = sale.Productid;
                UpdatedRec.Storeid    = sale.Storeid;
                UpdatedRec.Datesold   = sale.Datesold;
                _context.SaveChanges();
            }
            else
            {
                //Console.Write(e.Data + "Exception Occured");
                var modelErrors = new List <string>();
                foreach (var modelState in ModelState.Values)
                {
                    foreach (var modelError in modelState.Errors)
                    {
                        modelErrors.Add(modelError.ErrorMessage);
                    }
                }
                return(new JsonResult {
                    Data = modelErrors, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }


            return(new JsonResult {
                Data = "Sucess", JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Exemple #7
0
//============================================================================
        public void remove_sale_operation(int saleId)
        {
            sales op = DB.sales.Where(s => s.id == saleId).Single();

            DB.sales.Remove(op);
            DB.SaveChanges();
        }
        private void placeNewOrderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            _storeName = null;

            try
            {
                if (StoresDropDown.Text == "")
                {
                    MessageBox.Show("Choose a Book Store from the drop down.", "Error", MessageBoxButtons.OK);
                    return;
                }
                else
                {
                    _storeName = new store();

                    if (StoresDropDown.SelectedItem is storeViewModel st)
                    {
                        _storeName.stor_id   = st.StoreID;
                        _storeName.stor_name = st.StoreName;
                    }
                    _sales = new sales();

                    _placeOrder         = new PlaceOrderForm(this, _sales, _storeName);
                    _placeOrder.Enabled = true;
                    _placeOrder.ShowDialog();
                }
            }
            catch
            {
                return;
            }
        }
Exemple #9
0
        public JsonResult delete_sale_operation(int saleId)
        {
            sales op        = DB.sales.Where(s => s.id == saleId).Single();
            int   clientId  = (int)op.clientId;
            int   serviceId = (int)op.serviceId;
            float quantity  = (float)op.quantity; //3l4an el shareha
            float total     = (float)op.total;    //3l4an el client

            using (var removeSaleTransaction = DB.Database.BeginTransaction())
            {
                try
                {
                    remove_sale_operation(saleId);                //by cascading will remove client_sale_operation

                    decrease_chage_of_client(clientId, total);    //to rollback the increasing

                    increase_shareha_charge(serviceId, quantity); //to rollback the decreasing

                    //commit transaction if all opertaions is ok
                    removeSaleTransaction.Commit();
                    return(Json(new { msg = "تمت عمليه الاضافه بنجاح" }));
                }
                catch
                {
                    //rollback the transaction in case any exception occurs
                    removeSaleTransaction.Rollback();
                    return(Json(new { msg = "لم تتم عمليه الاضافه .. حاول مره اخري" }));
                }
            }
        }
Exemple #10
0
        //saves an order
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                using (sales db = new sales())
                {
                    Order obj = new Order();
                    obj.qty              = Convert.ToInt32(txtqty.Text);
                    obj.orderDate        = Convert.ToDateTime(txtOrderDate.Text);
                    obj.shipDate         = Convert.ToDateTime(txtShipDate.Text);
                    obj.tax              = Convert.ToDouble(txtTax.Text);
                    obj.estimateShipDate = Convert.ToDateTime(txtEstShipDate.Text);
                    obj.price            = Convert.ToDecimal(txtPrice.Text);



                    //save
                    db.Orders.Add(obj);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Response.Redirect("/error.aspx");
            }
        }
        public string Create(sales Model)
        {
            DatabaseContext db = new DatabaseContext();
            string          msg;

            try
            {
                if (ModelState.IsValid)
                {
                    Model.idSale = new Random().Next(1, 1000);
                    db.sales.Add(Model);
                    db.SaveChanges();
                    msg = "Saved Successfully";
                }
                else
                {
                    msg = "Validation data not successfully";
                }
            }
            catch (Exception ex)
            {
                msg = "Error occured:" + ex.Message;
            }
            return(msg);
        }
Exemple #12
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                using (sales db = new sales())
                {
                    var id = (from i in db.Retails
                              where i.name == ddlRetail.SelectedItem.Text
                              select i.retailID).FirstOrDefault();

                    Product obj = new Product();
                    obj.model      = txtModel.Text;
                    obj.name       = txtName.Text;
                    obj.color      = txtColor.Text;
                    obj.retailerID = id;


                    //save
                    db.Products.Add(obj);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Response.Redirect("/error.aspx");
            }
        }
Exemple #13
0
 public JsonResult SalesCreate(sales rec)
 {
     if (ModelState.IsValid)
     {
         _context.Sales.Add(rec);
         _context.SaveChanges();
         return(new JsonResult {
             Data = "Sucess", JsonRequestBehavior = JsonRequestBehavior.AllowGet
         });
     }
     else
     {
         //Console.Write(e.Data + "Exception Occured");
         var modelErrors = new List <string>();
         foreach (var modelState in ModelState.Values)
         {
             foreach (var modelError in modelState.Errors)
             {
                 modelErrors.Add(modelError.ErrorMessage);
             }
         }
         return(new JsonResult {
             Data = modelErrors, JsonRequestBehavior = JsonRequestBehavior.AllowGet
         });
     }
 }
Exemple #14
0
        static void Main(string[] args)
        {
            karyawanTetap karyawanTetap = new karyawanTetap();

            karyawanTetap.Nik         = "19.11.2737";
            karyawanTetap.Nama        = "Immanuel";
            karyawanTetap.GajiBulanan = 10000000;

            karyawanHarian karyawanHarian = new karyawanHarian();

            karyawanHarian.Nik            = "19.11.4343";
            karyawanHarian.Nama           = "Paulus";
            karyawanHarian.JumlahJamKerja = 15;
            karyawanHarian.UpahPerJam     = 55000;

            sales sales = new sales();

            sales.Nik             = "19.11.7373";
            sales.Nama            = "Claudio";
            sales.JumlahPenjualan = 50;
            sales.Komisi          = 50000;

            List <karyawan> listKaryawan = new List <karyawan>();

            listKaryawan.Add(karyawanTetap);
            listKaryawan.Add(karyawanHarian);
            listKaryawan.Add(sales);

            int noUrut = 1;

            foreach (karyawan karyawan in listKaryawan)
            {
                Console.WriteLine("{0}. Nik : {1}, Nama : {2}, Gaji : {3:N0}", noUrut, karyawan.Nik, karyawan.Nama, karyawan.Gaji());
            }
        }
Exemple #15
0
        public JsonResult GetSale(int id)
        {
            sales sale = _context.Sales.Find(id);

            return(new JsonResult {
                Data = sale, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public ActionResult DeleteConfirmed(int id)
        {
            sales sales = db.sales.Find(id);

            db.sales.Remove(sales);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult update(sales s)
 {
     ViewBag.i = new SelectList(new invoice().showall(), "in_id", "in_date");
     ViewBag.j = new SelectList(new product().showall(), "prd_id", "prd_name");
     s.sls_id  = (int)TempData["sales_id"];
     s.update();
     return(RedirectToAction("show"));
 }
Exemple #18
0
        public ActionResult DeleteConfirmed(string stor_id, string ord_num, string title_id)
        {
            sales sales = db.sales.Find(stor_id, ord_num, title_id);

            db.sales.Remove(sales);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult delete(string id)
        {
            sales s = new sales();

            s.sls_id = int.Parse(id);
            s.delete();
            return(RedirectToAction("show"));
        }
Exemple #20
0
        public bool addSaleOrder(sales addedSales)
        {
            if (_salesRepository.Add(addedSales))
            {
                return(true);
            }

            return(false);
        }
        public ActionResult DeleteConfirmed(string id)
        {
            string[] splitid = id.Split(',');
            sales    sales   = db.sales.Find(splitid[0], splitid[1], splitid[2]);

            db.sales.Remove(sales);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #22
0
        static void Tambahdata(List <karyawan> listKaryawan)
        {
            Console.Clear();
            Console.WriteLine("Jenis Karyawan [1. Karyawan Tetap, 2. Karyawan Harian, 3. Sales] : ");
            string pilih = Console.ReadLine();

            if (pilih == "1")
            {
                karyawanTetap karyawanTetap = new karyawanTetap();
                Console.Write("nik : ");
                karyawanTetap.Nik = Console.ReadLine();
                Console.Write("nama : ");
                karyawanTetap.Nama = Console.ReadLine();
                Console.Write("gaji bulanan : ");
                karyawanTetap.GajiBulanan = Convert.ToInt32(Console.ReadLine());

                listKaryawan.Add(karyawanTetap);
                Console.WriteLine("\ndata berhasil ditambahkan\n");
            }
            else if (pilih == "2")
            {
                karyawanHarian karyawanHarian = new karyawanHarian();
                Console.Write("nik : ");
                karyawanHarian.Nik = Console.ReadLine();
                Console.Write("nama : ");
                karyawanHarian.Nama = Console.ReadLine();
                Console.Write("jumlah jam kerja : ");
                karyawanHarian.JumlahJamKerja = Convert.ToInt32(Console.ReadLine());
                Console.Write("upah perjam : ");
                karyawanHarian.UpahPerJam = Convert.ToInt32(Console.ReadLine());

                listKaryawan.Add(karyawanHarian);
                Console.WriteLine("\ndata berhasil ditambahkan\n");
            }
            else if (pilih == "3")
            {
                sales sales = new sales();
                Console.Write("nik : ");
                sales.Nik = Console.ReadLine();
                Console.Write("nama : ");
                sales.Nama = Console.ReadLine();
                Console.Write("jumlah penjualan : ");
                sales.JumlahPenjualan = Convert.ToInt32(Console.ReadLine());
                Console.Write("komisi :");
                sales.Komisi = Convert.ToInt32(Console.ReadLine());

                listKaryawan.Add(sales);
                Console.WriteLine("\ndata berhasil ditambahkan\n");
            }
            else
            {
                Console.WriteLine("\nopsi tidak tersedia\n");
            }
            Console.WriteLine("tekan sembarang untuk kembali ke menu awal...");
            Console.ReadKey();
        }
        public IHttpActionResult AddSales(sales addedSales)
        {
            IRepository <sales> sale_repo = Repos.get_sales_repo();

            if (sale_repo.Add(addedSales))
            {
                return(StatusCode(HttpStatusCode.Created));
            }

            return(StatusCode(HttpStatusCode.NotModified));
        }
Exemple #24
0
 public ActionResult Edit([Bind(Include = "stor_id,ord_num,ord_date,qty,payterms,title_id")] sales sales)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sales).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.stor_id  = new SelectList(db.stores, "stor_id", "stor_name", sales.stor_id);
     ViewBag.title_id = new SelectList(db.titles, "title_id", "title", sales.title_id);
     return(View(sales));
 }
        public ActionResult update(string id)
        {
            ViewBag.i = new SelectList(new invoice().showall(), "in_id", "in_date");
            ViewBag.j = new SelectList(new product().showall(), "prd_id", "prd_name");
            sales s = new sales();

            s.sls_id             = int.Parse(id);
            TempData["sales_id"] = s.sls_id;
            sales ss = s.search();

            return(View(ss));
        }
 public ActionResult Edit([Bind(Include = "Id,custid,bouquetid,purchase_date")] sales sales)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sales).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.bouquetid = new SelectList(db.bouquet, "bouquetid", "name", sales.bouquetid);
     ViewBag.custid    = new SelectList(db.customer, "custid", "first_name", sales.custid);
     return(View(sales));
 }
Exemple #27
0
        protected void getProducts()
        {
            using (sales db = new sales())
            {
                //fills product data to drop down list
                var products = from p in db.Products
                               orderby p.name
                               select p;

                ddlProduct.DataSource = products.ToList();
                ddlProduct.DataBind();
            }
        }
Exemple #28
0
        public void TestShippingCostmet()
        {
            float expected = 12.50f;

            List <SaleLinesItem> productdb = new List <SaleLinesItem>();
            ProductInformatie    product1  = new ProductInformatie("testitem1", "testbeschrijving1", 10.00f, "Fysiek", "");

            productdb.Add(new SaleLinesItem("1", product1));

            sales sale   = new sales();
            float actual = sale.TotalPricecalc(productdb);

            Assert.AreEqual(expected, actual, 0.001, "Verzendkosten zijn er niet bij toegevoegd. test failed");
        }
Exemple #29
0
        // GET: sales/Details/5
        public ActionResult Details(string stor_id, string ord_num, string title_id)
        {
            if (stor_id == null || ord_num == null || title_id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            sales sales = db.sales.Find(stor_id, ord_num, title_id);

            if (sales == null)
            {
                return(HttpNotFound());
            }
            return(View(sales));
        }
        // GET: sales/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            sales sales = db.sales.Find(id);

            if (sales == null)
            {
                return(HttpNotFound());
            }
            return(View(sales));
        }
Exemple #31
0
        public void TestAantalPrijsVerhouding()
        {
            float expected = 30.0f;

            List <SaleLinesItem> productdb = new List <SaleLinesItem>();
            ProductInformatie    product1  = new ProductInformatie("testitem1", "testbeschrijving1", 10.00f, "Digitaal", "");

            productdb.Add(new SaleLinesItem("3", product1));

            sales sale   = new sales();
            float actual = sale.TotalPricecalc(productdb);

            Assert.AreEqual(expected, actual, 0.001, "De prijs is niet keer het aantal producten gedaan. test failed");
        }