Forms
This commit is contained in:
parent
30ba4972f9
commit
4add59d1f6
@ -1,6 +1,8 @@
|
||||
namespace SushiBarContracts.BindingModels
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
namespace SushiBarContracts.BindingModels
|
||||
{
|
||||
public class DishBindingModel
|
||||
public class DishBindingModel : IDishModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@ -8,6 +10,8 @@
|
||||
|
||||
public string Category { get; set;} = string.Empty;
|
||||
|
||||
public List<DishIngredientBindingModel> Ingredients { get; set; } = new();
|
||||
public double Price { get; set; }
|
||||
|
||||
public Dictionary<int, (IIngredientModel, int)> DishIngredients { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
namespace SushiBarContracts.BindingModels
|
||||
{
|
||||
public class DishIngredientBindingModel
|
||||
{
|
||||
public int IngredientId { get; set; }
|
||||
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
namespace SushiBarContracts.BindingModels
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
namespace SushiBarContracts.BindingModels
|
||||
{
|
||||
public class IngredientBindingModel
|
||||
public class IngredientBindingModel : IIngredientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
|
@ -6,4 +6,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SushiBarDataModels\SushiBarDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -11,6 +11,8 @@ namespace SushiBarContracts.ViewModels
|
||||
[DisplayName("Название блюда")]
|
||||
public string DishName { get; set; } = string.Empty;
|
||||
|
||||
public double DishPrice { get; set; }
|
||||
|
||||
public int CookId { get; set; }
|
||||
|
||||
[DisplayName("Повар")]
|
||||
|
@ -4,6 +4,7 @@ namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
public class ChequeViewModel
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
|
||||
public int? CustomerId { get; set; }
|
||||
|
@ -1,17 +0,0 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
public class DishIngredientViewModel
|
||||
{
|
||||
public int DishId { get; set; }
|
||||
|
||||
public int IngredientId { get; set; }
|
||||
|
||||
[DisplayName("Наименование ингредиента")]
|
||||
public string IngredientName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
using System.ComponentModel;
|
||||
using SushiBarDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
public class DishViewModel
|
||||
public class DishViewModel : IDishModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@ -12,6 +13,9 @@ namespace SushiBarContracts.ViewModels
|
||||
[DisplayName("Категория")]
|
||||
public string Category { get; set; } = string.Empty;
|
||||
|
||||
public Dictionary<int, DishIngredientViewModel> Ingredients { get; set; } = new();
|
||||
[DisplayName("Стоимость")]
|
||||
public double Price { get; set; }
|
||||
|
||||
public Dictionary<int, (IIngredientModel, int)> DishIngredients { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
using System.ComponentModel;
|
||||
using SushiBarDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
public class IngredientViewModel
|
||||
public class IngredientViewModel : IIngredientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
namespace SushiBarDataModels.Models
|
||||
{
|
||||
public interface IDish : IId
|
||||
{
|
||||
string DishName { get; }
|
||||
|
||||
string Category { get; }
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
namespace SushiBarDataModels.Models
|
||||
{
|
||||
public interface IDishIngredient : IId
|
||||
{
|
||||
int DishId { get; }
|
||||
|
||||
int IngredientId { get; }
|
||||
|
||||
int Count { get; }
|
||||
}
|
||||
}
|
13
SushiBarDataModels/Models/IDishModel.cs
Normal file
13
SushiBarDataModels/Models/IDishModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace SushiBarDataModels.Models
|
||||
{
|
||||
public interface IDishModel : IId
|
||||
{
|
||||
string DishName { get; }
|
||||
|
||||
string Category { get; }
|
||||
|
||||
double Price { get; }
|
||||
|
||||
Dictionary<int, (IIngredientModel, int)> DishIngredients { get; }
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
namespace SushiBarDataModels.Models
|
||||
{
|
||||
public interface IIngredient : IId
|
||||
public interface IIngredientModel : IId
|
||||
{
|
||||
string IngredientName { get; }
|
||||
|
@ -12,8 +12,8 @@ using SushiBarDatabaseImplement;
|
||||
namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(SushiBarDatabase))]
|
||||
[Migration("20240515171525_Initial")]
|
||||
partial class Initial
|
||||
[Migration("20240523183058_Fix DishIngredients")]
|
||||
partial class FixDishIngredients
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -144,6 +144,9 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Dishes");
|
||||
@ -267,7 +270,7 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.DishIngredient", b =>
|
||||
{
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Dish", "Dish")
|
||||
.WithMany("DishIngredients")
|
||||
.WithMany("Ingredients")
|
||||
.HasForeignKey("DishId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@ -302,7 +305,7 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
b.Navigation("ChequeItems");
|
||||
|
||||
b.Navigation("DishIngredients");
|
||||
b.Navigation("Ingredients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Ingredient", b =>
|
@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Initial : Migration
|
||||
public partial class FixDishIngredients : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
@ -48,7 +48,8 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
DishName = table.Column<string>(type: "text", nullable: false),
|
||||
Category = table.Column<string>(type: "text", nullable: false)
|
||||
Category = table.Column<string>(type: "text", nullable: false),
|
||||
Price = table.Column<double>(type: "double precision", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
@ -141,6 +141,9 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Dishes");
|
||||
@ -264,7 +267,7 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.DishIngredient", b =>
|
||||
{
|
||||
b.HasOne("SushiBarDatabaseImplement.Models.Dish", "Dish")
|
||||
.WithMany("DishIngredients")
|
||||
.WithMany("Ingredients")
|
||||
.HasForeignKey("DishId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@ -299,7 +302,7 @@ namespace SushiBarDatabaseImplement.Migrations
|
||||
{
|
||||
b.Navigation("ChequeItems");
|
||||
|
||||
b.Navigation("DishIngredients");
|
||||
b.Navigation("Ingredients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Ingredient", b =>
|
||||
|
@ -1,11 +1,12 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace SushiBarDatabaseImplement.Models
|
||||
{
|
||||
public class Dish
|
||||
public class Dish : IDishModel
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
@ -16,22 +17,44 @@ namespace SushiBarDatabaseImplement.Models
|
||||
[Required]
|
||||
public string Category { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public double Price { get; set; }
|
||||
|
||||
[ForeignKey("DishId")]
|
||||
public virtual List<DishIngredient> DishIngredients { get; set; } = new();
|
||||
public virtual List<DishIngredient> Ingredients { get; set; } = new();
|
||||
|
||||
[ForeignKey("DishId")]
|
||||
public virtual List<ChequeItem> ChequeItems { get; set; } = new();
|
||||
|
||||
private Dictionary<int, (IIngredientModel, int)>? _dishIngredients = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IIngredientModel, int)> DishIngredients
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_dishIngredients == null)
|
||||
{
|
||||
_dishIngredients = Ingredients.ToDictionary(DishIngredient => DishIngredient.IngredientId, DishIngredient =>
|
||||
(DishIngredient.Ingredient as IIngredientModel, DishIngredient.Count));
|
||||
}
|
||||
|
||||
return _dishIngredients;
|
||||
}
|
||||
}
|
||||
|
||||
public static Dish Create(SushiBarDatabase Context, DishBindingModel Model)
|
||||
{
|
||||
return new Dish()
|
||||
{
|
||||
Id = Model.Id,
|
||||
DishName = Model.DishName,
|
||||
Category = Model.Category,
|
||||
DishIngredients = Model.Ingredients.Select(x => new DishIngredient
|
||||
Price = Model.Price,
|
||||
Ingredients = Model.DishIngredients.Select(x => new DishIngredient
|
||||
{
|
||||
Ingredient = Context.Ingredients.First(y => y.Id == x.IngredientId),
|
||||
Count = x.Count,
|
||||
Ingredient = Context.Ingredients.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2,
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
@ -40,22 +63,55 @@ namespace SushiBarDatabaseImplement.Models
|
||||
{
|
||||
DishName = Model.DishName;
|
||||
Category = Model.Category;
|
||||
Price = Model.Price;
|
||||
}
|
||||
|
||||
public DishViewModel ViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
DishName = DishName,
|
||||
Price = Price,
|
||||
Category = Category,
|
||||
Ingredients = DishIngredients.ToDictionary(x => x.IngredientId, x => new DishIngredientViewModel
|
||||
{
|
||||
DishId = x.DishId,
|
||||
IngredientId = x.IngredientId,
|
||||
IngredientName = x.Ingredient.IngredientName,
|
||||
Count = x.Count,
|
||||
})
|
||||
DishIngredients = DishIngredients,
|
||||
};
|
||||
|
||||
public void UpdateIngredients(SushiBarDatabase Context, DishBindingModel Model)
|
||||
{
|
||||
var IngredientsForThisDish = Context.DishIngredients.Where(x => x.DishId == Model.Id).ToList();
|
||||
|
||||
if (IngredientsForThisDish.Count > 0)
|
||||
{
|
||||
// Delete DishIngredient records for selected dish if there is no record with such ingredient in passed model
|
||||
Context.DishIngredients.RemoveRange(IngredientsForThisDish.Where(x => !Model.DishIngredients.ContainsKey(x.IngredientId)));
|
||||
Context.SaveChanges();
|
||||
|
||||
foreach (var DishIngredientToUpdate in IngredientsForThisDish)
|
||||
{
|
||||
DishIngredientToUpdate.Count = Model.DishIngredients[DishIngredientToUpdate.IngredientId].Item2;
|
||||
Model.DishIngredients.Remove(DishIngredientToUpdate.IngredientId);
|
||||
}
|
||||
|
||||
Context.SaveChanges();
|
||||
}
|
||||
|
||||
var Dish = Context.Dishes.First(x => x.Id == Id);
|
||||
|
||||
foreach (var DishIngredient in Model.DishIngredients)
|
||||
{
|
||||
Context.DishIngredients.Add(new DishIngredient
|
||||
{
|
||||
Dish = Dish,
|
||||
Ingredient = Context.Ingredients.First(x => x.Id == DishIngredient.Key),
|
||||
Count = DishIngredient.Value.Item2
|
||||
});
|
||||
|
||||
Context.SaveChanges();
|
||||
}
|
||||
|
||||
_dishIngredients = null;
|
||||
}
|
||||
|
||||
/*
|
||||
public void UpdateIngredients(SushiBarDatabase Context, DishBindingModel Model)
|
||||
{
|
||||
var IngredientsForThisDish = Context.DishIngredients.Where(x => x.DishId == Model.Id).ToList();
|
||||
@ -90,5 +146,6 @@ namespace SushiBarDatabaseImplement.Models
|
||||
Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
using SushiBarDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace SushiBarDatabaseImplement.Models
|
||||
{
|
||||
public class Ingredient
|
||||
public class Ingredient : IIngredientModel
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
@ -16,6 +16,9 @@ namespace SushiBarDatabaseImplement.Storages
|
||||
.Include(x => x.Customer)
|
||||
.Include(x => x.Promotion)
|
||||
.Include(x => x.ChequeItems)
|
||||
.ThenInclude(x => x.Dish)
|
||||
.Include(x => x.ChequeItems)
|
||||
.ThenInclude(x => x.Cook)
|
||||
.Select(x => x.ViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -30,6 +33,9 @@ namespace SushiBarDatabaseImplement.Storages
|
||||
.Include(x => x.Customer)
|
||||
.Include(x => x.Promotion)
|
||||
.Include(x => x.ChequeItems)
|
||||
.ThenInclude(x => x.Dish)
|
||||
.Include(x => x.ChequeItems)
|
||||
.ThenInclude(x => x.Cook)
|
||||
.Where(x => x.CustomerId == Model.CustomerId)
|
||||
.Select(x => x.ViewModel)
|
||||
.ToList();
|
||||
@ -41,6 +47,9 @@ namespace SushiBarDatabaseImplement.Storages
|
||||
.Include(x => x.Customer)
|
||||
.Include(x => x.Promotion)
|
||||
.Include(x => x.ChequeItems)
|
||||
.ThenInclude(x => x.Dish)
|
||||
.Include(x => x.ChequeItems)
|
||||
.ThenInclude(x => x.Cook)
|
||||
.Where(x => x.OrderDate >= Model.OrderDateFrom && x.OrderDate <= Model.OrderDateTo)
|
||||
.Select(x => x.ViewModel)
|
||||
.ToList();
|
||||
@ -59,6 +68,9 @@ namespace SushiBarDatabaseImplement.Storages
|
||||
.Include(x => x.Customer)
|
||||
.Include(x => x.Promotion)
|
||||
.Include(x => x.ChequeItems)
|
||||
.ThenInclude(x => x.Dish)
|
||||
.Include(x => x.ChequeItems)
|
||||
.ThenInclude(x => x.Cook)
|
||||
.FirstOrDefault(x => x.Id == Model.Id)?.ViewModel;
|
||||
}
|
||||
|
||||
@ -72,6 +84,7 @@ namespace SushiBarDatabaseImplement.Storages
|
||||
|
||||
Context.Cheques.Add(NewCheque);
|
||||
Context.SaveChanges();
|
||||
NewCheque.UpdateChequeItems(Context, Model);
|
||||
|
||||
return NewCheque.ViewModel;
|
||||
}
|
||||
|
@ -13,7 +13,8 @@ namespace SushiBarDatabaseImplement.Storages
|
||||
using var Context = new SushiBarDatabase();
|
||||
|
||||
return Context.Dishes
|
||||
.Include(x => x.DishIngredients)
|
||||
.Include(x => x.Ingredients)
|
||||
.ThenInclude(x => x.Ingredient)
|
||||
.Select(x => x.ViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -25,7 +26,8 @@ namespace SushiBarDatabaseImplement.Storages
|
||||
|
||||
using var Context = new SushiBarDatabase();
|
||||
return Context.Dishes
|
||||
.Include(x => x.DishIngredients)
|
||||
.Include(x => x.Ingredients)
|
||||
.ThenInclude(x => x.Ingredient)
|
||||
.Where(x => x.DishName.Contains(Model.DishName))
|
||||
.Select(x => x.ViewModel)
|
||||
.ToList();
|
||||
@ -38,7 +40,8 @@ namespace SushiBarDatabaseImplement.Storages
|
||||
|
||||
using var Context = new SushiBarDatabase();
|
||||
return Context.Dishes
|
||||
.Include(x => x.DishIngredients)
|
||||
.Include(x => x.Ingredients)
|
||||
.ThenInclude(x => x.Ingredient)
|
||||
.FirstOrDefault(x => x.Id == Model.Id)?.ViewModel;
|
||||
}
|
||||
|
||||
@ -86,7 +89,6 @@ namespace SushiBarDatabaseImplement.Storages
|
||||
{
|
||||
using var Context = new SushiBarDatabase();
|
||||
var Dish = Context.Dishes
|
||||
.Include(x => x.DishIngredients)
|
||||
.FirstOrDefault(rec => rec.Id == Model.Id);
|
||||
|
||||
if (Dish == null)
|
||||
|
@ -9,7 +9,8 @@ namespace SushiBarDatabaseImplement
|
||||
{
|
||||
if (OptionsBuilder.IsConfigured == false)
|
||||
{
|
||||
OptionsBuilder.UseNpgsql(@"Host=192.168.56.101;Port=5436;Database=postgres;Username=postgres;Password=admin");
|
||||
//OptionsBuilder.UseNpgsql(@"Host=192.168.56.101;Port=5436;Database=postgres;Username=postgres;Password=admin");
|
||||
OptionsBuilder.UseNpgsql(@"Host=localhost;Port=5000;Database=SushiBarTest;Username=postgres;Password=admin");
|
||||
}
|
||||
base.OnConfiguring(OptionsBuilder);
|
||||
|
||||
|
39
SushiBarView/Form1.Designer.cs
generated
39
SushiBarView/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
||||
namespace SushiBar
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace SushiBar
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
105
SushiBarView/Forms/FormCook.Designer.cs
generated
Normal file
105
SushiBarView/Forms/FormCook.Designer.cs
generated
Normal file
@ -0,0 +1,105 @@
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
partial class FormCook
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
label1 = new Label();
|
||||
FioTextBox = new TextBox();
|
||||
label2 = new Label();
|
||||
EmploymentDateTimePicker = new DateTimePicker();
|
||||
button1 = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(11, 15);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(34, 15);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "ФИО";
|
||||
//
|
||||
// FioTextBox
|
||||
//
|
||||
FioTextBox.Location = new Point(144, 12);
|
||||
FioTextBox.Name = "FioTextBox";
|
||||
FioTextBox.Size = new Size(200, 23);
|
||||
FioTextBox.TabIndex = 1;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(11, 47);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(127, 15);
|
||||
label2.TabIndex = 2;
|
||||
label2.Text = "Дата трудоустройства";
|
||||
//
|
||||
// EmploymentDateTimePicker
|
||||
//
|
||||
EmploymentDateTimePicker.Location = new Point(144, 41);
|
||||
EmploymentDateTimePicker.Name = "EmploymentDateTimePicker";
|
||||
EmploymentDateTimePicker.Size = new Size(200, 23);
|
||||
EmploymentDateTimePicker.TabIndex = 3;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(255, 86);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(89, 28);
|
||||
button1.TabIndex = 4;
|
||||
button1.Text = "Сохранить";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += ButtonSave_Click;
|
||||
//
|
||||
// FormCook
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(358, 123);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(EmploymentDateTimePicker);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(FioTextBox);
|
||||
Controls.Add(label1);
|
||||
Name = "FormCook";
|
||||
Text = "Повар";
|
||||
Load += FormCook_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private TextBox FioTextBox;
|
||||
private Label label2;
|
||||
private DateTimePicker EmploymentDateTimePicker;
|
||||
private Button button1;
|
||||
}
|
||||
}
|
78
SushiBarView/Forms/FormCook.cs
Normal file
78
SushiBarView/Forms/FormCook.cs
Normal file
@ -0,0 +1,78 @@
|
||||
using SushiBarBusinessLogic;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
public partial class FormCook : Form
|
||||
{
|
||||
private readonly CookLogic _logic;
|
||||
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormCook(CookLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = Logic;
|
||||
}
|
||||
|
||||
private void FormCook_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var View = _logic.ReadElement(new CookSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
|
||||
if (View != null)
|
||||
{
|
||||
FioTextBox.Text = View.Fio;
|
||||
EmploymentDateTimePicker.Value = View.EmploymentDate;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(FioTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var Model = new CookBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
Fio = FioTextBox.Text,
|
||||
EmploymentDate = EmploymentDateTimePicker.Value,
|
||||
};
|
||||
|
||||
var OperationResult = _id.HasValue ? _logic.Update(Model) : _logic.Create(Model);
|
||||
|
||||
if (!OperationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка сохранения повара", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
SushiBarView/Forms/FormCook.resx
Normal file
120
SushiBarView/Forms/FormCook.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
113
SushiBarView/Forms/FormCooks.Designer.cs
generated
Normal file
113
SushiBarView/Forms/FormCooks.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
partial class FormCooks
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
DataGridView = new DataGridView();
|
||||
AddButton = new Button();
|
||||
ChangeButton = new Button();
|
||||
DeleteButton = new Button();
|
||||
UpdateButton = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Location = new Point(12, 12);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.RowTemplate.Height = 25;
|
||||
DataGridView.Size = new Size(413, 358);
|
||||
DataGridView.TabIndex = 0;
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
AddButton.Location = new Point(431, 12);
|
||||
AddButton.Name = "AddButton";
|
||||
AddButton.Size = new Size(138, 29);
|
||||
AddButton.TabIndex = 1;
|
||||
AddButton.Text = "Добавить";
|
||||
AddButton.UseVisualStyleBackColor = true;
|
||||
AddButton.Click += AddButton_Click;
|
||||
//
|
||||
// ChangeButton
|
||||
//
|
||||
ChangeButton.Location = new Point(431, 47);
|
||||
ChangeButton.Name = "ChangeButton";
|
||||
ChangeButton.Size = new Size(138, 29);
|
||||
ChangeButton.TabIndex = 2;
|
||||
ChangeButton.Text = "Изменить";
|
||||
ChangeButton.UseVisualStyleBackColor = true;
|
||||
ChangeButton.Click += ChangeButton_Click;
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
DeleteButton.Location = new Point(431, 82);
|
||||
DeleteButton.Name = "DeleteButton";
|
||||
DeleteButton.Size = new Size(138, 29);
|
||||
DeleteButton.TabIndex = 3;
|
||||
DeleteButton.Text = "Удалить";
|
||||
DeleteButton.UseVisualStyleBackColor = true;
|
||||
DeleteButton.Click += DeleteButton_Click;
|
||||
//
|
||||
// UpdateButton
|
||||
//
|
||||
UpdateButton.Location = new Point(431, 117);
|
||||
UpdateButton.Name = "UpdateButton";
|
||||
UpdateButton.Size = new Size(138, 29);
|
||||
UpdateButton.TabIndex = 4;
|
||||
UpdateButton.Text = "Обновить";
|
||||
UpdateButton.UseVisualStyleBackColor = true;
|
||||
UpdateButton.Click += RefreshButton_Click;
|
||||
//
|
||||
// FormCooks
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(580, 384);
|
||||
Controls.Add(UpdateButton);
|
||||
Controls.Add(DeleteButton);
|
||||
Controls.Add(ChangeButton);
|
||||
Controls.Add(AddButton);
|
||||
Controls.Add(DataGridView);
|
||||
Name = "FormCooks";
|
||||
Text = "Повара";
|
||||
Load += FormCooks_Load;
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView DataGridView;
|
||||
private Button AddButton;
|
||||
private Button ChangeButton;
|
||||
private Button DeleteButton;
|
||||
private Button UpdateButton;
|
||||
}
|
||||
}
|
98
SushiBarView/Forms/FormCooks.cs
Normal file
98
SushiBarView/Forms/FormCooks.cs
Normal file
@ -0,0 +1,98 @@
|
||||
using SushiBarBusinessLogic;
|
||||
using SushiBarContracts.BindingModels;
|
||||
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
public partial class FormCooks : Form
|
||||
{
|
||||
private readonly CookLogic _logic;
|
||||
|
||||
public FormCooks(CookLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = Logic;
|
||||
}
|
||||
|
||||
private void FormCooks_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var List = _logic.ReadList(null);
|
||||
|
||||
if (List != null)
|
||||
{
|
||||
DataGridView.DataSource = List;
|
||||
DataGridView.Columns["Id"].Visible = false;
|
||||
DataGridView.Columns["Fio"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
DataGridView.Columns["EmploymentDate"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormCook Form = new FormCook(new CookLogic(new SushiBarDatabaseImplement.Storages.CookStorage()));
|
||||
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
FormCook Form = new FormCook(new CookLogic(new SushiBarDatabaseImplement.Storages.CookStorage()));
|
||||
Form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new CookBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
199
SushiBarView/Forms/FormCreateCheque.Designer.cs
generated
Normal file
199
SushiBarView/Forms/FormCreateCheque.Designer.cs
generated
Normal file
@ -0,0 +1,199 @@
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
partial class FormCreateCheque
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
NameLabel = new Label();
|
||||
PriceLabel = new Label();
|
||||
PriceTextBox = new TextBox();
|
||||
ComponentsGroupBox = new GroupBox();
|
||||
AddButton = new Button();
|
||||
DataGridView = new DataGridView();
|
||||
IdColumn = new DataGridViewTextBoxColumn();
|
||||
DishNameColumn = new DataGridViewTextBoxColumn();
|
||||
CountColumn = new DataGridViewTextBoxColumn();
|
||||
CookColumn = new DataGridViewTextBoxColumn();
|
||||
SaveButton = new Button();
|
||||
CancelButton = new Button();
|
||||
CustomerComboBox = new ComboBox();
|
||||
ComponentsGroupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// NameLabel
|
||||
//
|
||||
NameLabel.AutoSize = true;
|
||||
NameLabel.Location = new Point(12, 9);
|
||||
NameLabel.Name = "NameLabel";
|
||||
NameLabel.Size = new Size(75, 15);
|
||||
NameLabel.TabIndex = 0;
|
||||
NameLabel.Text = "Покупатель:";
|
||||
//
|
||||
// PriceLabel
|
||||
//
|
||||
PriceLabel.AutoSize = true;
|
||||
PriceLabel.Location = new Point(12, 38);
|
||||
PriceLabel.Name = "PriceLabel";
|
||||
PriceLabel.Size = new Size(88, 15);
|
||||
PriceLabel.TabIndex = 1;
|
||||
PriceLabel.Text = "Общая сумма:";
|
||||
//
|
||||
// PriceTextBox
|
||||
//
|
||||
PriceTextBox.Location = new Point(108, 35);
|
||||
PriceTextBox.Name = "PriceTextBox";
|
||||
PriceTextBox.ReadOnly = true;
|
||||
PriceTextBox.Size = new Size(100, 23);
|
||||
PriceTextBox.TabIndex = 3;
|
||||
//
|
||||
// ComponentsGroupBox
|
||||
//
|
||||
ComponentsGroupBox.Controls.Add(AddButton);
|
||||
ComponentsGroupBox.Controls.Add(DataGridView);
|
||||
ComponentsGroupBox.Location = new Point(12, 64);
|
||||
ComponentsGroupBox.Name = "ComponentsGroupBox";
|
||||
ComponentsGroupBox.Size = new Size(706, 318);
|
||||
ComponentsGroupBox.TabIndex = 4;
|
||||
ComponentsGroupBox.TabStop = false;
|
||||
ComponentsGroupBox.Text = "Заказанные блюда";
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
AddButton.Location = new Point(588, 22);
|
||||
AddButton.Name = "AddButton";
|
||||
AddButton.Size = new Size(112, 29);
|
||||
AddButton.TabIndex = 1;
|
||||
AddButton.Text = "Добавить";
|
||||
AddButton.UseVisualStyleBackColor = true;
|
||||
AddButton.Click += AddButton_Click;
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Columns.AddRange(new DataGridViewColumn[] { IdColumn, DishNameColumn, CountColumn, CookColumn });
|
||||
DataGridView.Location = new Point(6, 22);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.RowHeadersWidth = 51;
|
||||
DataGridView.Size = new Size(567, 290);
|
||||
DataGridView.TabIndex = 0;
|
||||
//
|
||||
// IdColumn
|
||||
//
|
||||
IdColumn.HeaderText = "Column1";
|
||||
IdColumn.MinimumWidth = 6;
|
||||
IdColumn.Name = "IdColumn";
|
||||
IdColumn.Visible = false;
|
||||
IdColumn.Width = 6;
|
||||
//
|
||||
// DishNameColumn
|
||||
//
|
||||
DishNameColumn.HeaderText = "Блюдо";
|
||||
DishNameColumn.MinimumWidth = 6;
|
||||
DishNameColumn.Name = "DishNameColumn";
|
||||
DishNameColumn.Width = 175;
|
||||
//
|
||||
// CountColumn
|
||||
//
|
||||
CountColumn.HeaderText = "Количество";
|
||||
CountColumn.MinimumWidth = 6;
|
||||
CountColumn.Name = "CountColumn";
|
||||
CountColumn.Width = 139;
|
||||
//
|
||||
// CookColumn
|
||||
//
|
||||
CookColumn.HeaderText = "Повар";
|
||||
CookColumn.Name = "CookColumn";
|
||||
CookColumn.ReadOnly = true;
|
||||
CookColumn.Width = 200;
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
SaveButton.Location = new Point(523, 404);
|
||||
SaveButton.Name = "SaveButton";
|
||||
SaveButton.Size = new Size(96, 33);
|
||||
SaveButton.TabIndex = 5;
|
||||
SaveButton.Text = "Сохранить";
|
||||
SaveButton.UseVisualStyleBackColor = true;
|
||||
SaveButton.Click += SaveButton_Click;
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
CancelButton.Location = new Point(625, 404);
|
||||
CancelButton.Name = "CancelButton";
|
||||
CancelButton.Size = new Size(87, 33);
|
||||
CancelButton.TabIndex = 6;
|
||||
CancelButton.Text = "Отмена";
|
||||
CancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// CustomerComboBox
|
||||
//
|
||||
CustomerComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
CustomerComboBox.FormattingEnabled = true;
|
||||
CustomerComboBox.Location = new Point(108, 6);
|
||||
CustomerComboBox.Name = "CustomerComboBox";
|
||||
CustomerComboBox.Size = new Size(225, 23);
|
||||
CustomerComboBox.TabIndex = 9;
|
||||
//
|
||||
// FormCreateCheque
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(730, 449);
|
||||
Controls.Add(CustomerComboBox);
|
||||
Controls.Add(CancelButton);
|
||||
Controls.Add(SaveButton);
|
||||
Controls.Add(ComponentsGroupBox);
|
||||
Controls.Add(PriceTextBox);
|
||||
Controls.Add(PriceLabel);
|
||||
Controls.Add(NameLabel);
|
||||
Name = "FormCreateCheque";
|
||||
Text = "Чек";
|
||||
Load += FormCreateCheque_Load;
|
||||
ComponentsGroupBox.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label NameLabel;
|
||||
private Label PriceLabel;
|
||||
private TextBox PriceTextBox;
|
||||
private GroupBox ComponentsGroupBox;
|
||||
private Button AddButton;
|
||||
private DataGridView DataGridView;
|
||||
private Button SaveButton;
|
||||
private Button CancelButton;
|
||||
private ComboBox CustomerComboBox;
|
||||
private DataGridViewTextBoxColumn IdColumn;
|
||||
private DataGridViewTextBoxColumn DishNameColumn;
|
||||
private DataGridViewTextBoxColumn CountColumn;
|
||||
private DataGridViewTextBoxColumn CookColumn;
|
||||
}
|
||||
}
|
165
SushiBarView/Forms/FormCreateCheque.cs
Normal file
165
SushiBarView/Forms/FormCreateCheque.cs
Normal file
@ -0,0 +1,165 @@
|
||||
using SushiBarBusinessLogic;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarContracts.ViewModels;
|
||||
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
public partial class FormCreateCheque : Form
|
||||
{
|
||||
private readonly ChequeLogic _chequeLogic;
|
||||
private readonly CustomerLogic _customerLogic;
|
||||
|
||||
private List<ChequeItemViewModel> ChequeItems;
|
||||
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormCreateCheque(ChequeLogic ChequeLogic, CustomerLogic customerLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_chequeLogic = ChequeLogic;
|
||||
_customerLogic = customerLogic;
|
||||
|
||||
ChequeItems = new();
|
||||
}
|
||||
|
||||
private void FormCreateCheque_Load(object sender, EventArgs e)
|
||||
{
|
||||
var List = _customerLogic.ReadList(null);
|
||||
if (List != null)
|
||||
{
|
||||
CustomerComboBox.DisplayMember = "Fio";
|
||||
CustomerComboBox.ValueMember = "Id";
|
||||
CustomerComboBox.DataSource = List;
|
||||
CustomerComboBox.SelectedItem = null;
|
||||
}
|
||||
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var View = _chequeLogic.ReadElement(new ChequeSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
|
||||
if (View != null)
|
||||
{
|
||||
CustomerComboBox.SelectedItem = View.CustomerId;
|
||||
ChequeItems = View.ChequeItems.Select(x => x.Value).ToList();
|
||||
|
||||
CustomerComboBox.Enabled = false;
|
||||
AddButton.Enabled = false;
|
||||
SaveButton.Enabled = false;
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
DataGridView.Rows.Clear();
|
||||
foreach (var ChequeItem in ChequeItems)
|
||||
{
|
||||
DataGridView.Rows.Add(new object[] { ChequeItem.DishId, ChequeItem.DishName, ChequeItem.Count, ChequeItem.CookFio });
|
||||
}
|
||||
|
||||
PriceTextBox.Text = CalcPrice().ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Form = new FormCreateChequeItem(
|
||||
new DishLogic(new SushiBarDatabaseImplement.Storages.DishStorage()),
|
||||
new CookLogic(new SushiBarDatabaseImplement.Storages.CookStorage()));
|
||||
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (Form.DishModel == null || Form.CookModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ChequeItems.Add(new ChequeItemViewModel
|
||||
{
|
||||
DishId = Form.DishId,
|
||||
DishName = Form.DishModel.DishName,
|
||||
DishPrice = Form.DishModel.Price,
|
||||
CookId = Form.CookId,
|
||||
CookFio = Form.CookModel.Fio,
|
||||
Count = Form.Count,
|
||||
});
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var Мodel = new ChequeBindingModel
|
||||
{
|
||||
Id = 0,
|
||||
ChequeItems = ChequeItems.Select(x => new ChequeItemBindingModel
|
||||
{
|
||||
DishId = x.DishId,
|
||||
CookId = x.CookId,
|
||||
Count = x.Count,
|
||||
}).ToList(),
|
||||
CustomerId = null,
|
||||
OrderDate = DateTime.Now,
|
||||
TotalSum = CalcPrice(),
|
||||
PromotionId = null,
|
||||
};
|
||||
|
||||
var OperationResult = _chequeLogic.CreateCheque(Мodel);
|
||||
|
||||
if (!OperationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private double CalcPrice()
|
||||
{
|
||||
double Price = 0;
|
||||
|
||||
foreach (var Elem in ChequeItems)
|
||||
{
|
||||
Price += Elem.DishPrice * Elem.Count;
|
||||
}
|
||||
|
||||
return Math.Round(Price * 1.1, 2);
|
||||
}
|
||||
}
|
||||
}
|
123
SushiBarView/Forms/FormCreateCheque.resx
Normal file
123
SushiBarView/Forms/FormCreateCheque.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="CookColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
143
SushiBarView/Forms/FormCreateChequeItem.Designer.cs
generated
Normal file
143
SushiBarView/Forms/FormCreateChequeItem.Designer.cs
generated
Normal file
@ -0,0 +1,143 @@
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
partial class FormCreateChequeItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
label1 = new Label();
|
||||
DishComboBox = new ComboBox();
|
||||
label2 = new Label();
|
||||
CookComboBox = new ComboBox();
|
||||
label3 = new Label();
|
||||
CountTextBox = new TextBox();
|
||||
CancelButton = new Button();
|
||||
SaveButton = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 15);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(47, 15);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Блюдо:";
|
||||
//
|
||||
// DishComboBox
|
||||
//
|
||||
DishComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
DishComboBox.FormattingEnabled = true;
|
||||
DishComboBox.Location = new Point(93, 12);
|
||||
DishComboBox.Name = "DishComboBox";
|
||||
DishComboBox.Size = new Size(232, 23);
|
||||
DishComboBox.TabIndex = 1;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(12, 44);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(45, 15);
|
||||
label2.TabIndex = 2;
|
||||
label2.Text = "Повар:";
|
||||
//
|
||||
// CookComboBox
|
||||
//
|
||||
CookComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
CookComboBox.FormattingEnabled = true;
|
||||
CookComboBox.Location = new Point(93, 41);
|
||||
CookComboBox.Name = "CookComboBox";
|
||||
CookComboBox.Size = new Size(232, 23);
|
||||
CookComboBox.TabIndex = 3;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(12, 73);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(75, 15);
|
||||
label3.TabIndex = 4;
|
||||
label3.Text = "Количество:";
|
||||
//
|
||||
// CountTextBox
|
||||
//
|
||||
CountTextBox.Location = new Point(93, 70);
|
||||
CountTextBox.Name = "CountTextBox";
|
||||
CountTextBox.Size = new Size(232, 23);
|
||||
CountTextBox.TabIndex = 5;
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
CancelButton.Location = new Point(250, 109);
|
||||
CancelButton.Name = "CancelButton";
|
||||
CancelButton.Size = new Size(75, 23);
|
||||
CancelButton.TabIndex = 8;
|
||||
CancelButton.Text = "Отмена";
|
||||
CancelButton.UseVisualStyleBackColor = true;
|
||||
CancelButton.Click += CancelButton_Click;
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
SaveButton.Location = new Point(163, 109);
|
||||
SaveButton.Name = "SaveButton";
|
||||
SaveButton.Size = new Size(81, 23);
|
||||
SaveButton.TabIndex = 9;
|
||||
SaveButton.Text = "Сохранить";
|
||||
SaveButton.UseVisualStyleBackColor = true;
|
||||
SaveButton.Click += SaveButton_Click;
|
||||
//
|
||||
// FormCreateChequeItem
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(347, 146);
|
||||
Controls.Add(SaveButton);
|
||||
Controls.Add(CancelButton);
|
||||
Controls.Add(CountTextBox);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(CookComboBox);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(DishComboBox);
|
||||
Controls.Add(label1);
|
||||
Name = "FormCreateChequeItem";
|
||||
Text = "Элемент чека";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private ComboBox DishComboBox;
|
||||
private Label label2;
|
||||
private ComboBox CookComboBox;
|
||||
private Label label3;
|
||||
private TextBox CountTextBox;
|
||||
private Button CancelButton;
|
||||
private Button SaveButton;
|
||||
}
|
||||
}
|
136
SushiBarView/Forms/FormCreateChequeItem.cs
Normal file
136
SushiBarView/Forms/FormCreateChequeItem.cs
Normal file
@ -0,0 +1,136 @@
|
||||
using SushiBarBusinessLogic;
|
||||
using SushiBarContracts.ViewModels;
|
||||
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
public partial class FormCreateChequeItem : Form
|
||||
{
|
||||
private readonly List<DishViewModel>? _dishes;
|
||||
private readonly List<CookViewModel>? _cooks;
|
||||
|
||||
public int DishId
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(DishComboBox.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
DishComboBox.SelectedValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int CookId
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(CookComboBox.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
CookComboBox.SelectedValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
public DishViewModel? DishModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_dishes == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var Elem in _dishes)
|
||||
{
|
||||
if (Elem.Id == DishId)
|
||||
{
|
||||
return Elem;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public CookViewModel? CookModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cooks == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var Elem in _cooks)
|
||||
{
|
||||
if (Elem.Id == CookId)
|
||||
{
|
||||
return Elem;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return Convert.ToInt32(CountTextBox.Text); }
|
||||
set { CountTextBox.Text = value.ToString(); }
|
||||
}
|
||||
|
||||
public FormCreateChequeItem(DishLogic DishLogic, CookLogic CookLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_dishes = DishLogic.ReadList(null);
|
||||
if (_dishes != null)
|
||||
{
|
||||
DishComboBox.DisplayMember = "DishName";
|
||||
DishComboBox.ValueMember = "Id";
|
||||
DishComboBox.DataSource = _dishes;
|
||||
DishComboBox.SelectedItem = null;
|
||||
}
|
||||
|
||||
_cooks = CookLogic.ReadList(null);
|
||||
if (_cooks != null)
|
||||
{
|
||||
CookComboBox.DisplayMember = "Fio";
|
||||
CookComboBox.ValueMember = "Id";
|
||||
CookComboBox.DataSource = _cooks;
|
||||
CookComboBox.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(CountTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (DishComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите блюдо", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (CookComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите повара", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void CancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
SushiBarView/Forms/FormCreateChequeItem.resx
Normal file
120
SushiBarView/Forms/FormCreateChequeItem.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
128
SushiBarView/Forms/FormCustomer.Designer.cs
generated
Normal file
128
SushiBarView/Forms/FormCustomer.Designer.cs
generated
Normal file
@ -0,0 +1,128 @@
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
partial class FormCustomer
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
label1 = new Label();
|
||||
FioTextBox = new TextBox();
|
||||
label2 = new Label();
|
||||
EmploymentDateTimePicker = new DateTimePicker();
|
||||
button1 = new Button();
|
||||
label3 = new Label();
|
||||
SumOfAllOrdersTextBox = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(11, 15);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(34, 15);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "ФИО";
|
||||
//
|
||||
// FioTextBox
|
||||
//
|
||||
FioTextBox.Location = new Point(119, 12);
|
||||
FioTextBox.Name = "FioTextBox";
|
||||
FioTextBox.Size = new Size(225, 23);
|
||||
FioTextBox.TabIndex = 1;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(11, 47);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(90, 15);
|
||||
label2.TabIndex = 2;
|
||||
label2.Text = "Дата рождения";
|
||||
//
|
||||
// EmploymentDateTimePicker
|
||||
//
|
||||
EmploymentDateTimePicker.Location = new Point(119, 41);
|
||||
EmploymentDateTimePicker.Name = "EmploymentDateTimePicker";
|
||||
EmploymentDateTimePicker.Size = new Size(225, 23);
|
||||
EmploymentDateTimePicker.TabIndex = 3;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(255, 117);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(89, 28);
|
||||
button1.TabIndex = 4;
|
||||
button1.Text = "Сохранить";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += ButtonSave_Click;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(11, 77);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(89, 15);
|
||||
label3.TabIndex = 5;
|
||||
label3.Text = "Сумма заказов";
|
||||
//
|
||||
// SumOfAllOrdersTextBox
|
||||
//
|
||||
SumOfAllOrdersTextBox.Location = new Point(119, 74);
|
||||
SumOfAllOrdersTextBox.Name = "SumOfAllOrdersTextBox";
|
||||
SumOfAllOrdersTextBox.ReadOnly = true;
|
||||
SumOfAllOrdersTextBox.Size = new Size(225, 23);
|
||||
SumOfAllOrdersTextBox.TabIndex = 6;
|
||||
//
|
||||
// FormCustomer
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(358, 155);
|
||||
Controls.Add(SumOfAllOrdersTextBox);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(EmploymentDateTimePicker);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(FioTextBox);
|
||||
Controls.Add(label1);
|
||||
Name = "FormCustomer";
|
||||
Text = "Покупатель";
|
||||
Load += FormCustomer_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private TextBox FioTextBox;
|
||||
private Label label2;
|
||||
private DateTimePicker EmploymentDateTimePicker;
|
||||
private Button button1;
|
||||
private Label label3;
|
||||
private TextBox SumOfAllOrdersTextBox;
|
||||
}
|
||||
}
|
80
SushiBarView/Forms/FormCustomer.cs
Normal file
80
SushiBarView/Forms/FormCustomer.cs
Normal file
@ -0,0 +1,80 @@
|
||||
using SushiBarBusinessLogic;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
public partial class FormCustomer : Form
|
||||
{
|
||||
private readonly CustomerLogic _logic;
|
||||
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormCustomer(CustomerLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = Logic;
|
||||
}
|
||||
|
||||
private void FormCustomer_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var View = _logic.ReadElement(new CustomerSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
|
||||
if (View != null)
|
||||
{
|
||||
FioTextBox.Text = View.Fio;
|
||||
EmploymentDateTimePicker.Value = View.BirthdayDate ?? new DateTime();
|
||||
SumOfAllOrdersTextBox.Text = View.SumOfAllOrders.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(FioTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var Model = new CustomerBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
Fio = FioTextBox.Text,
|
||||
BirthdayDate = EmploymentDateTimePicker.Value,
|
||||
SumOfAllOrders = 0,
|
||||
};
|
||||
|
||||
var OperationResult = _id.HasValue ? _logic.Update(Model) : _logic.Create(Model);
|
||||
|
||||
if (!OperationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка сохранения повара", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
SushiBarView/Forms/FormCustomer.resx
Normal file
120
SushiBarView/Forms/FormCustomer.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
113
SushiBarView/Forms/FormCustomers.Designer.cs
generated
Normal file
113
SushiBarView/Forms/FormCustomers.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
partial class FormCustomers
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
DataGridView = new DataGridView();
|
||||
AddButton = new Button();
|
||||
ChangeButton = new Button();
|
||||
DeleteButton = new Button();
|
||||
UpdateButton = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Location = new Point(12, 12);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.RowTemplate.Height = 25;
|
||||
DataGridView.Size = new Size(413, 358);
|
||||
DataGridView.TabIndex = 0;
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
AddButton.Location = new Point(431, 12);
|
||||
AddButton.Name = "AddButton";
|
||||
AddButton.Size = new Size(138, 29);
|
||||
AddButton.TabIndex = 1;
|
||||
AddButton.Text = "Добавить";
|
||||
AddButton.UseVisualStyleBackColor = true;
|
||||
AddButton.Click += AddButton_Click;
|
||||
//
|
||||
// ChangeButton
|
||||
//
|
||||
ChangeButton.Location = new Point(431, 47);
|
||||
ChangeButton.Name = "ChangeButton";
|
||||
ChangeButton.Size = new Size(138, 29);
|
||||
ChangeButton.TabIndex = 2;
|
||||
ChangeButton.Text = "Изменить";
|
||||
ChangeButton.UseVisualStyleBackColor = true;
|
||||
ChangeButton.Click += ChangeButton_Click;
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
DeleteButton.Location = new Point(431, 82);
|
||||
DeleteButton.Name = "DeleteButton";
|
||||
DeleteButton.Size = new Size(138, 29);
|
||||
DeleteButton.TabIndex = 3;
|
||||
DeleteButton.Text = "Удалить";
|
||||
DeleteButton.UseVisualStyleBackColor = true;
|
||||
DeleteButton.Click += DeleteButton_Click;
|
||||
//
|
||||
// UpdateButton
|
||||
//
|
||||
UpdateButton.Location = new Point(431, 117);
|
||||
UpdateButton.Name = "UpdateButton";
|
||||
UpdateButton.Size = new Size(138, 29);
|
||||
UpdateButton.TabIndex = 4;
|
||||
UpdateButton.Text = "Обновить";
|
||||
UpdateButton.UseVisualStyleBackColor = true;
|
||||
UpdateButton.Click += RefreshButton_Click;
|
||||
//
|
||||
// FormCustomers
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(580, 384);
|
||||
Controls.Add(UpdateButton);
|
||||
Controls.Add(DeleteButton);
|
||||
Controls.Add(ChangeButton);
|
||||
Controls.Add(AddButton);
|
||||
Controls.Add(DataGridView);
|
||||
Name = "FormCustomers";
|
||||
Text = "Покупатели";
|
||||
Load += FormCustomers_Load;
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView DataGridView;
|
||||
private Button AddButton;
|
||||
private Button ChangeButton;
|
||||
private Button DeleteButton;
|
||||
private Button UpdateButton;
|
||||
}
|
||||
}
|
98
SushiBarView/Forms/FormCustomers.cs
Normal file
98
SushiBarView/Forms/FormCustomers.cs
Normal file
@ -0,0 +1,98 @@
|
||||
using SushiBarBusinessLogic;
|
||||
using SushiBarContracts.BindingModels;
|
||||
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
public partial class FormCustomers : Form
|
||||
{
|
||||
private readonly CustomerLogic _logic;
|
||||
|
||||
public FormCustomers(CustomerLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = Logic;
|
||||
}
|
||||
|
||||
private void FormCustomers_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var List = _logic.ReadList(null);
|
||||
|
||||
if (List != null)
|
||||
{
|
||||
DataGridView.DataSource = List;
|
||||
DataGridView.Columns["Id"].Visible = false;
|
||||
DataGridView.Columns["Fio"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
DataGridView.Columns["BirthdayDate"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormCustomer Form = new FormCustomer(new CustomerLogic(new SushiBarDatabaseImplement.Storages.CustomerStorage()));
|
||||
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
FormCustomer Form = new FormCustomer(new CustomerLogic(new SushiBarDatabaseImplement.Storages.CustomerStorage()));
|
||||
Form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new CustomerBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
SushiBarView/Forms/FormCustomers.resx
Normal file
120
SushiBarView/Forms/FormCustomers.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
249
SushiBarView/Forms/FormDish.Designer.cs
generated
Normal file
249
SushiBarView/Forms/FormDish.Designer.cs
generated
Normal file
@ -0,0 +1,249 @@
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
partial class FormDish
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
NameLabel = new Label();
|
||||
PriceLabel = new Label();
|
||||
NameTextBox = new TextBox();
|
||||
PriceTextBox = new TextBox();
|
||||
ComponentsGroupBox = new GroupBox();
|
||||
RefreshButton = new Button();
|
||||
DeleteButton = new Button();
|
||||
UpdateButton = new Button();
|
||||
AddButton = new Button();
|
||||
DataGridView = new DataGridView();
|
||||
IdColumn = new DataGridViewTextBoxColumn();
|
||||
IngredientNameColumn = new DataGridViewTextBoxColumn();
|
||||
CountColumn = new DataGridViewTextBoxColumn();
|
||||
SaveButton = new Button();
|
||||
CancelButton = new Button();
|
||||
label1 = new Label();
|
||||
CategoryTextBox = new TextBox();
|
||||
ComponentsGroupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// NameLabel
|
||||
//
|
||||
NameLabel.AutoSize = true;
|
||||
NameLabel.Location = new Point(12, 9);
|
||||
NameLabel.Name = "NameLabel";
|
||||
NameLabel.Size = new Size(59, 15);
|
||||
NameLabel.TabIndex = 0;
|
||||
NameLabel.Text = "Название";
|
||||
//
|
||||
// PriceLabel
|
||||
//
|
||||
PriceLabel.AutoSize = true;
|
||||
PriceLabel.Location = new Point(12, 67);
|
||||
PriceLabel.Name = "PriceLabel";
|
||||
PriceLabel.Size = new Size(35, 15);
|
||||
PriceLabel.TabIndex = 1;
|
||||
PriceLabel.Text = "Цена";
|
||||
//
|
||||
// NameTextBox
|
||||
//
|
||||
NameTextBox.Location = new Point(81, 6);
|
||||
NameTextBox.Name = "NameTextBox";
|
||||
NameTextBox.Size = new Size(237, 23);
|
||||
NameTextBox.TabIndex = 2;
|
||||
//
|
||||
// PriceTextBox
|
||||
//
|
||||
PriceTextBox.Location = new Point(81, 64);
|
||||
PriceTextBox.Name = "PriceTextBox";
|
||||
PriceTextBox.ReadOnly = true;
|
||||
PriceTextBox.Size = new Size(100, 23);
|
||||
PriceTextBox.TabIndex = 3;
|
||||
//
|
||||
// ComponentsGroupBox
|
||||
//
|
||||
ComponentsGroupBox.Controls.Add(RefreshButton);
|
||||
ComponentsGroupBox.Controls.Add(DeleteButton);
|
||||
ComponentsGroupBox.Controls.Add(UpdateButton);
|
||||
ComponentsGroupBox.Controls.Add(AddButton);
|
||||
ComponentsGroupBox.Controls.Add(DataGridView);
|
||||
ComponentsGroupBox.Location = new Point(12, 95);
|
||||
ComponentsGroupBox.Name = "ComponentsGroupBox";
|
||||
ComponentsGroupBox.Size = new Size(582, 287);
|
||||
ComponentsGroupBox.TabIndex = 4;
|
||||
ComponentsGroupBox.TabStop = false;
|
||||
ComponentsGroupBox.Text = "Компоненты";
|
||||
//
|
||||
// RefreshButton
|
||||
//
|
||||
RefreshButton.Location = new Point(464, 127);
|
||||
RefreshButton.Name = "RefreshButton";
|
||||
RefreshButton.Size = new Size(112, 29);
|
||||
RefreshButton.TabIndex = 4;
|
||||
RefreshButton.Text = "Обновить";
|
||||
RefreshButton.UseVisualStyleBackColor = true;
|
||||
RefreshButton.Click += RefreshButton_Click;
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
DeleteButton.Location = new Point(464, 92);
|
||||
DeleteButton.Name = "DeleteButton";
|
||||
DeleteButton.Size = new Size(112, 29);
|
||||
DeleteButton.TabIndex = 3;
|
||||
DeleteButton.Text = "Удалить";
|
||||
DeleteButton.UseVisualStyleBackColor = true;
|
||||
DeleteButton.Click += DeleteButton_Click;
|
||||
//
|
||||
// UpdateButton
|
||||
//
|
||||
UpdateButton.Location = new Point(464, 57);
|
||||
UpdateButton.Name = "UpdateButton";
|
||||
UpdateButton.Size = new Size(112, 29);
|
||||
UpdateButton.TabIndex = 2;
|
||||
UpdateButton.Text = "Изменить";
|
||||
UpdateButton.UseVisualStyleBackColor = true;
|
||||
UpdateButton.Click += UpdateButton_Click;
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
AddButton.Location = new Point(464, 22);
|
||||
AddButton.Name = "AddButton";
|
||||
AddButton.Size = new Size(112, 29);
|
||||
AddButton.TabIndex = 1;
|
||||
AddButton.Text = "Добавить";
|
||||
AddButton.UseVisualStyleBackColor = true;
|
||||
AddButton.Click += AddButton_Click;
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Columns.AddRange(new DataGridViewColumn[] { IdColumn, IngredientNameColumn, CountColumn });
|
||||
DataGridView.Location = new Point(6, 22);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.RowHeadersWidth = 51;
|
||||
DataGridView.Size = new Size(442, 259);
|
||||
DataGridView.TabIndex = 0;
|
||||
//
|
||||
// IdColumn
|
||||
//
|
||||
IdColumn.HeaderText = "Column1";
|
||||
IdColumn.MinimumWidth = 6;
|
||||
IdColumn.Name = "IdColumn";
|
||||
IdColumn.Visible = false;
|
||||
IdColumn.Width = 6;
|
||||
//
|
||||
// IngredientNameColumn
|
||||
//
|
||||
IngredientNameColumn.HeaderText = "Ингредиент";
|
||||
IngredientNameColumn.MinimumWidth = 6;
|
||||
IngredientNameColumn.Name = "IngredientNameColumn";
|
||||
IngredientNameColumn.Width = 300;
|
||||
//
|
||||
// CountColumn
|
||||
//
|
||||
CountColumn.HeaderText = "Количество";
|
||||
CountColumn.MinimumWidth = 6;
|
||||
CountColumn.Name = "CountColumn";
|
||||
CountColumn.Width = 125;
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
SaveButton.Location = new Point(421, 404);
|
||||
SaveButton.Name = "SaveButton";
|
||||
SaveButton.Size = new Size(92, 33);
|
||||
SaveButton.TabIndex = 5;
|
||||
SaveButton.Text = "Сохранить";
|
||||
SaveButton.UseVisualStyleBackColor = true;
|
||||
SaveButton.Click += SaveButton_Click;
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
CancelButton.Location = new Point(519, 404);
|
||||
CancelButton.Name = "CancelButton";
|
||||
CancelButton.Size = new Size(75, 33);
|
||||
CancelButton.TabIndex = 6;
|
||||
CancelButton.Text = "Отмена";
|
||||
CancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 38);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(63, 15);
|
||||
label1.TabIndex = 7;
|
||||
label1.Text = "Категория";
|
||||
//
|
||||
// CategoryTextBox
|
||||
//
|
||||
CategoryTextBox.Location = new Point(81, 35);
|
||||
CategoryTextBox.Name = "CategoryTextBox";
|
||||
CategoryTextBox.Size = new Size(237, 23);
|
||||
CategoryTextBox.TabIndex = 8;
|
||||
//
|
||||
// FormDish
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(606, 449);
|
||||
Controls.Add(CategoryTextBox);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(CancelButton);
|
||||
Controls.Add(SaveButton);
|
||||
Controls.Add(ComponentsGroupBox);
|
||||
Controls.Add(PriceTextBox);
|
||||
Controls.Add(NameTextBox);
|
||||
Controls.Add(PriceLabel);
|
||||
Controls.Add(NameLabel);
|
||||
Name = "FormDish";
|
||||
Text = "Блюдо";
|
||||
Load += FormDish_Load;
|
||||
ComponentsGroupBox.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label NameLabel;
|
||||
private Label PriceLabel;
|
||||
private TextBox NameTextBox;
|
||||
private TextBox PriceTextBox;
|
||||
private GroupBox ComponentsGroupBox;
|
||||
private Button RefreshButton;
|
||||
private Button DeleteButton;
|
||||
private Button UpdateButton;
|
||||
private Button AddButton;
|
||||
private DataGridView DataGridView;
|
||||
private DataGridViewTextBoxColumn IdColumn;
|
||||
private DataGridViewTextBoxColumn IngredientNameColumn;
|
||||
private DataGridViewTextBoxColumn CountColumn;
|
||||
private Button SaveButton;
|
||||
private Button CancelButton;
|
||||
private Label label1;
|
||||
private TextBox CategoryTextBox;
|
||||
}
|
||||
}
|
205
SushiBarView/Forms/FormDish.cs
Normal file
205
SushiBarView/Forms/FormDish.cs
Normal file
@ -0,0 +1,205 @@
|
||||
using SushiBarBusinessLogic;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
using SushiBarDataModels.Models;
|
||||
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
public partial class FormDish : Form
|
||||
{
|
||||
private readonly DishLogic _dishLogic;
|
||||
|
||||
private int? _id;
|
||||
private Dictionary<int, (IIngredientModel, int)> _dishIngredients;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormDish(DishLogic DishLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_dishLogic = DishLogic;
|
||||
_dishIngredients = new Dictionary<int, (IIngredientModel, int)>();
|
||||
}
|
||||
|
||||
private void FormDish_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var View = _dishLogic.ReadElement(new DishSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
|
||||
if (View != null)
|
||||
{
|
||||
NameTextBox.Text = View.DishName;
|
||||
CategoryTextBox.Text = View.Category;
|
||||
PriceTextBox.Text = View.Price.ToString();
|
||||
|
||||
_dishIngredients = View.DishIngredients ?? new Dictionary<int, (IIngredientModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_dishIngredients != null)
|
||||
{
|
||||
DataGridView.Rows.Clear();
|
||||
foreach (var Ingredient in _dishIngredients)
|
||||
{
|
||||
DataGridView.Rows.Add(new object[] { Ingredient.Key, Ingredient.Value.Item1.IngredientName, Ingredient.Value.Item2 });
|
||||
}
|
||||
|
||||
PriceTextBox.Text = CalcPrice().ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Form = new FormDishIngredient(new IngredientLogic(new SushiBarDatabaseImplement.Storages.IngredientStorage()));
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (Form.IngredientModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_dishIngredients.ContainsKey(Form.Id))
|
||||
{
|
||||
_dishIngredients[Form.Id] = (Form.IngredientModel, Form.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
_dishIngredients.Add(Form.Id, (Form.IngredientModel, Form.Count));
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var Form = new FormDishIngredient(new IngredientLogic(new SushiBarDatabaseImplement.Storages.IngredientStorage()));
|
||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value);
|
||||
Form.Id = id;
|
||||
Form.Count = _dishIngredients[id].Item2;
|
||||
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (Form.IngredientModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_dishIngredients[Form.Id] = (Form.IngredientModel, Form.Count);
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
try
|
||||
{
|
||||
_dishIngredients?.Remove(Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(NameTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(PriceTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_dishIngredients == null || _dishIngredients.Count == 0)
|
||||
{
|
||||
MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var Мodel = new DishBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
DishName = NameTextBox.Text,
|
||||
Category = CategoryTextBox.Text,
|
||||
Price = Convert.ToDouble(PriceTextBox.Text),
|
||||
DishIngredients = _dishIngredients,
|
||||
};
|
||||
|
||||
var OperationResult = _id.HasValue ? _dishLogic.Update(Мodel) : _dishLogic.Create(Мodel);
|
||||
|
||||
if (!OperationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private double CalcPrice()
|
||||
{
|
||||
double Price = 0;
|
||||
|
||||
foreach (var Elem in _dishIngredients)
|
||||
{
|
||||
Price += ((Elem.Value.Item1?.Cost ?? 0) * Elem.Value.Item2);
|
||||
}
|
||||
|
||||
return Math.Round(Price * 1.1, 2);
|
||||
}
|
||||
}
|
||||
}
|
120
SushiBarView/Forms/FormDish.resx
Normal file
120
SushiBarView/Forms/FormDish.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
119
SushiBarView/Forms/FormDishIngredient.Designer.cs
generated
Normal file
119
SushiBarView/Forms/FormDishIngredient.Designer.cs
generated
Normal file
@ -0,0 +1,119 @@
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
partial class FormDishIngredient
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
ComponentLabel = new Label();
|
||||
CountLabel = new Label();
|
||||
CountTextBox = new TextBox();
|
||||
ComboBox = new ComboBox();
|
||||
SaveButton = new Button();
|
||||
CancelButton = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// ComponentLabel
|
||||
//
|
||||
ComponentLabel.AutoSize = true;
|
||||
ComponentLabel.Location = new Point(14, 15);
|
||||
ComponentLabel.Name = "ComponentLabel";
|
||||
ComponentLabel.Size = new Size(75, 15);
|
||||
ComponentLabel.TabIndex = 0;
|
||||
ComponentLabel.Text = "Ингредиент:";
|
||||
//
|
||||
// CountLabel
|
||||
//
|
||||
CountLabel.AutoSize = true;
|
||||
CountLabel.Location = new Point(14, 46);
|
||||
CountLabel.Name = "CountLabel";
|
||||
CountLabel.Size = new Size(75, 15);
|
||||
CountLabel.TabIndex = 1;
|
||||
CountLabel.Text = "Количество:";
|
||||
//
|
||||
// CountTextBox
|
||||
//
|
||||
CountTextBox.Location = new Point(95, 43);
|
||||
CountTextBox.Name = "CountTextBox";
|
||||
CountTextBox.Size = new Size(292, 23);
|
||||
CountTextBox.TabIndex = 2;
|
||||
//
|
||||
// ComboBox
|
||||
//
|
||||
ComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
ComboBox.FormattingEnabled = true;
|
||||
ComboBox.Location = new Point(95, 12);
|
||||
ComboBox.Name = "ComboBox";
|
||||
ComboBox.Size = new Size(292, 23);
|
||||
ComboBox.TabIndex = 3;
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
SaveButton.Location = new Point(205, 81);
|
||||
SaveButton.Name = "SaveButton";
|
||||
SaveButton.Size = new Size(90, 32);
|
||||
SaveButton.TabIndex = 4;
|
||||
SaveButton.Text = "Сохранить";
|
||||
SaveButton.UseVisualStyleBackColor = true;
|
||||
SaveButton.Click += ButtonSave_Click;
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
CancelButton.Location = new Point(301, 81);
|
||||
CancelButton.Name = "CancelButton";
|
||||
CancelButton.Size = new Size(86, 32);
|
||||
CancelButton.TabIndex = 5;
|
||||
CancelButton.Text = "Отмена";
|
||||
CancelButton.UseVisualStyleBackColor = true;
|
||||
CancelButton.Click += ButtonCancel_Click;
|
||||
//
|
||||
// FormDishIngredient
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(407, 130);
|
||||
Controls.Add(CancelButton);
|
||||
Controls.Add(SaveButton);
|
||||
Controls.Add(ComboBox);
|
||||
Controls.Add(CountTextBox);
|
||||
Controls.Add(CountLabel);
|
||||
Controls.Add(ComponentLabel);
|
||||
Name = "FormDishIngredient";
|
||||
Text = "Ингредиент блюда";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label ComponentLabel;
|
||||
private Label CountLabel;
|
||||
private TextBox CountTextBox;
|
||||
private ComboBox ComboBox;
|
||||
private Button SaveButton;
|
||||
private Button CancelButton;
|
||||
}
|
||||
}
|
87
SushiBarView/Forms/FormDishIngredient.cs
Normal file
87
SushiBarView/Forms/FormDishIngredient.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using SushiBarBusinessLogic;
|
||||
using SushiBarContracts.ViewModels;
|
||||
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
public partial class FormDishIngredient : Form
|
||||
{
|
||||
private readonly List<IngredientViewModel>? _list;
|
||||
|
||||
public int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(ComboBox.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
ComboBox.SelectedValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
public IngredientViewModel? IngredientModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var Elem in _list)
|
||||
{
|
||||
if (Elem.Id == Id)
|
||||
{
|
||||
return Elem;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return Convert.ToInt32(CountTextBox.Text); }
|
||||
set { CountTextBox.Text = value.ToString(); }
|
||||
}
|
||||
|
||||
public FormDishIngredient(IngredientLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_list = Logic.ReadList(null);
|
||||
|
||||
if (_list != null)
|
||||
{
|
||||
ComboBox.DisplayMember = "IngredientName";
|
||||
ComboBox.ValueMember = "Id";
|
||||
ComboBox.DataSource = _list;
|
||||
ComboBox.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(CountTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите ингредиент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
SushiBarView/Forms/FormDishIngredient.resx
Normal file
120
SushiBarView/Forms/FormDishIngredient.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
113
SushiBarView/Forms/FormDishes.Designer.cs
generated
Normal file
113
SushiBarView/Forms/FormDishes.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
partial class FormDishes
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
DataGridView = new DataGridView();
|
||||
AddButton = new Button();
|
||||
ChangeButton = new Button();
|
||||
DeleteButton = new Button();
|
||||
UpdateButton = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Location = new Point(12, 12);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.RowTemplate.Height = 25;
|
||||
DataGridView.Size = new Size(413, 358);
|
||||
DataGridView.TabIndex = 0;
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
AddButton.Location = new Point(431, 12);
|
||||
AddButton.Name = "AddButton";
|
||||
AddButton.Size = new Size(138, 29);
|
||||
AddButton.TabIndex = 1;
|
||||
AddButton.Text = "Добавить";
|
||||
AddButton.UseVisualStyleBackColor = true;
|
||||
AddButton.Click += AddButton_Click;
|
||||
//
|
||||
// ChangeButton
|
||||
//
|
||||
ChangeButton.Location = new Point(431, 47);
|
||||
ChangeButton.Name = "ChangeButton";
|
||||
ChangeButton.Size = new Size(138, 29);
|
||||
ChangeButton.TabIndex = 2;
|
||||
ChangeButton.Text = "Изменить";
|
||||
ChangeButton.UseVisualStyleBackColor = true;
|
||||
ChangeButton.Click += UpdateButton_Click;
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
DeleteButton.Location = new Point(431, 82);
|
||||
DeleteButton.Name = "DeleteButton";
|
||||
DeleteButton.Size = new Size(138, 29);
|
||||
DeleteButton.TabIndex = 3;
|
||||
DeleteButton.Text = "Удалить";
|
||||
DeleteButton.UseVisualStyleBackColor = true;
|
||||
DeleteButton.Click += DeleteButton_Click;
|
||||
//
|
||||
// UpdateButton
|
||||
//
|
||||
UpdateButton.Location = new Point(431, 117);
|
||||
UpdateButton.Name = "UpdateButton";
|
||||
UpdateButton.Size = new Size(138, 29);
|
||||
UpdateButton.TabIndex = 4;
|
||||
UpdateButton.Text = "Обновить";
|
||||
UpdateButton.UseVisualStyleBackColor = true;
|
||||
UpdateButton.Click += RefreshButton_Click;
|
||||
//
|
||||
// FormDishes
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(580, 384);
|
||||
Controls.Add(UpdateButton);
|
||||
Controls.Add(DeleteButton);
|
||||
Controls.Add(ChangeButton);
|
||||
Controls.Add(AddButton);
|
||||
Controls.Add(DataGridView);
|
||||
Name = "FormDishes";
|
||||
Text = "FormDishes";
|
||||
Load += FormDishes_Load;
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView DataGridView;
|
||||
private Button AddButton;
|
||||
private Button ChangeButton;
|
||||
private Button DeleteButton;
|
||||
private Button UpdateButton;
|
||||
}
|
||||
}
|
97
SushiBarView/Forms/FormDishes.cs
Normal file
97
SushiBarView/Forms/FormDishes.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using SushiBarBusinessLogic;
|
||||
using SushiBarContracts.BindingModels;
|
||||
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
public partial class FormDishes : Form
|
||||
{
|
||||
private readonly DishLogic _logic;
|
||||
|
||||
public FormDishes(DishLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = Logic;
|
||||
}
|
||||
|
||||
private void FormDishes_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var List = _logic.ReadList(null);
|
||||
|
||||
if (List != null)
|
||||
{
|
||||
DataGridView.DataSource = List;
|
||||
DataGridView.Columns["Id"].Visible = false;
|
||||
DataGridView.Columns["DishName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
DataGridView.Columns["DishIngredients"].Visible = false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormDish Form = new FormDish(new DishLogic(new SushiBarDatabaseImplement.Storages.DishStorage()));
|
||||
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
FormDish Form = new FormDish(new DishLogic(new SushiBarDatabaseImplement.Storages.DishStorage()));
|
||||
Form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new DishBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
SushiBarView/Forms/FormDishes.resx
Normal file
120
SushiBarView/Forms/FormDishes.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
127
SushiBarView/Forms/FormIngredient.Designer.cs
generated
Normal file
127
SushiBarView/Forms/FormIngredient.Designer.cs
generated
Normal file
@ -0,0 +1,127 @@
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
partial class FormIngredient
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
CostTextBox = new TextBox();
|
||||
UnitTextBox = new TextBox();
|
||||
IngredientNameTextBox = new TextBox();
|
||||
SaveButton = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 15);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(93, 15);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Наименование:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(12, 44);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(122, 15);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Единицы измерения:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(12, 73);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(133, 15);
|
||||
label3.TabIndex = 2;
|
||||
label3.Text = "Стоимость за единицу:";
|
||||
//
|
||||
// CostTextBox
|
||||
//
|
||||
CostTextBox.Location = new Point(151, 70);
|
||||
CostTextBox.Name = "CostTextBox";
|
||||
CostTextBox.Size = new Size(86, 23);
|
||||
CostTextBox.TabIndex = 3;
|
||||
//
|
||||
// UnitTextBox
|
||||
//
|
||||
UnitTextBox.Location = new Point(151, 41);
|
||||
UnitTextBox.Name = "UnitTextBox";
|
||||
UnitTextBox.Size = new Size(170, 23);
|
||||
UnitTextBox.TabIndex = 4;
|
||||
//
|
||||
// IngredientNameTextBox
|
||||
//
|
||||
IngredientNameTextBox.Location = new Point(151, 12);
|
||||
IngredientNameTextBox.Name = "IngredientNameTextBox";
|
||||
IngredientNameTextBox.Size = new Size(170, 23);
|
||||
IngredientNameTextBox.TabIndex = 5;
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
SaveButton.Location = new Point(219, 109);
|
||||
SaveButton.Name = "SaveButton";
|
||||
SaveButton.Size = new Size(102, 30);
|
||||
SaveButton.TabIndex = 6;
|
||||
SaveButton.Text = "Сохранить";
|
||||
SaveButton.UseVisualStyleBackColor = true;
|
||||
SaveButton.Click += ButtonSave_Click;
|
||||
//
|
||||
// FormIngredient
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(335, 151);
|
||||
Controls.Add(SaveButton);
|
||||
Controls.Add(IngredientNameTextBox);
|
||||
Controls.Add(UnitTextBox);
|
||||
Controls.Add(CostTextBox);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Name = "FormIngredient";
|
||||
Text = "Ингредиент";
|
||||
Load += FormIngredient_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private TextBox CostTextBox;
|
||||
private TextBox UnitTextBox;
|
||||
private TextBox IngredientNameTextBox;
|
||||
private Button SaveButton;
|
||||
}
|
||||
}
|
81
SushiBarView/Forms/FormIngredient.cs
Normal file
81
SushiBarView/Forms/FormIngredient.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using SushiBarBusinessLogic;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
public partial class FormIngredient : Form
|
||||
{
|
||||
private readonly IngredientLogic _logic;
|
||||
|
||||
private int? _id;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormIngredient(IngredientLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = Logic;
|
||||
}
|
||||
|
||||
private void FormIngredient_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var View = _logic.ReadElement(new IngredientSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
|
||||
if (View != null)
|
||||
{
|
||||
IngredientNameTextBox.Text = View.IngredientName;
|
||||
UnitTextBox.Text = View.Unit;
|
||||
CostTextBox.Text = View.Cost.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(IngredientNameTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var Model = new IngredientBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
IngredientName = IngredientNameTextBox.Text,
|
||||
Unit = UnitTextBox.Text,
|
||||
Cost = Convert.ToDouble(CostTextBox.Text),
|
||||
};
|
||||
|
||||
var OperationResult = _id.HasValue ? _logic.Update(Model) : _logic.Create(Model);
|
||||
|
||||
if (!OperationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка сохранения ингредиента", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
SushiBarView/Forms/FormIngredient.resx
Normal file
120
SushiBarView/Forms/FormIngredient.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
113
SushiBarView/Forms/FormIngredients.Designer.cs
generated
Normal file
113
SushiBarView/Forms/FormIngredients.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
partial class FormIngredients
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
DataGridView = new DataGridView();
|
||||
AddButton = new Button();
|
||||
ChangeButton = new Button();
|
||||
DeleteButton = new Button();
|
||||
UpdateButton = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Location = new Point(12, 12);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.RowTemplate.Height = 25;
|
||||
DataGridView.Size = new Size(413, 358);
|
||||
DataGridView.TabIndex = 0;
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
AddButton.Location = new Point(431, 12);
|
||||
AddButton.Name = "AddButton";
|
||||
AddButton.Size = new Size(138, 29);
|
||||
AddButton.TabIndex = 1;
|
||||
AddButton.Text = "Добавить";
|
||||
AddButton.UseVisualStyleBackColor = true;
|
||||
AddButton.Click += AddButton_Click;
|
||||
//
|
||||
// ChangeButton
|
||||
//
|
||||
ChangeButton.Location = new Point(431, 47);
|
||||
ChangeButton.Name = "ChangeButton";
|
||||
ChangeButton.Size = new Size(138, 29);
|
||||
ChangeButton.TabIndex = 2;
|
||||
ChangeButton.Text = "Изменить";
|
||||
ChangeButton.UseVisualStyleBackColor = true;
|
||||
ChangeButton.Click += ChangeButton_Click;
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
DeleteButton.Location = new Point(431, 82);
|
||||
DeleteButton.Name = "DeleteButton";
|
||||
DeleteButton.Size = new Size(138, 29);
|
||||
DeleteButton.TabIndex = 3;
|
||||
DeleteButton.Text = "Удалить";
|
||||
DeleteButton.UseVisualStyleBackColor = true;
|
||||
DeleteButton.Click += DeleteButton_Click;
|
||||
//
|
||||
// UpdateButton
|
||||
//
|
||||
UpdateButton.Location = new Point(431, 117);
|
||||
UpdateButton.Name = "UpdateButton";
|
||||
UpdateButton.Size = new Size(138, 29);
|
||||
UpdateButton.TabIndex = 4;
|
||||
UpdateButton.Text = "Обновить";
|
||||
UpdateButton.UseVisualStyleBackColor = true;
|
||||
UpdateButton.Click += RefreshButton_Click;
|
||||
//
|
||||
// FormIngredients
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(580, 384);
|
||||
Controls.Add(UpdateButton);
|
||||
Controls.Add(DeleteButton);
|
||||
Controls.Add(ChangeButton);
|
||||
Controls.Add(AddButton);
|
||||
Controls.Add(DataGridView);
|
||||
Name = "FormIngredients";
|
||||
Text = "Ингредиенты";
|
||||
Load += FormIngredients_Load;
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView DataGridView;
|
||||
private Button AddButton;
|
||||
private Button ChangeButton;
|
||||
private Button DeleteButton;
|
||||
private Button UpdateButton;
|
||||
}
|
||||
}
|
98
SushiBarView/Forms/FormIngredients.cs
Normal file
98
SushiBarView/Forms/FormIngredients.cs
Normal file
@ -0,0 +1,98 @@
|
||||
using SushiBarBusinessLogic;
|
||||
using SushiBarContracts.BindingModels;
|
||||
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
public partial class FormIngredients : Form
|
||||
{
|
||||
private readonly IngredientLogic _logic;
|
||||
|
||||
public FormIngredients(IngredientLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = Logic;
|
||||
}
|
||||
|
||||
private void FormIngredients_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var List = _logic.ReadList(null);
|
||||
|
||||
if (List != null)
|
||||
{
|
||||
DataGridView.DataSource = List;
|
||||
DataGridView.Columns["Id"].Visible = false;
|
||||
DataGridView.Columns["IngredientName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormIngredient Form = new FormIngredient(new IngredientLogic(new SushiBarDatabaseImplement.Storages.IngredientStorage()));
|
||||
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
FormIngredient Form = new FormIngredient(new IngredientLogic(new SushiBarDatabaseImplement.Storages.IngredientStorage()));
|
||||
Form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new IngredientBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
SushiBarView/Forms/FormIngredients.resx
Normal file
120
SushiBarView/Forms/FormIngredients.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
127
SushiBarView/Forms/FormPromotion.Designer.cs
generated
Normal file
127
SushiBarView/Forms/FormPromotion.Designer.cs
generated
Normal file
@ -0,0 +1,127 @@
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
partial class FormPromotion
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
label1 = new Label();
|
||||
NameTextBox = new TextBox();
|
||||
label2 = new Label();
|
||||
button1 = new Button();
|
||||
DiscountTextBox = new TextBox();
|
||||
TriggeringSumTextBox = new TextBox();
|
||||
label3 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 15);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(59, 15);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Название";
|
||||
//
|
||||
// NameTextBox
|
||||
//
|
||||
NameTextBox.Location = new Point(187, 12);
|
||||
NameTextBox.Name = "NameTextBox";
|
||||
NameTextBox.Size = new Size(200, 23);
|
||||
NameTextBox.TabIndex = 1;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(12, 44);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(88, 15);
|
||||
label2.TabIndex = 2;
|
||||
label2.Text = "Размер скидки";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(298, 108);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(89, 28);
|
||||
button1.TabIndex = 4;
|
||||
button1.Text = "Сохранить";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += ButtonSave_Click;
|
||||
//
|
||||
// DiscountTextBox
|
||||
//
|
||||
DiscountTextBox.Location = new Point(187, 41);
|
||||
DiscountTextBox.Name = "DiscountTextBox";
|
||||
DiscountTextBox.Size = new Size(200, 23);
|
||||
DiscountTextBox.TabIndex = 5;
|
||||
//
|
||||
// TriggeringSumTextBox
|
||||
//
|
||||
TriggeringSumTextBox.Location = new Point(187, 70);
|
||||
TriggeringSumTextBox.Name = "TriggeringSumTextBox";
|
||||
TriggeringSumTextBox.Size = new Size(200, 23);
|
||||
TriggeringSumTextBox.TabIndex = 6;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(12, 73);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(169, 15);
|
||||
label3.TabIndex = 7;
|
||||
label3.Text = "Минимальная сумма заказов";
|
||||
//
|
||||
// FormPromotion
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(397, 145);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(TriggeringSumTextBox);
|
||||
Controls.Add(DiscountTextBox);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(NameTextBox);
|
||||
Controls.Add(label1);
|
||||
Name = "FormPromotion";
|
||||
Text = "Акция";
|
||||
Load += FormPromotion_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private TextBox NameTextBox;
|
||||
private Label label2;
|
||||
private Button button1;
|
||||
private TextBox DiscountTextBox;
|
||||
private TextBox TriggeringSumTextBox;
|
||||
private Label label3;
|
||||
}
|
||||
}
|
80
SushiBarView/Forms/FormPromotion.cs
Normal file
80
SushiBarView/Forms/FormPromotion.cs
Normal file
@ -0,0 +1,80 @@
|
||||
using SushiBarBusinessLogic;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.SearchModels;
|
||||
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
public partial class FormPromotion : Form
|
||||
{
|
||||
private readonly PromotionLogic _logic;
|
||||
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormPromotion(PromotionLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = Logic;
|
||||
}
|
||||
|
||||
private void FormPromotion_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var View = _logic.ReadElement(new PromotionSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
|
||||
if (View != null)
|
||||
{
|
||||
NameTextBox.Text = View.PromotionName;
|
||||
DiscountTextBox.Text = View.Discount.ToString();
|
||||
TriggeringSumTextBox.Text = View.TriggeringSum.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(NameTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var Model = new PromotionBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
PromotionName = NameTextBox.Text,
|
||||
Discount = float.Parse(DiscountTextBox.Text),
|
||||
TriggeringSum = Double.Parse(TriggeringSumTextBox.Text),
|
||||
};
|
||||
|
||||
var OperationResult = _id.HasValue ? _logic.Update(Model) : _logic.Create(Model);
|
||||
|
||||
if (!OperationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка сохранения акции", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
SushiBarView/Forms/FormPromotion.resx
Normal file
120
SushiBarView/Forms/FormPromotion.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
113
SushiBarView/Forms/FormPromotions.Designer.cs
generated
Normal file
113
SushiBarView/Forms/FormPromotions.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
partial class FormPromotions
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
DataGridView = new DataGridView();
|
||||
AddButton = new Button();
|
||||
ChangeButton = new Button();
|
||||
DeleteButton = new Button();
|
||||
UpdateButton = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Location = new Point(12, 12);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.RowTemplate.Height = 25;
|
||||
DataGridView.Size = new Size(413, 358);
|
||||
DataGridView.TabIndex = 0;
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
AddButton.Location = new Point(431, 12);
|
||||
AddButton.Name = "AddButton";
|
||||
AddButton.Size = new Size(138, 29);
|
||||
AddButton.TabIndex = 1;
|
||||
AddButton.Text = "Добавить";
|
||||
AddButton.UseVisualStyleBackColor = true;
|
||||
AddButton.Click += AddButton_Click;
|
||||
//
|
||||
// ChangeButton
|
||||
//
|
||||
ChangeButton.Location = new Point(431, 47);
|
||||
ChangeButton.Name = "ChangeButton";
|
||||
ChangeButton.Size = new Size(138, 29);
|
||||
ChangeButton.TabIndex = 2;
|
||||
ChangeButton.Text = "Изменить";
|
||||
ChangeButton.UseVisualStyleBackColor = true;
|
||||
ChangeButton.Click += ChangeButton_Click;
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
DeleteButton.Location = new Point(431, 82);
|
||||
DeleteButton.Name = "DeleteButton";
|
||||
DeleteButton.Size = new Size(138, 29);
|
||||
DeleteButton.TabIndex = 3;
|
||||
DeleteButton.Text = "Удалить";
|
||||
DeleteButton.UseVisualStyleBackColor = true;
|
||||
DeleteButton.Click += DeleteButton_Click;
|
||||
//
|
||||
// UpdateButton
|
||||
//
|
||||
UpdateButton.Location = new Point(431, 117);
|
||||
UpdateButton.Name = "UpdateButton";
|
||||
UpdateButton.Size = new Size(138, 29);
|
||||
UpdateButton.TabIndex = 4;
|
||||
UpdateButton.Text = "Обновить";
|
||||
UpdateButton.UseVisualStyleBackColor = true;
|
||||
UpdateButton.Click += RefreshButton_Click;
|
||||
//
|
||||
// FormPromotions
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(580, 384);
|
||||
Controls.Add(UpdateButton);
|
||||
Controls.Add(DeleteButton);
|
||||
Controls.Add(ChangeButton);
|
||||
Controls.Add(AddButton);
|
||||
Controls.Add(DataGridView);
|
||||
Name = "FormPromotions";
|
||||
Text = "Акции";
|
||||
Load += FormPromotions_Load;
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView DataGridView;
|
||||
private Button AddButton;
|
||||
private Button ChangeButton;
|
||||
private Button DeleteButton;
|
||||
private Button UpdateButton;
|
||||
}
|
||||
}
|
98
SushiBarView/Forms/FormPromotions.cs
Normal file
98
SushiBarView/Forms/FormPromotions.cs
Normal file
@ -0,0 +1,98 @@
|
||||
using SushiBarBusinessLogic;
|
||||
using SushiBarContracts.BindingModels;
|
||||
|
||||
namespace SushiBarView.Forms
|
||||
{
|
||||
public partial class FormPromotions : Form
|
||||
{
|
||||
private readonly PromotionLogic _logic;
|
||||
|
||||
public FormPromotions(PromotionLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = Logic;
|
||||
}
|
||||
|
||||
private void FormPromotions_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var List = _logic.ReadList(null);
|
||||
|
||||
if (List != null)
|
||||
{
|
||||
DataGridView.DataSource = List;
|
||||
DataGridView.Columns["Id"].Visible = false;
|
||||
DataGridView.Columns["PromotionName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
DataGridView.Columns["Discount"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormPromotion Form = new FormPromotion(new PromotionLogic(new SushiBarDatabaseImplement.Storages.PromotionStorage()));
|
||||
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
FormPromotion Form = new FormPromotion(new PromotionLogic(new SushiBarDatabaseImplement.Storages.PromotionStorage()));
|
||||
Form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new PromotionBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
SushiBarView/Forms/FormPromotions.resx
Normal file
120
SushiBarView/Forms/FormPromotions.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
174
SushiBarView/MainForm.Designer.cs
generated
Normal file
174
SushiBarView/MainForm.Designer.cs
generated
Normal file
@ -0,0 +1,174 @@
|
||||
namespace SushiBarView
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
menuStrip1 = new MenuStrip();
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
IngredientsToolStripMenuItem = new ToolStripMenuItem();
|
||||
DishesToolStripMenuItem = new ToolStripMenuItem();
|
||||
CooksToolStripMenuItem = new ToolStripMenuItem();
|
||||
CustomersToolStripMenuItem = new ToolStripMenuItem();
|
||||
PromotionsToolStripMenuItem = new ToolStripMenuItem();
|
||||
DataGridView = new DataGridView();
|
||||
CreateOrderButton = new Button();
|
||||
RefreshButton = new Button();
|
||||
ChequeInfoButton = new Button();
|
||||
menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(1189, 24);
|
||||
menuStrip1.TabIndex = 0;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { IngredientsToolStripMenuItem, DishesToolStripMenuItem, CooksToolStripMenuItem, CustomersToolStripMenuItem, PromotionsToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(94, 20);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// IngredientsToolStripMenuItem
|
||||
//
|
||||
IngredientsToolStripMenuItem.Name = "IngredientsToolStripMenuItem";
|
||||
IngredientsToolStripMenuItem.Size = new Size(148, 22);
|
||||
IngredientsToolStripMenuItem.Text = "Ингредиенты";
|
||||
IngredientsToolStripMenuItem.Click += IngredientsToolStripMenuItem_Click;
|
||||
//
|
||||
// DishesToolStripMenuItem
|
||||
//
|
||||
DishesToolStripMenuItem.Name = "DishesToolStripMenuItem";
|
||||
DishesToolStripMenuItem.Size = new Size(148, 22);
|
||||
DishesToolStripMenuItem.Text = "Блюда";
|
||||
DishesToolStripMenuItem.Click += DishesToolStripMenuItem_Click;
|
||||
//
|
||||
// CooksToolStripMenuItem
|
||||
//
|
||||
CooksToolStripMenuItem.Name = "CooksToolStripMenuItem";
|
||||
CooksToolStripMenuItem.Size = new Size(148, 22);
|
||||
CooksToolStripMenuItem.Text = "Повара";
|
||||
CooksToolStripMenuItem.Click += CooksToolStripMenuItem_Click;
|
||||
//
|
||||
// CustomersToolStripMenuItem
|
||||
//
|
||||
CustomersToolStripMenuItem.Name = "CustomersToolStripMenuItem";
|
||||
CustomersToolStripMenuItem.Size = new Size(148, 22);
|
||||
CustomersToolStripMenuItem.Text = "Покупатели";
|
||||
CustomersToolStripMenuItem.Click += CustomersToolStripMenuItem_Click;
|
||||
//
|
||||
// PromotionsToolStripMenuItem
|
||||
//
|
||||
PromotionsToolStripMenuItem.Name = "PromotionsToolStripMenuItem";
|
||||
PromotionsToolStripMenuItem.Size = new Size(148, 22);
|
||||
PromotionsToolStripMenuItem.Text = "Акции";
|
||||
PromotionsToolStripMenuItem.Click += PromotionsToolStripMenuItem_Click;
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Location = new Point(12, 27);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.RowTemplate.Height = 25;
|
||||
DataGridView.Size = new Size(931, 370);
|
||||
DataGridView.TabIndex = 1;
|
||||
//
|
||||
// CreateOrderButton
|
||||
//
|
||||
CreateOrderButton.Location = new Point(949, 27);
|
||||
CreateOrderButton.Margin = new Padding(3, 2, 3, 2);
|
||||
CreateOrderButton.Name = "CreateOrderButton";
|
||||
CreateOrderButton.Size = new Size(227, 30);
|
||||
CreateOrderButton.TabIndex = 3;
|
||||
CreateOrderButton.Text = "Создать заказ";
|
||||
CreateOrderButton.UseVisualStyleBackColor = true;
|
||||
CreateOrderButton.Click += CreateOrderButton_Click;
|
||||
//
|
||||
// RefreshButton
|
||||
//
|
||||
RefreshButton.Location = new Point(949, 61);
|
||||
RefreshButton.Margin = new Padding(3, 2, 3, 2);
|
||||
RefreshButton.Name = "RefreshButton";
|
||||
RefreshButton.Size = new Size(227, 30);
|
||||
RefreshButton.TabIndex = 7;
|
||||
RefreshButton.Text = "Обновить";
|
||||
RefreshButton.UseVisualStyleBackColor = true;
|
||||
RefreshButton.Click += RefreshButton_Click;
|
||||
//
|
||||
// ChequeInfoButton
|
||||
//
|
||||
ChequeInfoButton.Location = new Point(950, 114);
|
||||
ChequeInfoButton.Margin = new Padding(3, 2, 3, 2);
|
||||
ChequeInfoButton.Name = "ChequeInfoButton";
|
||||
ChequeInfoButton.Size = new Size(227, 30);
|
||||
ChequeInfoButton.TabIndex = 8;
|
||||
ChequeInfoButton.Text = "Информация о заказе";
|
||||
ChequeInfoButton.UseVisualStyleBackColor = true;
|
||||
ChequeInfoButton.Click += ChequeInfo_Click;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1189, 405);
|
||||
Controls.Add(ChequeInfoButton);
|
||||
Controls.Add(RefreshButton);
|
||||
Controls.Add(CreateOrderButton);
|
||||
Controls.Add(DataGridView);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "MainForm";
|
||||
Text = "MainForm";
|
||||
Load += MainForm_Load;
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem IngredientsToolStripMenuItem;
|
||||
private ToolStripMenuItem DishesToolStripMenuItem;
|
||||
private ToolStripMenuItem CooksToolStripMenuItem;
|
||||
private ToolStripMenuItem CustomersToolStripMenuItem;
|
||||
private ToolStripMenuItem PromotionsToolStripMenuItem;
|
||||
private DataGridView DataGridView;
|
||||
private Button CreateOrderButton;
|
||||
private Button RefreshButton;
|
||||
private Button ChequeInfoButton;
|
||||
}
|
||||
}
|
99
SushiBarView/MainForm.cs
Normal file
99
SushiBarView/MainForm.cs
Normal file
@ -0,0 +1,99 @@
|
||||
using SushiBarBusinessLogic;
|
||||
using SushiBarView.Forms;
|
||||
|
||||
namespace SushiBarView
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
private readonly ChequeLogic _chequeLogic;
|
||||
|
||||
public MainForm(ChequeLogic ChequeLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_chequeLogic = ChequeLogic;
|
||||
}
|
||||
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var List = _chequeLogic.ReadList(null);
|
||||
|
||||
if (List != null)
|
||||
{
|
||||
DataGridView.DataSource = List;
|
||||
DataGridView.Columns["CustomerId"].Visible = false;
|
||||
DataGridView.Columns["PromotionId"].Visible = false;
|
||||
DataGridView.Columns["ChequeItems"].Visible = false;
|
||||
DataGridView.Columns["OrderDate"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
DataGridView.Columns["TotalSum"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void IngredientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormIngredients Form = new FormIngredients(new SushiBarBusinessLogic.IngredientLogic(new SushiBarDatabaseImplement.Storages.IngredientStorage()));
|
||||
Form.ShowDialog();
|
||||
}
|
||||
|
||||
private void DishesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormDishes Form = new FormDishes(new SushiBarBusinessLogic.DishLogic(new SushiBarDatabaseImplement.Storages.DishStorage()));
|
||||
Form.ShowDialog();
|
||||
}
|
||||
|
||||
private void CooksToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormCooks Form = new FormCooks(new SushiBarBusinessLogic.CookLogic(new SushiBarDatabaseImplement.Storages.CookStorage()));
|
||||
Form.ShowDialog();
|
||||
}
|
||||
|
||||
private void CustomersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormCustomers Form = new FormCustomers(new SushiBarBusinessLogic.CustomerLogic(new SushiBarDatabaseImplement.Storages.CustomerStorage()));
|
||||
Form.ShowDialog();
|
||||
}
|
||||
|
||||
private void PromotionsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormPromotions Form = new FormPromotions(new SushiBarBusinessLogic.PromotionLogic(new SushiBarDatabaseImplement.Storages.PromotionStorage()));
|
||||
Form.ShowDialog();
|
||||
}
|
||||
|
||||
private void CreateOrderButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormCreateCheque Form = new FormCreateCheque(
|
||||
new ChequeLogic(new SushiBarDatabaseImplement.Storages.ChequeStorage()),
|
||||
new CustomerLogic(new SushiBarDatabaseImplement.Storages.CustomerStorage()));
|
||||
|
||||
Form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ChequeInfo_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormCreateCheque Form = new FormCreateCheque(
|
||||
new ChequeLogic(new SushiBarDatabaseImplement.Storages.ChequeStorage()),
|
||||
new CustomerLogic(new SushiBarDatabaseImplement.Storages.CustomerStorage()));
|
||||
Form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
Form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
123
SushiBarView/MainForm.resx
Normal file
123
SushiBarView/MainForm.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1,17 +1,11 @@
|
||||
namespace SushiBar
|
||||
namespace SushiBarView
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new MainForm(new SushiBarBusinessLogic.ChequeLogic(new SushiBarDatabaseImplement.Storages.ChequeStorage())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SushiBarBusinessLogic\SushiBarBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\SushiBarDatabaseImplement\SushiBarDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user