Add good list
This commit is contained in:
parent
26c5b72339
commit
e4d1ba38df
@ -28,13 +28,12 @@ public class GoodsController : Controller
|
|||||||
if (
|
if (
|
||||||
string.IsNullOrEmpty(model.Barcode) || model.Barcode.Length > 16
|
string.IsNullOrEmpty(model.Barcode) || model.Barcode.Length > 16
|
||||||
|| string.IsNullOrEmpty(model.Label) || model.Label.Length > 40
|
|| string.IsNullOrEmpty(model.Label) || model.Label.Length > 40
|
||||||
|| model.Price < 0
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return BadRequest();
|
return BadRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.repository.AddGoods(model.Label, model.Barcode, model.Price).ConfigureAwait(false);
|
await this.repository.AddGoods(model.Label, model.Barcode).ConfigureAwait(false);
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,7 @@ public class RecordController : Controller
|
|||||||
if (
|
if (
|
||||||
string.IsNullOrEmpty(model.Barcode) || model.Barcode.Length > 16
|
string.IsNullOrEmpty(model.Barcode) || model.Barcode.Length > 16
|
||||||
|| model.Count < 0
|
|| model.Count < 0
|
||||||
|
|| model.Price < 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return BadRequest();
|
return BadRequest();
|
||||||
@ -44,7 +45,7 @@ public class RecordController : Controller
|
|||||||
int month = from.Month;
|
int month = from.Month;
|
||||||
int day = from.Day;
|
int day = from.Day;
|
||||||
var date = new DateTime(year, month, day);
|
var date = new DateTime(year, month, day);
|
||||||
await this.repository.AddRegister(good.Id, model.Count, date).ConfigureAwait(false);
|
await this.repository.AddRegister(good.Id, model.Count, model.Price, date).ConfigureAwait(false);
|
||||||
|
|
||||||
return RedirectToAction("Register");
|
return RedirectToAction("Register");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,4 @@ public class GoodData
|
|||||||
|
|
||||||
[Column(Name = "label"), StringLength(40)]
|
[Column(Name = "label"), StringLength(40)]
|
||||||
public string Label { get; set; }
|
public string Label { get; set; }
|
||||||
|
|
||||||
[Column(Name = "price")]
|
|
||||||
public int Price { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,9 @@ public class GoodRegisterData
|
|||||||
[Column(Name = "date")]
|
[Column(Name = "date")]
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
|
||||||
|
[Column(Name = "price")]
|
||||||
|
public int Price { get; set; }
|
||||||
|
|
||||||
[Column(Name = "count")]
|
[Column(Name = "count")]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,9 @@ public class RegisterData
|
|||||||
[Column(Name = "date")]
|
[Column(Name = "date")]
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
|
||||||
|
[Column(Name = "price")]
|
||||||
|
public int Price { get; set; }
|
||||||
|
|
||||||
[Column(Name = "count")]
|
[Column(Name = "count")]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,15 +17,13 @@ public class MyRepository
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="label"></param>
|
/// <param name="label"></param>
|
||||||
/// <param name="barcode"></param>
|
/// <param name="barcode"></param>
|
||||||
/// <param name="price"></param>
|
|
||||||
/// <returns>正常終了時、商品IDを返します。</returns>
|
/// <returns>正常終了時、商品IDを返します。</returns>
|
||||||
public async ValueTask<int> AddGoods(string label, string barcode, int price)
|
public async ValueTask<int> AddGoods(string label, string barcode)
|
||||||
{
|
{
|
||||||
GoodData data = new GoodData()
|
GoodData data = new GoodData()
|
||||||
{
|
{
|
||||||
Label = label,
|
Label = label,
|
||||||
Barcode = barcode,
|
Barcode = barcode,
|
||||||
Price = price,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var ret = await this.database.InsertAsync(data).ConfigureAwait(false);
|
var ret = await this.database.InsertAsync(data).ConfigureAwait(false);
|
||||||
@ -74,13 +72,14 @@ public class MyRepository
|
|||||||
/// <param name="count"></param>
|
/// <param name="count"></param>
|
||||||
/// <param name="date"></param>
|
/// <param name="date"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async ValueTask AddRegister(int goodId, int count, DateTime date)
|
public async ValueTask AddRegister(int goodId, int count, int price, DateTime date)
|
||||||
{
|
{
|
||||||
RegisterData data = new RegisterData()
|
RegisterData data = new RegisterData()
|
||||||
{
|
{
|
||||||
GoodId = goodId,
|
GoodId = goodId,
|
||||||
Date = date,
|
Date = date,
|
||||||
Count = count,
|
Count = count,
|
||||||
|
Price = price,
|
||||||
};
|
};
|
||||||
|
|
||||||
await this.database.InsertAsync(data).ConfigureAwait(false);
|
await this.database.InsertAsync(data).ConfigureAwait(false);
|
||||||
@ -89,7 +88,7 @@ public class MyRepository
|
|||||||
public async ValueTask<List<GoodRegisterData>> GetGoodRegisterFromBarcode(string barcode)
|
public async ValueTask<List<GoodRegisterData>> GetGoodRegisterFromBarcode(string barcode)
|
||||||
{
|
{
|
||||||
var ret = await this.database.FetchAsync<GoodRegisterData>(
|
var ret = await this.database.FetchAsync<GoodRegisterData>(
|
||||||
$"SELECT goods.good_id, goods.barcode, goods.label, registers.date, registers.count FROM goods, registers WHERE barcode = {barcode} AND goods.good_id = registers.good_id"
|
$"SELECT goods.good_id, goods.barcode, goods.label, registers.date, registers.price, registers.count FROM goods, registers WHERE barcode = {barcode} AND goods.good_id = registers.good_id"
|
||||||
).ConfigureAwait(false);
|
).ConfigureAwait(false);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@ -9,7 +9,4 @@ public class AddGoodModel
|
|||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string Label { get; set; }
|
public string Label { get; set; }
|
||||||
|
|
||||||
[Required]
|
|
||||||
public int Price { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,9 @@ public class AddUriageModel
|
|||||||
[Required]
|
[Required]
|
||||||
public string Barcode { get; set; }
|
public string Barcode { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int Price { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,14 +22,6 @@
|
|||||||
<input type="text" minlength="0" maxlength="16" required name="Barcode" class="form-control" id="goodBarcode" />
|
<input type="text" minlength="0" maxlength="16" required name="Barcode" class="form-control" id="goodBarcode" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row m-2">
|
|
||||||
<div class="col-md-3">
|
|
||||||
<label class="form-label" for="goodPrice">金額</label>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-9">
|
|
||||||
<input type="number" min="0" required name="Price" class="form-control" id="goodPrice" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group row m-2">
|
<div class="form-group row m-2">
|
||||||
<div class="col-md-9 offset-md-3">
|
<div class="col-md-9 offset-md-3">
|
||||||
<button type="submit" class="btn btn-block btn-outline-primary">登録</button>
|
<button type="submit" class="btn btn-block btn-outline-primary">登録</button>
|
||||||
|
|||||||
@ -12,6 +12,14 @@
|
|||||||
<input type="text" minlength="0" maxlength="16" required name="Barcode" class="form-control" id="goodBarcode" />
|
<input type="text" minlength="0" maxlength="16" required name="Barcode" class="form-control" id="goodBarcode" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group row m-2">
|
||||||
|
<div class="col-md-3">
|
||||||
|
<label class="form-label" for="goodPrice">金額</label>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<input type="number" min="0" required name="Price" class="form-control" id="goodPrice" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group row m-2">
|
<div class="form-group row m-2">
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label class="form-label" for="goodCount">売上個数</label>
|
<label class="form-label" for="goodCount">売上個数</label>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user