Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            purchase           p  = new purchase();
            List <rawmaterial> rs = new List <rawmaterial>();

            rs = p.find_all1();
            Console.Write(rs);
            foreach (rawmaterial r1  in rs)
            {
                Console.Write(r1.Id);
            }
        }
Beispiel #2
0
        public purchase newpurchase(int supplierid, string userid)
        {
            purchase po = new purchase();

            po.supplierId           = supplierid;
            po.purchaseDate         = DateTime.Today.Date;
            po.expectedDeliveryDate = DateTime.Today.Date.AddDays(14);
            po.status = "waiting";
            po.userId = userid;
            ctx.purchases.Add(po);
            ctx.SaveChanges();
            return(po);
        }
        public async Task <ActionResult> Edit([Bind(Include = "username,product,creditcardnumber,dateOfPurchase,dealID")] purchase purchase)
        {
            if (ModelState.IsValid)
            {
                db.Entry(purchase).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.creditcardnumber = new SelectList(db.paymentoptions, "creditcardnumber", "creditcardcompany", purchase.creditcardnumber);
            ViewBag.product          = new SelectList(db.products, "product1", "type", purchase.product);
            ViewBag.username         = new SelectList(db.users, "username", "password", purchase.username);
            return(View(purchase));
        }
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            purchase purchase = await db.purchases.FindAsync(id);

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

            if (purchase == null)
            {
                return(HttpNotFound());
            }
            return(View(purchase));
        }
Beispiel #6
0
 public ActionResult Edit([Bind(Include = "Purchase_Id,Purchase_Name,Product_Id,Company_Id,Category_Id,Purchase_Date,Quantity,Pay_Id")] purchase purchase)
 {
     if (ModelState.IsValid)
     {
         db.Entry(purchase).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Category_Id = new SelectList(db.categories, "Category_Id", "Category_Name", purchase.Category_Id);
     ViewBag.Company_Id  = new SelectList(db.companies, "Company_Id", "Company_Name", purchase.Company_Id);
     ViewBag.Pay_Id      = new SelectList(db.pays, "pay_Id", "Value", purchase.Pay_Id);
     ViewBag.Product_Id  = new SelectList(db.products, "Product_Id", "Product_Name", purchase.Product_Id);
     return(View(purchase));
 }
Beispiel #7
0
        //


        public void formorder(User u)
        {
            var n = from a in ctx.items
                    where (a.balance < a.reorderlevel) && (a.status == "stockout")
                    from c in ctx.item_supplier
                    where a.itemId == c.itemId
                    from b in ctx.suppliers
                    where b.supplierId == c.supplierId && (c.priority == 1)
                    select b;
            var d = from a in ctx.items
                    where (a.balance < a.reorderlevel) && (a.status == "stockout")
                    from c in ctx.item_supplier
                    where a.itemId == c.itemId
                    from b in ctx.suppliers
                    where b.supplierId == c.supplierId && (c.priority == 1)
                    select c;
            List <supplier>      s  = n.ToList();
            List <item_supplier> ls = d.ToList();

            foreach (supplier x in s)
            {
                purchase po = new purchase();
                po.supplierId           = x.supplierId;
                po.purchaseDate         = DateTime.Today.Date;
                po.userId               = u.UserId;
                po.expectedDeliveryDate = DateTime.Today.Date.AddDays(14);
                po.status               = "waiting";
                ctx.purchases.Add(po);
                ctx.SaveChanges();
                foreach (item_supplier i in ls)
                {
                    if (i.supplierId == x.supplierId)
                    {
                        var y = from a in ctx.items
                                where a.itemId == i.itemId
                                select a;
                        item item = y.SingleOrDefault();
                        item.status = "ordering";
                        purchase_item pitem = new purchase_item();
                        pitem.purchaseId = po.purchaserId;
                        pitem.itemId     = i.itemId.Value;
                        pitem.requestQty = item.reorderlevel;
                        pitem.supplierid = po.supplierId;
                        ctx.purchase_item.Add(pitem);
                        ctx.SaveChanges();
                    }
                }
            }
        }
Beispiel #8
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (!filledValues())
            {
                //MessageBox.Show("Complete la información");
            }
            else
            {
                //serviceDA = new DBControllerWSClient();
                purchase p = new purchase();
                p.state         = 1;
                p.serialCode    = txtSerialCode.Text;
                p.totalPurchase = float.Parse(txtTotal.Text);
                //para el supplier
                supplier c = new supplier();
                serviceDA  = new DBControllerWSClient();
                c          = serviceDA.querySupplierByCode(txtIdProv.Text);
                p.supplier = c;
                //para los purchase lanes
                purchaseLane[] salelanes;
                salelanes = new purchaseLane[dgvPurchaseDetails.RowCount - 1];
                for (int i = 0; i < dgvPurchaseDetails.RowCount - 1; i++)
                {
                    purchaseLane purchaselane = new purchaseLane();
                    purchaselane.subtotal = float.Parse(dgvPurchaseDetails.Rows[i].Cells[4].Value.ToString());
                    purchaselane.quantity = int.Parse(dgvPurchaseDetails.Rows[i].Cells[3].Value.ToString());
                    //purchaselane.purchase = p;
                    product pr = new product();
                    pr = serviceDA.queryProductBySKUCode(dgvPurchaseDetails.Rows[i].Cells[0].Value.ToString());
                    purchaselane.product = pr;
                    salelanes[i]         = purchaselane;
                }
                p.currency      = "Soles";
                p.purchaseLanes = salelanes;
                //Cursor.Current = Cursors.WaitCursor;
                int salio = serviceDA.insertPurchase(p);
                if (salio == 1)
                {
                    MessageBox.Show("Se ingresó la compra correctamente");
                }
                else
                {
                    MessageBox.Show("¡Hubo un problema!");
                }
                //Cursor.Current = Cursors.Arrow;

                this.Close();
            }
        }
 protected void Confirm_Click(object sender, EventArgs e)
 {
     try
     {
         purchase s           = (purchase)Session["purchaseitem"];
         string   description = Itemchoose.SelectedValue;
         int      itemcode    = pl.finditemcode(description, s.supplierId);
         int      qt          = Convert.ToInt32(itemnumber.Text);
         pl.additems(itemcode, s.supplierId, s.purchaserId, qt);
         Response.Redirect("Purchaseitems.aspx");
     }
     catch
     {
         s.Text = "Number Validation not Pass!";
     }
 }
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            User   u        = (User)Session["UserEntity"];
            int    itemcode = Convert.ToInt32(e.CommandArgument);
            string k        = GridView1.Rows[itemcode].Cells[1].Text;
            string l        = GridView1.Rows[itemcode].Cells[3].Text;

            itemcode = Convert.ToInt32(k);
            int      quantity   = Convert.ToInt32(l);
            int      supplierid = pl.findsupplier(itemcode);
            purchase s          = pl.newpurhcase(supplierid, u.UserId);

            pl.additems(itemcode, supplierid, s.purchaserId, quantity);
            Session["purchaseitem"] = s;
            Response.Redirect("Purchaseitems.aspx");
        }
