narsil/Tanshu.Accounts.PointOfSale/ComplexProductForm.cs
2010-03-02 23:26:21 +05:30

133 lines
4.4 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows.Forms;
using Accounts.Proxy;
using System.Threading;
using Accounts.BI;
namespace Accounts.PointOfSale
{
public partial class ComplexProductForm : Form
{
public ComplexProductForm()
{
InitializeComponent();
}
private void ComplexProductForm_Load(object sender, EventArgs e)
{
FillCombos();
}
private void FillCombos()
{
//cmbComplexProducts.DisplayMember = "Name";
//cmbComplexProducts.ValueMember = "ProductID";
//cmbComplexProducts.DataSource = ProductProxy.GetComplexProducts().ToList();
cmbChildItems.DisplayMember = "Name";
cmbChildItems.ValueMember = "ProductID";
cmbChildItems.DataSource = ProductBI.GetProducts();
}
private void btnAdd_Click(object sender, EventArgs e)
{
//if ((cmbComplexProducts.Text != "") && (cmbChildItems.Text != "") && (txtQuantity.Text.Trim() != ""))
// Save();
//else
//{
// System.Windows.Forms.MessageBox.Show("Please select missing information");
// cmbComplexProducts.Focus();
//}
}
private void Save()
{
//ComplexProduct complexProduct = new ComplexProduct();
//complexProduct.ProductID = (Guid)cmbComplexProducts.SelectedValue;
//complexProduct.ChildID = (Guid)cmbChildItems.SelectedValue;
//complexProduct.Quantity = Convert.ToDecimal(txtQuantity.Text);
//ProductProxy.AddComplexProduct(complexProduct);
//GetComplexProductItems();
}
private void GetComplexProductItems()
{
//List<DisplayComplexProducts> list = new List<DisplayComplexProducts>();
//if (cmbComplexProducts.Text != "")
//{
// list = ProductProxy.GetChildProductList(new Guid(cmbComplexProducts.SelectedValue.ToString()));
// dgvItems.DataSource = list;
//}
}
private void btnProducts_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Master/Products"))
{
MessageBox.Show("You are not authorized to access");
}
else
{
ProductsForm form = new ProductsForm();
form.ShowDialog();
form.Dispose();
FillCombos();
}
}
private void dgvItems_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (dgvItems.Columns[e.ColumnIndex].Name == "deleteDataGridViewButtonColumn")
{
ProductProxy.DeleteComplexProductFromID((Guid)dgvItems.Rows[e.RowIndex].Cells[0].Value);
GetComplexProductItems();
}
}
private void cmbComplexProducts_SelectedIndexChanged(object sender, EventArgs e)
{
GetComplexProductItems();
}
private void ComplexProductForm_KeyDown(object sender, KeyEventArgs e)
{
//if (e.KeyCode == Keys.F7)
//{
// using (SelectProduct selectProduct = new SelectProduct(ProductProxy.GetAllComplexProductList(), true))
// {
// selectProduct.ShowDialog();
// if (selectProduct.SelectedItem != null)
// {
// cmbComplexProducts.SelectedValue = selectProduct.SelectedItem.productID;
// GetComplexProductItems();
// cmbChildItems.Focus();
// }
// }
//}
if (e.KeyCode == Keys.F6)
{
using (SelectProduct selectProduct = new SelectProduct(ProductBI.GetProducts(), true))
{
selectProduct.ShowDialog();
if (selectProduct.SelectedItem != null)
{
cmbChildItems.SelectedValue = selectProduct.SelectedItem.ProductID;
txtQuantity.Focus();
}
}
}
}
private void btnPrint_Click(object sender, EventArgs e)
{
//Accounts.Print.Thermal.PrintComplexProducts(new Guid(cmbComplexProducts.SelectedValue.ToString()));
}
}
}