- installation_-_sqlexpr.zip
- Makanan2
- John Kenedy DAL.pdf
- JohnKenedy.DataAccess
- JohnKenedy.DataAccessModule
- MenuMakanan
- ProgramTools.sln
- ProgramTools.suo
- SetupMakanan
- Debug
- Release
- SetupMakanan.vdproj
- SetupMakananSqlExpr
- Debug
- Release
- SetupMakananSqlExpr.vdproj
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using JohnKenedy.DataAccess;
using JohnKenedy.Samples;
namespace MenuMakanan
{
public partial class MenuFoodDetail : Form
{
public MFoodEntity Header { get; set; }
public MIngredientsEntityCollection Detail { get; set; }
public MenuFoodDetail()
{
InitializeComponent();
}
private void MenuFoodDetail_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
dataGridView1.AutoGenerateColumns = false;
if (Header == null)
{
txtName.ReadOnly = false;
DataAccessLayer.Manager.DALLayer.OpenConnectionTryClose();
MIngredientsEntityCollection _col = new MIngredientsEntityCollection();
_col.GetDataBy(null, new List<KeyValuePair<string, object>> { new KeyValuePair<string, object>("FoodNo", 0 )}, null);
dataGridView1.DataSource = _col.LastSelectTable;
DataAccessLayer.Manager.DALLayer.CloseConnection();
}
else
{
txtName.ReadOnly = true;
txtName.Text = Header.Filler.GetColumnValueNotNull("Name").ToString();
txtPrice.Text = Header.Filler.GetColumnValueNotNull("Price").ToString();
bool _foodType = (bool) Header.Filler.GetColumnValueNotNull("IsFoodOrDrink");
if (_foodType) radioButton1.Checked = true;
else radioButton2.Checked = true;
DataAccessLayer.Manager.DALLayer.OpenConnectionTryClose();
Detail = Header.GetHeaderDetailMIngredientsEntityCollectionByPrimaryKey();
dataGridView1.DataSource = Detail.LastSelectTable;
DataAccessLayer.Manager.DALLayer.CloseConnection();
}
}
private void button5_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnSaveSetting_Click(object sender, EventArgs e)
{
DataAccessLayer.Manager.DALLayer.OpenConnectionTryClose();
DataAccessLayer.Manager.DALLayer.BeginTransaction();
try
{
MFoodEntity _header = Header;
if (Header == null)
{
_header = new MFoodEntity();
}
_header.Filler.AddColumnValue("Name", txtName.Text);
_header.Filler.AddColumnValue("SellPrice", Convert.ToDecimal(txtPrice.Text));
_header.Filler.AddColumnValue("IsFoodOrDrink", radioButton1.Checked);
if (Convert.ToInt32(_header.Filler.GetColumnValueNotNull("FoodNo")) == 0)
{
_header.InsertIdentity();
}
else
{
_header.Update();
}
DataTable _table = (DataTable)dataGridView1.DataSource;
MIngredientsEntityCollection _entityCollection = new MIngredientsEntityCollection();
_entityCollection.SetDataByTable(_table);
foreach (MIngredientsEntity _item in _entityCollection)
{
if (Convert.ToInt32(_item.Filler.GetColumnValueNotNull("IngredientsNo")) == 0)
{
_item.InsertHeaderDetailMIngredientsIdentityToHeader(_header);
}
else
{
_item.UpdateHeaderDetailMIngredientsToHeader(_header);
}
}
if (_entityCollection.Collection.Count > 0)
_entityCollection[0].SortAbleMIngredientsNormalizeSortOrder(new object[] { Convert.ToInt32(_header.Filler.GetColumnValueNotNull("FoodNo")) });
DataAccessLayer.Manager.DALLayer.CommitTransaction();
MessageBox.Show("Data has been saved successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
DataAccessLayer.Manager.DALLayer.RollbackTransaction();
MessageBox.Show("Error occur wheren storing information : " + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
DataAccessLayer.Manager.DALLayer.CloseConnection();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.