Beispiel #11
0
        // GET: purchases/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            purchase purchase = db.purchases.Find(id);

            if (purchase == null)
            {
                return(HttpNotFound());
            }
            ViewBag.client_id  = new SelectList(db.clients, "id", "firstname", purchase.client_id);
            ViewBag.product_id = new SelectList(db.products, "id", "name", purchase.product_id);
            return(View(purchase));
        }
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            purchase purchase = await db.purchases.FindAsync(id);

            if (purchase == null)
            {
                return(HttpNotFound());
            }
            ViewBag.creditcardnumber = new SelectList(db.paymentoptions, "creditcardnumber", "creditcardcompany", purchase.creditcardnumber);
            ViewBag.product          = new SelectList(db.products, "product1", "type", purchase.product);
            ViewBag.username         = new SelectList(db.users, "username", "password", purchase.username);
            return(View(purchase));
        }
Beispiel #13
0
        public ActionResult Create([Bind(Include = "id,client_id,product_id,count")] purchase purchase)
        {
            if (ModelState.IsValid)
            {
                purchase.date = DateTime.Now;
                product p = db.products.Find(purchase.product_id);
                purchase.productname  = p.name;
                purchase.productprice = p.price;
                db.purchases.Add(purchase);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.client_id  = new SelectList(db.clients, "id", "firstname", purchase.client_id);
            ViewBag.product_id = new SelectList(db.products, "id", "name", purchase.product_id);
            return(View(purchase));
        }
        public async Task <ActionResult> BuyCart(int paymentoptions)
        {
            string result = "";

            if (ModelState.IsValid)
            {
                List <product> cartItems = (List <AlexMichaelProject.Models.product>)Session["cart"];
                string         username  = (string)Session["username"];
                for (int i = 0; i < cartItems.Count; i++)
                {
                    int      j    = 0;
                    purchase temp = new purchase();
                    temp.username         = username;
                    temp.product          = cartItems.ElementAt(i).product1;
                    temp.creditcardnumber = paymentoptions;
                    temp.dateOfPurchase   = DateTime.Today;
                    Boolean flag = false;
                    while (flag == false)
                    {
                        purchase test = new purchase();
                        test = await db.purchases.FindAsync(j);

                        if (test == null)
                        {
                            flag = true;
                        }
                        else
                        {
                            j++;
                        }
                    }
                    temp.dealID = j;
                    db.purchases.Add(temp);
                }
                Session["cart"] = null;
                Session.Remove("cart");
                Session.Remove("cartsize");
                int zero = 0;
                Session["cartsize"] = zero;
                await db.SaveChangesAsync();

                result = "true";
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #15
0
        // GET: purchases/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            purchase purchase = db.purchases.Find(id);

            if (purchase == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Category_Id = new SelectList(db.categories, "Category_Id", "Category_Name", purchase.Category_Id);
            ViewBag.Company_Id  = new SelectList(db.companies, "Company_Id", "Company_Name", purchase.Company_Id);
            ViewBag.Pay_Id      = new SelectList(db.pays, "pay_Id", "Value", purchase.Pay_Id);
            ViewBag.Product_Id  = new SelectList(db.products, "Product_Id", "Product_Name", purchase.Product_Id);
            return(View(purchase));
        }
Beispiel #16
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO:  这行代码将数据加载到表“lemonDataSet.supplier”中。您可以根据需要移动或删除它。
            //panel1.Visible = false;
            //自动生成单据
            purchase p = new purchase();
            int      P_Int_newBillCode = p.selectMaxdanjuid() + 1;//记录单据编号中的数字码

            textBox1.Text = DateTime.Now.ToString("yyyyMMdd") + "HappyLemon" + P_Int_newBillCode;



            rawmaterial    r1  = new rawmaterial();
            rawmaterialdao dao = new rawmaterialdao();

            //int index=this.purchaseTable.Rows.Add();
            //Console.Write(number1[0]);
            if (number1 == null)
            {
            }
            else
            {
                foreach (string i in number1)
                {
                    r1 = dao.selectNumber(i);
                    if (r1 == null)
                    {
                    }
                    else
                    {
                        int index = this.dataGridView1.Rows.Add();
                        this.dataGridView1.Rows[index].Cells[0].Value = r1.Rawmaterial_number;
                        this.dataGridView1.Rows[index].Cells[1].Value = r1.Rawmaterial_name;
                        this.dataGridView1.Rows[index].Cells[3].Value = r1.Rawmaterial_unit;
                    }
                }
            }
            dataGridView1.Focus(); //使表格获得鼠标焦点
            supplier_text.Focus(); //使供应商文本框成为焦点


            //datagridview2
        }
Beispiel #17
0
        private void btnAddPRoduct_Click(object sender, EventArgs e)
        {
            CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
            TextInfo    textInfo    = cultureInfo.TextInfo;

            if (string.IsNullOrWhiteSpace(txtProductName.Text) || string.IsNullOrWhiteSpace(txtProductFeatures.Text) || string.IsNullOrWhiteSpace(txtPrice.Text) || string.IsNullOrWhiteSpace(datePurchasedDate.Text))
            {
                MessageBox.Show("You must fill in the required fields");
                return;
            }
            if (txtPiece.Text == "0")
            {
                MessageBox.Show("You need to write minimum 1 for pieces");
                return;
            }
            if (int.Parse(txtPrice.Text) < 0)
            {
                MessageBox.Show("You need to write positive value for price");
                return;
            }

            //Change To Upper Case First Letter
            txtProductName.Text = textInfo.ToTitleCase(txtProductName.Text.ToLower());
            txtProductName.Select(txtProductName.Text.Length, 0);

            txtProductFeatures.Text = textInfo.ToTitleCase(txtProductFeatures.Text.ToLower());
            txtProductFeatures.Select(txtProductFeatures.Text.Length, 0);


            //TODO:KULLAN BUNU int addedBy = 1;
            product  p    = new product();
            purchase purc = new purchase();

            p.productName      = txtProductName.Text;
            p.productFeatures  = txtProductFeatures.Text;
            purc.purchasedDate = datePurchasedDate.Text;
            p.pieces           = int.Parse(txtPiece.Text);
            purc.purchasedByID = userID;
            purc.purchasePrice = int.Parse(txtPrice.Text);

            Controller.ProductController.addProduct(p, purc);
        }
Beispiel #18
0
        public List <Purchaseitem111> showpurchaseitems(purchase p)
        {
            int x1 = p.purchaserId;
            var n  = from a in ctx.items
                     from b in ctx.purchase_item
                     from z in ctx.purchases
                     from c in ctx.item_supplier
                     from y in ctx.suppliers
                     where a.itemId == b.itemId && b.purchaseId == z.purchaserId && a.itemId == c.itemId && c.supplierId == y.supplierId && z.purchaserId == p.purchaserId && b.supplierid == y.supplierId
                     select new Purchaseitem111
            {
                Itemcode    = a.itemId,
                Description = a.description,
                Quantity    = b.requestQty,
                price       = c.price.Value,
                Amount      = c.price.Value * b.requestQty
            };

            return(n.ToList());
        }
Beispiel #19
0
        public ActionResult Create(PurchaseModel model)
        {
            purchase info              = model.info;
            String   invitees          = model.invitees;
            String   invitationContent = model.invitationContent;

            info.companyId     = (Int32)Session["user_id"];
            info.purchase_time = DateTime.Now;
            if (Utility.CheckSession(UserType.Company, Session))
            {
                var result = CreateRecord <purchase>(info);
                if (result.first)
                {
                    var inviteesList = invitees.Split(',').Distinct().ToList();
                    CreateInvitation(result.second.purchaseId, invitationContent, inviteesList);
                    return(RedirectToAction("Detail", new { id = result.second.purchaseId }));
                }
            }
            return(RedirectToAction("Home", "Company"));
        }
Beispiel #20
0
        public void confirmorder(int s)
        {
            var n = from a in ctx.purchase_item
                    from b in ctx.items
                    where (a.itemId == b.itemId) && (a.purchaseId == s)
                    select b;
            var x = from a in ctx.purchases
                    where a.purchaserId == s
                    select a;
            var w = from a in ctx.purchase_item
                    from b in ctx.items
                    where (a.itemId == b.itemId) && (a.purchaseId == s)
                    select a;

            foreach (item t in n.ToList())
            {
                foreach (purchase_item pt in w.ToList())
                {
                    if (t.itemId == pt.itemId)
                    {
                        t.balance += pt.requestQty;
                        t.status   = "sufficient";
                    }
                }
            }
            purchase o = x.SingleOrDefault();

            o.status = "Confirmed";
            ctx.SaveChanges();


            var purchaseitemlist = (from x1 in ctx.purchases
                                    from y1 in ctx.purchase_item
                                    from z1 in ctx.items
                                    where x1.purchaserId == s && x1.purchaserId == y1.purchaseId && z1.itemId == y1.itemId
                                    select z1).ToList();

            revalidationForReq(purchaseitemlist);
        }
Beispiel #21
0
        private void btnRemoveProduct_Click(object sender, EventArgs e)
        {
            CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
            TextInfo    textInfo    = cultureInfo.TextInfo;

            //Change To Upper Case First Letter
            txtProductName.Text = textInfo.ToTitleCase(txtProductName.Text.ToLower());
            txtProductName.Select(txtProductName.Text.Length, 0);

            txtProductFeatures.Text = textInfo.ToTitleCase(txtProductFeatures.Text.ToLower());
            txtProductFeatures.Select(txtProductFeatures.Text.Length, 0);

            if (string.IsNullOrWhiteSpace(txtProductName.Text) || string.IsNullOrWhiteSpace(txtProductFeatures.Text))
            {
                MessageBox.Show("You must fill in the required fields");
                return;
            }
            if (txtPiece.Text == "0" || txtPiece.Text == "")
            {
                MessageBox.Show("You need to write minimum 1 for number.");
                return;
            }
            var result = productList.Find(x => x.productName == cbProducts.SelectedItem.ToString());

            product p = new product();

            p.productID       = result.productID;
            p.productName     = txtProductName.Text;
            p.productFeatures = txtProductFeatures.Text;
            purchase purc = new purchase();

            purc.purchasePrice = int.Parse(txtPiece.Text);

            //Call editProduct method from controller
            Controller.ProductController.editProduct(purc, p);
            txtPiece.Text = "";
        }
Beispiel #22
0
        public void changesupplier(int itemcode, int purchaseid, string comname, string userid)
        {
            var n = from a in ctx.purchase_item
                    from b in ctx.purchases
                    where (a.itemId == itemcode) && (b.purchaserId == purchaseid) &&
                    (a.purchaseId == b.purchaserId)
                    select a;
            purchase_item pt = n.SingleOrDefault();
            int           x  = pt.itemId;

            ctx.purchase_item.Remove(pt);
            var l = from a in ctx.suppliers
                    where a.compName == comname
                    select a.supplierId;
            int      ls = l.FirstOrDefault();
            purchase po = new purchase();

            po.supplierId           = ls;
            po.purchaseDate         = DateTime.Today.Date;
            po.expectedDeliveryDate = DateTime.Today.Date.AddDays(14);
            po.status = "waiting";
            po.userId = userid;
            ctx.purchases.Add(po);
            var xo = from a in ctx.items
                     where a.itemId == x
                     select a;
            item          xx  = xo.SingleOrDefault();
            purchase_item npt = new purchase_item();

            npt.purchaseId = po.purchaserId;
            npt.itemId     = xx.itemId;
            npt.requestQty = xx.reorderQty;
            npt.supplierid = ls;
            ctx.purchase_item.Add(npt);
            ctx.SaveChanges();
        }
Beispiel #23
0
        public IHttpActionResult Putpurchase(int id, purchase purchase)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != purchase.id)
            {
                return(BadRequest());
            }
            //custom fix for error message in EntityState.Modified;
            foreach (participants p in purchase.participants)
            {
                p.group_members = null;
            }
            db.Entry(purchase).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!purchaseExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #24
0
 public void newpurchase()
 {
     purchase p = poFacade.newpurchase(1, "u005");
 }
Beispiel #25
0
        public ActionResult create(purchaseVM pvm)
        {
            decimal total_amount = 0;

            if (pvm != null && pvm.product_id.Count() != 0)
            {
                purchase p = new purchase();
                p.supplier_id  = pvm.supplier_id;
                p.warehouse_id = pvm.warehouse_id;
                p.total_amount = pvm.total_amount;
                p.create_date  = DateTime.Now;
                db.purchases.Add(p);
                db.SaveChanges();

                //get the purchas id
                var id = db.purchases.Find(p.purchase_id);

                //create purchase invoice
                id.pInv = "#PINV-" + id.purchase_id + id.supplier_id;
                //save all data in purchasse detiels page
                purchase_details purchaseDetails = new purchase_details();
                for (int i = 0; i < pvm.product_id.Count(); i++)
                {
                    purchaseDetails.product_id     = pvm.product_id[i];
                    purchaseDetails.quantity       = pvm.quantity[i];
                    purchaseDetails.purchase_price = pvm.bayPrice[i];
                    purchaseDetails.sale_price     = pvm.salePrice[i];
                    purchaseDetails.purchase_id    = id.purchase_id;
                    purchaseDetails.sku            = "SKU=" + purchaseDetails.product_id + "-" + purchaseDetails.purchase_id;
                    db.purchase_details.Add(purchaseDetails);
                    db.SaveChanges();

                    //samition the total price
                    total_amount += Convert.ToDecimal(purchaseDetails.purchase_price);
                    //update every product colams
                    var pro = db.product_tbl.Find(purchaseDetails.product_id);

                    //first create itemladger
                    ItemladgerController ic = new ItemladgerController();
                    ic.ladgerItem(Convert.ToInt32(pro.product_id), Convert.ToInt32(purchaseDetails.quantity), "in", Convert.ToInt32(p.warehouse_id), Convert.ToString(id.pInv));

                    pro.quantity += purchaseDetails.quantity;
                    pro.price     = purchaseDetails.sale_price;

                    db.Entry(pro).State = EntityState.Modified;
                    db.SaveChanges();
                }


                //save the total price in
                id.total_amount    = total_amount;
                db.Entry(id).State = EntityState.Modified;
                db.SaveChanges();


                message = " Purchase Created Is Successfully";
                status  = true;

                TempData["Message"] = message;
                TempData["Status"]  = status;

                return(RedirectToAction("purchaseInvoice", new { id = id.purchase_id }));
            }
            else
            {
                message = "There Are Some Problems";
            }

            TempData["Message"] = message;
            TempData["Status"]  = status;

            return(RedirectToAction("create"));
        }
Beispiel #26
0
        private void UbahTSB_Click(object sender, EventArgs e)
        {
            // save purchase Header
            purchase k = new purchase();

            k.PONO       = txtPONO.Text;
            k.CURRENCYID = cbCurrency.Text;
            k.DELIVERYTO = txtDeliveryTo.Text;
            // DataRow selectedDataRow = ((DataRowView)cbTypeID.SelectedItem).Row;
            // k.TYPEID = selectedDataRow["TYPEID"].ToString();
            DataRow selectedDIV = ((DataRowView)cbDIV.SelectedItem).Row;

            k.GDIV              = selectedDIV["DIVID"].ToString();
            k.CUSTVENDID        = txtCustomerID.Text;
            k.DELIVERYTO        = txtDeliveryTo.Text;
            k.DELIVERYTOADDRESS = txtAddress.Text;

            //k.ACKNOWLEDGEMENT =
            //k.ACKNOWLEDGEMENTBY=
            //k.ACKNOWLEDGEMENTDATE=
            //k.APPROVE=
            //k.APPROVEBY=
            //k.APPROVEDATE=
            //k.CHECKBY=
            //k.CHECKDATE=
            //k.CHECKED=
            //k.CLOSE=
            k.CURRENCYID        = cbCurrency.Text;
            k.CUSTVENDID        = txtCustomerID.Text;
            k.DATE              = dateCreated.Value;
            k.DELIVERYTO        = txtDeliveryTo.Text;
            k.DELIVERYTOADDRESS = txtAddress.Text;
            k.DELIVERYTONAME    = txtRefer.Text;
            k.DUEDATE           = dateDue.Value;
            k.ETA = dateETA.Value;
            k.ETD = dateETD.Value;
            // k.PPN = (float)Convert.ToDouble(txtPPN.Text);
            k.KURS = (float)Convert.ToDouble(txtKurs.Text);
            //k.GDIV=cbDIV.Text;
            //k.NONREQ=
            k.NOTE = txtRemarks.Text;
            //k.OFFICER=GOFFICER
            //k.PONO=
            k.REFERTO = txtRefer.Text;
            k.REMARKS = txtRemarks.Text;
            //k.REVISE=
            //k.REVISEBY=
            //k.REVISEDATE=
            //k.REVISEDUEDATE=
            k.SHIPMODA      = cbCourier.Text;
            k.TERMOFPAYMENT = cbTerms.Text;
            //k.TOTALAMOUNT=
            //k.TOTALDISCOUNT=
            //k.TOTALPAID=
            //k.TOTALPPN=
            //k.TOTALUPCHARGES=
            //k.DELIVERYTOADDRESS=txta

            if ((cbDIV.Text == "") || (txtCustomerID.Text == ""))
            {
                MessageBox.Show("Isian Belum lengkap,silahkan di lengkapi");
            }
            else if (new purchaseCRUD().updateData(k))
            {
                purchasedetail d = new purchasedetail();
                //dtGrid.BeginEdit(true);
                //dtGrid.Refresh();
                dtGrid.EndEdit();
                for (int i = 0; i < dtGrid.Rows.Count - 1; i++)
                {
                    d.PONO = txtPONO.Text;

                    d.ID        = Convert.ToInt32(dtGrid.Rows[i].Cells["hID"].Value); //i+1;//Convert.ToInt32(dtGrid.Rows[i].Cells["hCostingID"].Value);
                    d.COSTINGNO = dtGrid.Rows[i].Cells["hCostingNo"].Value.ToString();
                    d.COSTINGID = Convert.ToInt32(dtGrid.Rows[i].Cells["hCostingID"].Value);

                    // d.COSTINGDESC=dtGrid.Rows[i].Cells["hCostingID"].tr
                    //d.COSTINGDESC=
                    //d.MATERIALTYPEID=
                    d.ITEMSID       = dtGrid.Rows[i].Cells["hItemsID"].Value == null ? null : dtGrid.Rows[i].Cells["hItemsID"].Value.ToString();
                    d.DESCRIPTION   = dtGrid.Rows[i].Cells["hDescription"].Value == null?null:dtGrid.Rows[i].Cells["hDescription"].Value.ToString().ToString();
                    d.QUANTITY      = (float)Convert.ToDouble(dtGrid.Rows[i].Cells["hQuantity"].Value);
                    d.UOM           = dtGrid.Rows[i].Cells["hUOM"].Value == null ? null : dtGrid.Rows[i].Cells["hUOM"].Value.ToString();
                    d.PRICE         = (float)Convert.ToDouble(dtGrid.Rows[i].Cells["hPrice"].Value);
                    d.CONVER        = (float)Convert.ToDouble(dtGrid.Rows[i].Cells["hConvert"].Value);
                    d.QTYPURCHASE   = (float)Convert.ToDouble(dtGrid.Rows[i].Cells["hQtyPurchase"].Value);
                    d.UOMPURCHASE   = dtGrid.Rows[i].Cells["hUOMPurchase"].Value == null?null:dtGrid.Rows[i].Cells["hUOMPurchase"].Value.ToString();
                    d.PRICEPURCHASE = (float)Convert.ToDouble(dtGrid.Rows[i].Cells["hPricePurchase"].Value);
                    //d.TOTAL = (float)Convert.ToDouble(dtGrid.Rows[i].Cells["hTotal"].Value);
                    d.CURRENCYID = dtGrid.Rows[i].Cells["hCurrency"].Value == null ? null : dtGrid.Rows[i].Cells["hCurrency"].Value.ToString();
                    // d.DISCOUNT = (float)Convert.ToDouble(txtDiscount.Text);
                    // d.PPN = (float)Convert.ToDouble(txtPPN.Text);
                    d.KURS       = (float)Convert.ToDouble(txtKurs.Text);
                    d.CURRENCYID = cbCurrency.SelectedValue.ToString();

                    //d.ITEMSID=
                    //d.COSTINGDESC=txtPONO.Text;
                    //d.COSTINGNO=txtPONO.Text;
                    //d.CURRENCYID=txtPONO.Text;
                    if (dtGrid.Rows[i].HeaderCell.Value.ToString() == "#")
                    {
                        d.ID = i + 1;
                        if (new purchasedetailCRUD().insertData(d))
                        {
                            // MessageBox.Show("Data berhasil di tambahkan");
                            // Binding();
                            dtGrid.Rows[i].HeaderCell.Value = "V";
                        }
                        else
                        { //insert
                        }
                    }
                    else //if (dtGrid.Rows[i].HeaderCell.Value.ToString() == "E")
                    {
                        //update
                        if (new purchasedetailCRUD().updateData(d))
                        {
                            // MessageBox.Show("Data berhasil di tambahkan");
                            dtGrid.Rows[i].HeaderCell.Value = "V";
                        }
                        else
                        {
                            MessageBox.Show("Data gagal update");
                            //dtGrid.Rows[i].Cells["Check"].Value = "ER";
                            // dtGrid.Rows[i].HeaderCell.Value = "X";
                        }
                    }
                }
                MessageBox.Show("Data berhasil di update");
                SimpanTSB.Enabled = false;
            }
            else
            {
                MessageBox.Show("Data gagal update");
            }
        }
Beispiel #27
0
        private void SimpanTSB_Click(object sender, EventArgs e)
        {
            // save purchase Header
            purchase k   = new purchase();
            Generate gen = new Generate();

            txtPONO.Text = gen.genPONO();
            k.PONO       = txtPONO.Text;
            k.DATE       = dateCreated.Value;
            k.CURRENCYID = cbCurrency.Text;
            k.KURS       = (float)Convert.ToDouble(txtKurs.Text);
            // k.PPN = (float)Convert.ToDouble(txtPPN.Text);
            //k.pp
            // DataRow selectedDataRow = ((DataRowView)cbTypeID.SelectedItem).Row;
            // k.TYPEID = selectedDataRow["TYPEID"].ToString();
            DataRow selectedDIV = ((DataRowView)cbDIV.SelectedItem).Row;

            k.GDIV              = selectedDIV["DIVID"].ToString();
            k.CUSTVENDID        = txtCustomerID.Text;
            k.DELIVERYTO        = txtDeliveryTo.Text;
            k.DELIVERYTOADDRESS = txtAddress.Text;

            //k.ACKNOWLEDGEMENT =
            //k.ACKNOWLEDGEMENTBY=
            //k.ACKNOWLEDGEMENTDATE=
            //  k.APPROVE=
            // k.APPROVEBY=
            //  k.APPROVEDATE=
            // k.CHECKBY=
            //k.CHECKDATE=
            //k.CHECKED=
            //k.CLOSE=
            k.CURRENCYID        = cbCurrency.Text;
            k.CUSTVENDID        = txtCustomerID.Text;
            k.DATE              = dateCreated.Value;
            k.DELIVERYTOADDRESS = txtAddress.Text;
            k.DELIVERYTONAME    = txtRefer.Text;
            k.DUEDATE           = dateDue.Value;
            k.ETA  = dateETA.Value;
            k.ETD  = dateETD.Value;
            k.GDIV = cbDIV.SelectedValue.ToString();
            //k.NONREQ=
            k.NOTE = txtRemarks.Text;
            //k.OFFICER=GOFFIC
            //k.PONO=
            k.REFERTO = txtRefer.Text;
            k.REMARKS = txtRemarks.Text;
            //k.REVISE=
            //k.REVISEBY=
            //k.REVISEDATE=
            //k.REVISEDUEDATE=
            k.SHIPMODA = cbCourier.Text;
            //k.TERMOFPAYMENT=cbt
            //k.TOTALAMOUNT=
            //k.TOTALDISCOUNT=
            //k.TOTALPAID=
            //k.TOTALPPN=
            //k.TOTALUPCHARGES=
            //k.DELIVERYTOADDRESS=txta
            k.OFFICER = GlobalVariables.GUserID;

            if ((cbDIV.Text == "") || (txtCustomerID.Text == ""))
            {
                MessageBox.Show("Isian Belum lengkap,silahkan di lengkapi");
            }
            else if (new purchaseCRUD().insertData(k))
            {
                MessageBox.Show("Data berhasil di tambahkan");
                SimpanTSB.Enabled = false;
                UbahTSB.Enabled   = true;
                dtGrid.Enabled    = true;

                // Binding();
            }
            else
            {
                MessageBox.Show("Data gagal ditambahkan");
            }
        }
Beispiel #28
0
        public void findpurchaseorder()
        {
            purchase p = poFacade.findpurchaseorder(1);

            Assert.IsNotNull(p);
        }
        private void button4_Click(object sender, EventArgs e)
        {
            bool b = true;

            if (dataGridView1.Rows.Count == 1)
            {
                MessageBox.Show("请填写信息");
                b = false;
            }
            else
            {
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    if (dataGridView1.Rows[i].Cells[0].Value == null)
                    {
                        MessageBox.Show("编号不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[1].Value == null)
                    {
                        MessageBox.Show("商品名称不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[3].Value == null)
                    {
                        MessageBox.Show("单位不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[4].Value == null)
                    {
                        MessageBox.Show("数量不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[5].Value == null)
                    {
                        MessageBox.Show("单价不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[6].Value == null)
                    {
                        MessageBox.Show("金额不能为空");
                        b = false;
                    }
                    else if (supplier_text.Text == "")
                    {
                        MessageBox.Show("请选择供应商");
                        b = false;
                    }
                }
            }
            if (b == false)
            {
            }
            else
            {
                purchase dao = new purchase();
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    purchase_material p = new purchase_material();
                    Console.Write(dataGridView1.Rows[i].Cells[0].Value + "lallalalaalalalalalalla");
                    p.RawMaterial_number = dataGridView1.Rows[i].Cells[0].Value.ToString();
                    p.Suppliernumber     = supplier_text.Text;
                    p.Dan_date           = Convert.ToDateTime(dateTimePicker1.Text);

                    p.Unit  = dataGridView1.Rows[i].Cells[3].Value.ToString();
                    p.Count = Convert.ToDouble(dataGridView1.Rows[i].Cells[4].Value);
                    p.Price = Convert.ToDouble(dataGridView1.Rows[i].Cells[5].Value);
                    p.Money = Convert.ToDouble(dataGridView1.Rows[i].Cells[6].Value);
                    if (dataGridView1.Rows[i].Cells[7].Value == null)
                    {
                        p.Remark = " ";
                    }
                    else
                    {
                        p.Remark = dataGridView1.Rows[i].Cells[7].Value.ToString();
                    }
                    p.Status = 1;
                    dao.addpurchase(p);
                }
                MessageBox.Show("保存成功");
            }
        }
        private void button4_Click_1(object sender, EventArgs e)
        {
            bool b = true;

            if (dataGridView1.Rows.Count == 1)
            {
                MessageBox.Show("请填写信息");
                b = false;
            }
            else
            {
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    if (dataGridView1.Rows[i].Cells[0].Value == null)
                    {
                        MessageBox.Show("编号不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[1].Value == null)
                    {
                        MessageBox.Show("商品名称不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[3].Value == null)
                    {
                        MessageBox.Show("单位不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[4].Value == null)
                    {
                        MessageBox.Show("数量不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[5].Value == null)
                    {
                        MessageBox.Show("单价不能为空");
                        b = false;
                    }
                    else if (dataGridView1.Rows[i].Cells[6].Value == null)
                    {
                        MessageBox.Show("金额不能为空");
                        b = false;
                    }
                    else if (textBox1.Text == "")
                    {
                        MessageBox.Show("请选择供应商");
                        b = false;
                    }
                    else if (textBox3.Text == "")
                    {
                        MessageBox.Show("操作人不能为空!");
                    }
                }
            }
            if (b == false)
            {
            }
            else
            {
                MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
                DialogResult      dr         = MessageBox.Show("是否确认保存?", "提交", messButton);
                if (dr == DialogResult.OK)
                {
                    string[] supplier = supplier_text.Text.Split(' ');
                    string[] employer = textBox3.Text.Split(' ');
                    try
                    {
                        purchase dao = new purchase();
                        double   mm  = Convert.ToDouble(label9.Text);
                        dao.addDanju(Convert.ToDateTime(dateTimePicker1.Text), textBox1.Text, employer[0], mm, textBox4.Text, supplier[0], 1);

                        for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                        {
                            purchase_material p = new purchase_material();
                            Console.Write(dataGridView1.Rows[i].Cells[0].Value + "lallalalaalalalalalalla");
                            p.RawMaterial_number = dataGridView1.Rows[i].Cells[0].Value.ToString();
                            p.Suppliernumber     = supplier[0];
                            p.Dan_date           = Convert.ToDateTime(dateTimePicker1.Text);
                            Console.Write("这是一个人" + p.Suppliernumber + "这是一个人");
                            p.Unit  = dataGridView1.Rows[i].Cells[3].Value.ToString();
                            p.Count = Convert.ToDouble(dataGridView1.Rows[i].Cells[4].Value);
                            p.Price = Convert.ToDouble(dataGridView1.Rows[i].Cells[5].Value);
                            //Console.Write("这是一个人" + p.Price + "这是一个人");
                            p.Money = Convert.ToDouble(dataGridView1.Rows[i].Cells[6].Value);
                            if (dataGridView1.Rows[i].Cells[7].Value == null)
                            {
                                p.Remark = "";
                            }
                            else
                            {
                                p.Remark = dataGridView1.Rows[i].Cells[7].Value.ToString();
                            }

                            p.Status   = 1;
                            p.Danju_id = textBox1.Text;
                            // Console.Write("这是一个人" + p.Danju_id + "这是一个人");
                            dao.addpurchase(p);
                        }
                        MessageBox.Show("保存成功");
                    }
                    catch (SystemException)
                    {
                        MessageBox.Show("操作有误");
                    }
                }
                else
                {
                }
            }
        }