コード例 #1
0
        public void addItem(DTO_Product info)
        {
            string[] valss =
            {
                info.Name,
                info.Category.Id.ToString(),
                info.Producer.Id.ToString(),
                info.Origin.Id.ToString(),
                info.Price.ToString()
            };
            DataRow product = dataProduct.getID(valss);

            if (product == null)
            {
                string   timeNow = DateTime.Now.ToString("yyyy-MM-dd");
                string[] val     =
                {
                    timeNow
                };
                DataRow getImport = dataImport.getDate(val);
                if (getImport == null)
                {
                    info.Import.Id = dataImport.InsertID(val);
                }
                else
                {
                    info.Import.Id = Convert.ToInt32(getImport["id"]);
                }
                string[] value =
                {
                    info.Account.Id.ToString(),
                    info.Category.Id.ToString(),
                    info.Producer.Id.ToString(),
                    info.Import.Id.ToString(),
                    info.Origin.Id.ToString(),
                    info.Name,
                    info.Amount.ToString(),
                    info.Price.ToString(),
                    info.WarrantyPeriod.ToString()
                };
                dataProduct.Insert(value);
            }
            else
            {
                int      soluong = Convert.ToInt32(product["amount"]) + info.Amount;
                string[] value   =
                {
                    soluong.ToString(),
                    product["id"].ToString()
                };
                dataProduct.UpdateAmount(value);
            }
        }
コード例 #2
0
ファイル: BUS_Create_Bill.cs プロジェクト: dh19pm/doandotnet
        public void EditAmount(int id, int buy)
        {
            string[] value =
            {
                id.ToString()
            };
            int amount = dataProduct.getAmount(value);

            string[] values =
            {
                (amount - buy).ToString(),
                id.ToString()
            };
            dataProduct.UpdateAmount(values);
        }