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 Swash.Objects;
using Swash.BusinessLayer;
using System.IO;
using System.Text.RegularExpressions;
using POS.Properties;
using System.Drawing.Drawing2D;
using System.Threading;
namespace POS
{
public partial class FrmMain : Form
{
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x84:
base.WndProc(ref m);
if ((int)m.Result == 0x1) m.Result = (IntPtr)0x2;
return;
}
base.WndProc(ref m);
}
public FrmMain()
{
InitializeComponent();
imgGridBack = POS.Properties.Resources.grid_view_back;
}
#region Variables
Image imgGridBack = null;
// public static string ShipBack;
public string popupimgpurpose = "S";//for popup image
public string chkstockpurpose = "S";//for stock check
public string purpose = "S";//for transaction status
public string TxtTotalNoOfItems = "";
public string TxtTotalAmount = "";
public string TxtTotalTaxAmount = "";
public string TxtTotalDiscountAmount = "";
public string TxtTotalAdjustAmount = "";
public string TxtNetAmount = "";
public string AutoinvoiceNo = "";
public decimal TotalShippingCharge = 0;
public static bool ShipStatus = false;
// public string ShippingAmount = "";
//insert variable
string TxtInvoiceNumber;
string TxtNet;
public string maxsaleid = string.Empty;
public static int customeridshipping = 0;
//update variable
public string EditInvoiceNumber;
public int SaleId = 0;
//bool value for datagrid search check
private bool loading = true;
//****************************//
delegate void delGetCustomerInformation();
private System.Windows.Forms.Timer _Timer = new System.Windows.Forms.Timer();
private System.Windows.Forms.Timer _Timerstock = new System.Windows.Forms.Timer();
public static int Cust_ID;
int index; //Keps the gridview row ID
public DataTable dtItems = new DataTable();
public DataTable dtItemForDB = new DataTable();
DataTable dtBarcode = new DataTable();
public DataTable dtserial = new DataTable();
//--------tooltip declaration for showing in shipping details section label---------------------------
System.Windows.Forms.ToolTip ToolTip11 = new System.Windows.Forms.ToolTip();
System.Windows.Forms.ToolTip ToolTip22 = new System.Windows.Forms.ToolTip();
//------------------------------
decimal tax;
public int Choice;
int Item_ID;
string ItemName, Quantity, Unitprice, chktaxable, ItemPrice, Taxpercentage, Extendedprice, DiscountPercentage, Discountprice, Netprice;
int stockQuantity;
int TotalItems;
public decimal TotalAmount, TotalDiscountAmount, TotalTaxableAmount, TotalTaxAmount, TotalAdjustAmount, TotalNetAmount, TotalNetwithship;
bool EditQuantity = false;
bool _EditGrid = false;
bool _rowclickGrid = false;
string Barcode;
int Itemid = 0;
int Saleqty, Disqty, Byeqty, Getqty;
int FlagScheme, SchemeID = 0;
string checkscheme = "";
string Schemebarcode = "";
bool IsScheme = false;
bool iscountqty = false;
int customerid;
int rowindex;
bool isEdit = false;
bool IsBarcode = false;
bool isItemGridClick = false;
bool isInvoice = false;
string btnmode = "";
public static int x = 0;
public static int y = 0;
int locationX = 0;//pnl progress marking variable
int locationY = 0;//pnl progress marking variable
int i = 0;
int j, z = 0;
PictureBox pbLastAccess = null;
string msgstock = "";
//for user login id
int userid = 0;
//for check serial no of a item
bool Isserial;
//for popupserialno page
public static int QtyForSerialno;
public static string BarcodeForSerialno;
public static int ItemQtyForSerialno;
#endregion
private void FrmMain_Load(object sender, EventArgs e)
{
//location choosen to set the stockprogress bar and mark a red pont
locationX = pnlmark.Location.X;
locationY = pnlmark.Location.Y;
//current date
lblcurrentdate.Text = DateTime.Now.ToString("M/dd/yyyy hh:mm:ss tt");
//for clock
_Timer.Interval = 1000;
_Timer.Tick += new EventHandler(_Timer_Tick);
_Timer.Start();
//===================//
//for update stock in datagridview
_Timerstock.Interval = 2 * 60 * 1000;
_Timerstock.Tick += new EventHandler(_Timerstock_Tick);
_Timerstock.Start();
//===================//
GetProduct();
GetCustomer();
//currentdate
CurrentDate();
//header date
string headerdate = string.Format("{0:f}", DateTime.Now);
lblHeader3.Text = headerdate;
CreateDataTable();
//get autoinvoice no
GetAutoInvoiceNo();
//lblHeader1.Text = "Sale Invoices No." + AutoinvoiceNo;
//wish message
if (DateTime.Now.Hour < 12)
{
lblWishTime.Text = "Good Morning";
}
else if (DateTime.Now.Hour < 17)
{
lblWishTime.Text = "Good Afternoon";
}
else
{
lblWishTime.Text = "Good Evening";
}
//get totalsale
GetTotalSale();
//onhold
GetOnHoldSale();
TxtBarcode.Focus();
tabDisplay.SelectedIndex = 0;
//visible false item column
BlockItemColumn();
//user control
userControl11.Click1 += new UC_virtual_keyboard.UserControl1.sender1(userControl11_Click1);
x = this.Location.X; y = this.Location.Y;
//get sale userid
//SaleId = 1;
userid = int.Parse(frmLogin.userid.ToString());
//assign 0 index value in product combobox
combosearch.SelectedIndex = 0;
cmbCustomer.SelectedIndex = 0;
//set focus false in search grid
dgvProdSearch.Rows[0].Selected = false;
// dgvCustSearch.Rows[0].Selected = false;
}
private void userControl11_Click1(string s)
{
if (j == 1)
TxtBarcode.Text = s;
else if (j == 2)
TxtBarcode.Text = s;
else if (j == 3)
TxtBarcode.Text = s;
}
#region Defined By Salman
private void GetContextMenu()
{
if (GridViewItems.Rows.Count > 0)
{
GridViewItems.ContextMenuStrip = cmOperation;
}
}
//click timer for time
private void _Timer_Tick(object sender, EventArgs e)
{
this.lblTime.Text = DateTime.Now.ToString("hh:mm:ss tt");
}
//update stock after 2 mnts in datagridview
private void _Timerstock_Tick(object sender, EventArgs e)
{
//GetProduct();
//GetCustomer();
}
// attach the wire handler after the form is loaded
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
loading = false;
//if (this.GridViewItems.SelectedCells.Count > 0)
//{
// for (int i = 0; i < this.GridViewItems.SelectedCells.Count; i++)
// this.GridViewItems.SelectedCells[i].Selected = false;
//}
}
private DataTable EmptyGrid()
{
DataTable emptgrd = new DataTable();
GridViewItems.AutoGenerateColumns = false;
DataGridViewTextBoxColumn Barcode = new DataGridViewTextBoxColumn();
Barcode.Name = "barcode";
Barcode.HeaderText = "Barcode";
GridViewItems.Columns.Add(Barcode);
DataGridViewTextBoxColumn Itemname = new DataGridViewTextBoxColumn();
Itemname.HeaderText = "Item Name";
GridViewItems.Columns.Add(Itemname);
DataGridViewTextBoxColumn Quantity = new DataGridViewTextBoxColumn();
Quantity.HeaderText = "Quantity";
GridViewItems.Columns.Add(Quantity);
DataGridViewTextBoxColumn Unitprice = new DataGridViewTextBoxColumn();
Unitprice.HeaderText = "Unit Price";
GridViewItems.Columns.Add(Unitprice);
DataGridViewTextBoxColumn price = new DataGridViewTextBoxColumn();
price.HeaderText = "price";
GridViewItems.Columns.Add(price);
DataGridViewTextBoxColumn Taxable = new DataGridViewTextBoxColumn();
Taxable.HeaderText = "Taxable";
GridViewItems.Columns.Add(Taxable);
DataGridViewTextBoxColumn tax = new DataGridViewTextBoxColumn();
tax.HeaderText = "Tax";
GridViewItems.Columns.Add(tax);
DataGridViewTextBoxColumn Extendedprice = new DataGridViewTextBoxColumn();
Extendedprice.HeaderText = "Extended Price";
GridViewItems.Columns.Add(Extendedprice);
DataGridViewTextBoxColumn discountprice = new DataGridViewTextBoxColumn();
discountprice.HeaderText = "Discount Price";
GridViewItems.Columns.Add(discountprice);
DataGridViewTextBoxColumn netprice = new DataGridViewTextBoxColumn();
netprice.HeaderText = "Net Price";
GridViewItems.Columns.Add(netprice);
return emptgrd;
}
private DataTable AutoNumberedTable(DataTable SourceTable)
{
DataTable ResultTable = new DataTable();
DataColumn AutoNumberColumn = new DataColumn();
AutoNumberColumn.ColumnName = "SL.No.";
AutoNumberColumn.DataType = typeof(int);
AutoNumberColumn.AutoIncrement = true;
AutoNumberColumn.AutoIncrementSeed = 1;
AutoNumberColumn.AutoIncrementStep = 1;
ResultTable.Columns.Add(AutoNumberColumn);
ResultTable.Merge(SourceTable);
return ResultTable;
}
#region Procedure
//create a datatable for intialize data from popup and if not any record then create new one
private void SerialDatatable()
{
if (frmPoupSerialNo.dtSerialNo.Rows.Count > 0)
{
dtserial = frmPoupSerialNo.dtSerialNo;
}
else
{
if (dtserial.Columns.Count == 0)
{
dtserial.Columns.Add("BarCode", typeof(string));
dtserial.Columns.Add("SerialNo", typeof(string));
}
}
}
private void CurrentDate()
{
string currentdate = string.Format("{0:ddd, MMM d, yyyy}", DateTime.Now);
lblDate.Text = currentdate;
}
private void GetAutoInvoiceNo()
{
try
{
lblHeader1.Text = "";
List<POS_PointOfSale> objinvoice = new List<POS_PointOfSale>();
objinvoice = ERPManagement.GetInstance.AutoInvoiceNo();
AutoinvoiceNo = objinvoice.ToList()[0].ReturnInvoiceNo;
lblHeader1.Text = "Sale Invoices No." + AutoinvoiceNo;
}
catch
{
}
}
private DataTable EmptyproductsearchGrid()
{
DataTable emptgrd = new DataTable();
DataColumn ItemName = new DataColumn();
DataColumn ItemQuantity = new DataColumn();
ItemName.ColumnName = "Item Name";
ItemQuantity.ColumnName = "Item Quantity";
emptgrd.Columns.Add(ItemName);
emptgrd.Columns.Add(ItemQuantity);
return emptgrd;
}
private DataTable EmptycustomersearchGrid()
{
DataTable emptcustgrd = new DataTable();
DataColumn customername = new DataColumn();
DataColumn phone = new DataColumn();
customername.ColumnName = "Customer Name";
phone.ColumnName = "Phone";
emptcustgrd.Columns.Add(customername);
emptcustgrd.Columns.Add(phone);
return emptcustgrd;
}
private void SetProdSearchGrid()
{
int totalWidth = dgvProdSearch.Width;
dgvProdSearch.Columns["img"].Width = 30;
dgvProdSearch.Columns["ItemQuantity"].Width = 38;
dgvProdSearch.Columns["ItemName"].Width = 158;
dgvProdSearch.Columns["Price"].Width = 52;
}
private void GetProduct()
{
try
{
dgvProdSearch.Columns.Clear();
var product = from prod in ERPManagement.GetInstance.GetProductSearch()
select new
{
ItemId = prod.ItemID,
Barcode = prod.ItemBarcode,
ItemQuantity = prod.ItemQuantity,
ItemName = prod.ItemName,
Price = prod.ItemPrice.ToString("f"),
Isserial = prod.IsSerial,
};
if (product.ToList().Count > 0)
{
LblNoRecord.Visible = false;
dgvProdSearch.DataSource = product.ToList();
DataGridViewImageColumn imgprog = new DataGridViewImageColumn();
imgprog.Name = "img";
dgvProdSearch.Columns.Add(imgprog);
dgvProdSearch.Columns["ItemId"].Visible = false;
dgvProdSearch.Columns["Barcode"].Visible = false;
dgvProdSearch.Columns["Isserial"].Visible = false;
dgvProdSearch.Columns["ItemName"].HeaderText = "Item Name";
dgvProdSearch.Columns["Price"].HeaderText = "Price";
dgvProdSearch.Columns["ItemQuantity"].HeaderText = "";
dgvProdSearch.Columns["img"].HeaderText = "";
this.dgvProdSearch.Columns["Price"].DefaultCellStyle.Format = "f";
SetProdSearchGrid();
SetdgvProdSearchProgressImage();
dgvProdSearch.Columns["img"].DisplayIndex = 2;
dgvProdSearch.Columns["ItemQuantity"].DisplayIndex = 3;
dgvProdSearch.Rows[0].Selected = false;
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
LblNoRecord.Visible = true;
// dgvProdSearch.DataSource = EmptyproductsearchGrid();
}
}
catch { }
}
private void GetVariationProduct(int itemid)
{
try
{
var product = from prod in ERPManagement.GetInstance.GetVariationProduct(itemid)
select new
{
ItemId = prod.ItemID,
Barcode = prod.ItemBarcode,
ItemQuantity = prod.ItemQuantity,
ItemName = prod.ItemName,
Price = prod.ItemPrice.ToString("f"),
Isserial = prod.IsSerial,
};
if (product.ToList().Count > 0)
{
//assign z=1 for back to main product and it is work in tadisplay click event
z = 1;
dgvProdSearch.Columns.Clear();
LblNoRecord.Visible = false;
dgvProdSearch.DataSource = product.ToList();
DataGridViewImageColumn imgprog = new DataGridViewImageColumn();
imgprog.Name = "img";
dgvProdSearch.Columns.Add(imgprog);
dgvProdSearch.Columns["ItemId"].Visible = false;
dgvProdSearch.Columns["Barcode"].Visible = false;
dgvProdSearch.Columns["Isserial"].Visible = false;
dgvProdSearch.Columns["ItemName"].HeaderText = "Item Name";
dgvProdSearch.Columns["Price"].HeaderText = "Price";
dgvProdSearch.Columns["ItemQuantity"].HeaderText = "";
dgvProdSearch.Columns["img"].HeaderText = "";
this.dgvProdSearch.Columns["Price"].DefaultCellStyle.Format = "f";
SetProdSearchGrid();
SetdgvProdSearchProgressImage();
dgvProdSearch.Columns["img"].DisplayIndex = 2;
dgvProdSearch.Columns["ItemQuantity"].DisplayIndex = 3;
dgvProdSearch.Rows[0].Selected = false;
}
else
{
z = 0;
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
// LblNoRecord.Visible = true;
// dgvProdSearch.DataSource = EmptyproductsearchGrid();
}
}
catch { }
}
//set image for item
private void SetdgvProdSearchProgressImage()
{
tabDisplay.SelectedIndex = 1;
int minstock = 0;
//if (dgvProdSearch.Rows.Count > 0)
//{
// string barcode = dgvProdSearch.Rows[i].Cells["Barcode"].Value.ToString();
// List<POS_PointOfSale> listPOS = ERPManagement.GetInstance.GetBarcodeLevel(barcode);
// if (listPOS.Count > 0)
// {
// minstock = Convert.ToInt16(Convert.ToString(listPOS.ToArray()[0].Minimum_Stock) == "" ? "0" : Convert.ToString(listPOS.ToArray()[0].Minimum_Stock));
// }
//}
for (int i = 0; i <= dgvProdSearch.Rows.Count - 1; i++)
{
try
{
Image myImage = null;
decimal per = 0;
int quantity = int.Parse(dgvProdSearch.Rows[i].Cells["ItemQuantity"].Value.ToString());
string barcode = dgvProdSearch.Rows[i].Cells["Barcode"].Value.ToString();
List<POS_PointOfSale> listPOS = ERPManagement.GetInstance.GetBarcodeLevel(barcode);
if (listPOS.Count > 0)
{
minstock = Convert.ToInt16(Convert.ToString(listPOS.ToArray()[0].Minimum_Stock) == "" ? "0" : Convert.ToString(listPOS.ToArray()[0].Minimum_Stock));
per = (quantity / (decimal)minstock) * 100;
}
// decimal per = (quantity * 100) / 100;
if (per == 0)
{
myImage = POS.Properties.Resources.grp0;
}
else if (per <= 10)
{
myImage = POS.Properties.Resources.progress10;
}
else if (per <= 20)
{
myImage = POS.Properties.Resources.progress20;
}
else if (per <= 30)
{
myImage = POS.Properties.Resources.progress30;
}
else if (per <= 40)
{
myImage = POS.Properties.Resources.progress40;
}
else if (per <= 50)
{
myImage = POS.Properties.Resources.progress50;
}
else if (per <= 60)
{
myImage = POS.Properties.Resources.progress60;
}
else if (per <= 70)
{
myImage = POS.Properties.Resources.progress70;
}
else if (per <= 80)
{
myImage = POS.Properties.Resources.progress80;
}
else if (per <= 90)
{
myImage = POS.Properties.Resources.progress90;
}
else if (per < 100)
{
myImage = POS.Properties.Resources.progress90;
}
else if (per >= 100)
{
myImage = POS.Properties.Resources.progress100;
}
dgvProdSearch.Rows[i].Cells["img"].Value = myImage;
}
catch { }
}
}
public void GetCustomer()
{
try
{
dgvCustSearch.Columns.Clear();
var customer = (from cust in ERPManagement.GetInstance.GetCustomerSearch()
select new
{
customerid = cust.Customer_ID,
custimg = GetImageFromByteArrary(cust.CustImage),
customername = cust.Customer_NameLC,
mobileno = cust.CustomerPhone
}).ToList();
if (customer.Count > 0)
{
dgvCustSearch.Width = 270;
lblcustNorecord.Visible = false;
dgvCustSearch.DataSource = customer.ToList();
DisplayCustomerGridFormat();
dgvCustSearch.Rows[0].Selected = false;
//List<POSCustomer> listpos = new List<POSCustomer>();
//for (int i = 0; i < customer.Count; i++)
//{
// POSCustomer objnew = new POSCustomer();
// objnew.Customer_ID = customer[i].customerid;
// objnew.Customer_Name = customer[i].customername;
// objnew.CustomerPhone = customer[i].mobileno;
// objnew.Imagevalue = funImagecroping(customer[i].custimg);
// listpos.Add(objnew);
//}
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
lblcustNorecord.Visible = true;
dgvCustSearch.DataSource = EmptycustomersearchGrid();
}
}
catch
{
}
}
public void GetInvoiceDetails()
{
try
{
//frmViewSale obj = new frmViewSale("I");
//obj.ShowDialog();
isInvoice = true;
ResetForm();
Point p = GridViewItems.Location;
p = new Point(GridViewItems.Location.X + this.Location.X + 7, p.Y + 126);
frmViewSale obj = new frmViewSale("S");
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
obj.Location = new Point(p.X, p.Y);
obj.ShowDialog();
SaleId = obj.saleid;
//set saleid to maxsaleid for complee transaction bcoz maxsaleid pass to paymentsell page
maxsaleid = SaleId.ToString();
if (SaleId != 0)
{
GetSaleData();
GetSaleDetails();
GetSaleCustomer();
DisableControl();
GridViewItems.Rows[0].Selected = false;
stockprogressBar.Value = 0;
}
else
{
ResetForm();
GetAutoInvoiceNo();
EnableControl();
}
}
catch { }
}
//Image funImagecroping(Image img)
//{
// Image icon=new Image();
// using (Graphics gr = Graphics.FromImage(img))
// {
// gr.SmoothingMode = SmoothingMode.HighQuality;
// gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
// gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
// gr.DrawImage(icon, new Rectangle(0, 0, 17, 17));
// //gr.CreateObjRef(typeof
// }
//}
#region Generating a new Image
public Image NewImage(Image image)
{
int width = 30, height = 25;
// Image resizedImage = new Bitmap(image.Width, image.Height);
Image resizedImage = new Bitmap(width, height);
using (Graphics graphics = Graphics.FromImage(resizedImage))
{
graphics.Clear(Color.White);
//graphics.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height), new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
graphics.DrawImage(image, new Rectangle(0, 0, width, height), new Rectangle(0, 0, width, height), GraphicsUnit.Pixel);
}
return resizedImage;
}
#endregion
Image GetImageFromByteArrary(byte[] bt)
{
Image img = POS.Properties.Resources.custimg;
try
{
if (bt.Length > 0 && bt != null)
{
MemoryStream ms = new MemoryStream(bt);
img = Image.FromStream(ms);
//img = NewImage(img);
}
}
catch (Exception) { }
return img;
}
void DisplayCustomerGridFormat()
{
dgvCustSearch.Columns["customerid"].Visible = false;
//DataGridViewImageColumn imgcust = new DataGridViewImageColumn();
//Image image1 = POS.Properties.Resources.custimg;
//imgcust.Image = image1;
//imgcust.Name = "custimg";
//dgvCustSearch.Columns.Add(imgcust);
dgvCustSearch.Columns["custimg"].HeaderText = "";
dgvCustSearch.Columns["custimg"].MinimumWidth = 25;
dgvCustSearch.Columns["custimg"].Width = 25;
dgvCustSearch.Columns["customername"].HeaderText = "Customer Name";
dgvCustSearch.Columns["mobileno"].HeaderText = "Phone";
DataGridViewImageColumn imgedit = new DataGridViewImageColumn();
Image image = POS.Properties.Resources.customer_panel_icon;
imgedit.Image = image;
imgedit.MinimumWidth = 20;
imgedit.Width = 20;
dgvCustSearch.Columns.Add(imgedit);
imgedit.HeaderText = "";
imgedit.Name = "Edit";
this.dgvCustSearch.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
SetCustSearchGrid();
//set position
}
private void SetCustSearchGrid()
{
int totalWidth = dgvCustSearch.Width;
dgvCustSearch.Columns["custimg"].MinimumWidth = 30;
dgvCustSearch.Columns["custimg"].Width = 30;
dgvCustSearch.Columns["customername"].MinimumWidth = 130;
dgvCustSearch.Columns["customername"].Width = 130;
dgvCustSearch.Columns["mobileno"].MinimumWidth = 90;
dgvCustSearch.Columns["mobileno"].Width = 90;
}
public void GetCustomerBySearch()
{
if (cmbCustomer.SelectedIndex == -1)
{
MessageBox.Show(" Select any type Of search!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
cmbCustomer.Focus();
}
else
{
try
{
List<POS_PointOfSale> Customers = new List<POS_PointOfSale>();
Customers = ERPManagement.GetInstance.GetCustomerSearch();
dgvCustSearch.Columns.Clear();
if (cmbCustomer.Text == "By Name")
{
var customer = from cust in Customers
where cust.Customer_Name.ToLower().Contains(txtCustomerSearch.Text.Trim().ToLower())
select new
{
customerid = cust.Customer_ID,
custimg = GetImageFromByteArrary(cust.CustImage),
customername = cust.Customer_NameLC,
mobileno = cust.CustomerPhone
};
if (customer.ToList().Count > 0)
{
tabDisplay.SelectedIndex = 2;
lblcustNorecord.Visible = false;
dgvCustSearch.DataSource = customer.ToList();
DisplayCustomerGridFormat();
}
else
{
lblcustNorecord.Visible = true;
dgvCustSearch.DataSource = EmptycustomersearchGrid();
}
}
else if (cmbCustomer.Text == "By Card No")
{
var customer = from cust in Customers
where cust.Loyalty_Card_No.ToLower().Contains(txtCustomerSearch.Text.Trim().ToLower())
select new
{
customerid = cust.Customer_ID,
custimg = GetImageFromByteArrary(cust.CustImage),
customername = cust.Customer_NameLC,
mobileno = cust.CustomerPhone
};
if (customer.ToList().Count > 0)
{
tabDisplay.SelectedIndex = 2;
lblcustNorecord.Visible = false;
dgvCustSearch.DataSource = customer.ToList();
DisplayCustomerGridFormat();
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
lblcustNorecord.Visible = true;
dgvCustSearch.DataSource = EmptycustomersearchGrid();
}
}
else if (cmbCustomer.Text == "By Phone No")
{
var customer = from cust in Customers
where cust.CustomerPhone.ToLower().StartsWith(txtCustomerSearch.Text.Trim().ToLower())
select new
{
customerid = cust.Customer_ID,
custimg = GetImageFromByteArrary(cust.CustImage),
customername = cust.Customer_NameLC,
mobileno = cust.CustomerPhone
};
if (customer.ToList().Count > 0)
{
tabDisplay.SelectedIndex = 2;
lblcustNorecord.Visible = false;
dgvCustSearch.DataSource = customer.ToList();
DisplayCustomerGridFormat();
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
lblcustNorecord.Visible = true;
dgvCustSearch.DataSource = EmptycustomersearchGrid();
}
}
else if (cmbCustomer.Text == "Select")
{
var customer = from cust in Customers
where cust.CustomerPhone.ToLower().StartsWith(txtCustomerSearch.Text.Trim().ToLower()) ||
cust.Customer_Name.Trim().StartsWith(txtCustomerSearch.Text.Trim().ToLower()) ||
cust.Loyalty_Card_No.Trim().StartsWith(txtCustomerSearch.Text.Trim().ToLower())
select new
{
customerid = cust.Customer_ID,
custimg = GetImageFromByteArrary(cust.CustImage),
customername = cust.Customer_NameLC,
mobileno = cust.CustomerPhone
};
if (customer.ToList().Count > 0)
{
tabDisplay.SelectedIndex = 2;
lblcustNorecord.Visible = false;
dgvCustSearch.DataSource = customer.ToList();
DisplayCustomerGridFormat();
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
lblcustNorecord.Visible = true;
dgvCustSearch.DataSource = EmptycustomersearchGrid();
}
}
}
catch { }
}
}
private void GetTotalSale()
{
try
{
List<POS_PointOfSale> objtotsale = new List<POS_PointOfSale>();
objtotsale = ERPManagement.GetInstance.GetTotalSale();
if (objtotsale.Count > 0)
{
lblSales.Text = objtotsale.ToList()[0].TotalSale.ToString() == null ? "0" : objtotsale.ToList()[0].TotalSale.ToString();
lblReceipts.Text = objtotsale.ToList()[0].TotalSaleAmount.ToString() == null ? "0.00" : objtotsale.ToList()[0].TotalSaleAmount.ToString("f");
if (lblReceipts.Text.Length < 5) lblReceipts.Location = new Point(25, lblReceipts.Location.Y);
else if (lblReceipts.Text.Length <= 7)
lblReceipts.Location = new Point(8, lblReceipts.Location.Y);
else if (lblReceipts.Text.Length <= 12)
{
lblReceipts.Font = new Font("Verdana", 8, FontStyle.Regular);
lblReceipts.Location = new Point(6, lblReceipts.Location.Y);
}
else if (lblReceipts.Text.Length <= 16)
{
lblReceipts.Font = new Font("Verdana", 7, FontStyle.Regular);
lblReceipts.Location = new Point(4, lblReceipts.Location.Y);
}
}
else
{ }
}
catch
{
}
}
private void GetOnHoldSale()
{
try
{
List<POS_PointOfSale> objholdsale = new List<POS_PointOfSale>();
objholdsale = ERPManagement.GetInstance.GetOnHoldSale();
if (objholdsale.Count > 0)
{
lblOnHold.Text = objholdsale.ToList()[0].TotalHoldSale.ToString() == null ? "0" : objholdsale.ToList()[0].TotalHoldSale.ToString();
}
else
{ }
}
catch
{
}
}
/// <summary>
/// edit countitem
/// </summary>
private void GetCountItem()
{
try
{
if (GridViewItems.Rows.Count > 0)
{
if (GridViewItems.SelectedRows.Count > 0)
{
isEdit = true;
rowindex = GridViewItems.SelectedRows[0].Index;
GetAllBarcodeDetails();
TxtBarcode.Text = GridViewItems.Rows[rowindex].Cells[1].Value.ToString();
txtCountNo.Text = GridViewItems.Rows[rowindex].Cells[3].Value.ToString();
GridViewItems.Rows[rowindex].Selected = true;
isEdit = false;
}
}
}
catch
{ }
}
private void GetProductSearch()
{
if (combosearch.SelectedIndex == -1)
{
MessageBox.Show(" Select one Item!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
combosearch.Focus();
}
else
{
try
{
dgvProdSearch.Columns.Clear();
if (combosearch.Text == "Barcode")
{
var searchitem = from prod in ERPManagement.GetInstance.GetProductSearch()
where prod.ItemBarcode.ToUpper().StartsWith(txtSearch.Text.ToUpper())
//select prod;
select new
{
ItemId = prod.ItemID,
Barcode = prod.ItemBarcode,
ItemName = prod.ItemName,
ItemQuantity = prod.ItemQuantity,
Price = prod.ItemPrice,
Isserial = prod.IsSerial,
};
if (searchitem.ToList().Count > 0)
{
LblNoRecord.Visible = false;
dgvProdSearch.DataSource = searchitem.ToList();
DataGridViewImageColumn imgprog = new DataGridViewImageColumn();
imgprog.Name = "img";
dgvProdSearch.Columns.Add(imgprog);
dgvProdSearch.Columns["ItemId"].Visible = false;
dgvProdSearch.Columns["Barcode"].Visible = false;
dgvProdSearch.Columns["Isserial"].Visible = false;
dgvProdSearch.Columns["ItemName"].HeaderText = "Item Name";
dgvProdSearch.Columns["Price"].HeaderText = "Price";
dgvProdSearch.Columns["ItemQuantity"].HeaderText = "";
dgvProdSearch.Columns["img"].HeaderText = "";
this.dgvProdSearch.Columns["Price"].DefaultCellStyle.Format = "f";
SetProdSearchGrid();
SetdgvProdSearchProgressImage();
dgvProdSearch.Columns["img"].DisplayIndex = 2;
dgvProdSearch.Columns["ItemQuantity"].DisplayIndex = 3;
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
LblNoRecord.Visible = true;
dgvProdSearch.DataSource = EmptyproductsearchGrid();
}
}
else if (combosearch.Text == "Item")
{
var searchitem = from prod in ERPManagement.GetInstance.GetProductSearch()
where prod.ItemName.ToLower().Contains(txtSearch.Text.Trim().ToLower())
//select prod;
select new
{
ItemId = prod.ItemID,
Barcode = prod.ItemBarcode,
ItemName = prod.ItemName,
ItemQuantity = prod.ItemQuantity,
Price = prod.ItemPrice,
Isserial = prod.IsSerial,
};
if (searchitem.ToList().Count > 0)
{
LblNoRecord.Visible = false;
dgvProdSearch.DataSource = searchitem.ToList();
DataGridViewImageColumn imgprog = new DataGridViewImageColumn();
imgprog.Name = "img";
dgvProdSearch.Columns.Add(imgprog);
dgvProdSearch.Columns["ItemId"].Visible = false;
dgvProdSearch.Columns["Barcode"].Visible = false;
dgvProdSearch.Columns["Isserial"].Visible = false;
dgvProdSearch.Columns["ItemName"].HeaderText = "Item Name";
dgvProdSearch.Columns["Price"].HeaderText = "Price";
dgvProdSearch.Columns["ItemQuantity"].HeaderText = "";
dgvProdSearch.Columns["img"].HeaderText = "";
this.dgvProdSearch.Columns["Price"].DefaultCellStyle.Format = "f";
SetProdSearchGrid();
SetdgvProdSearchProgressImage();
dgvProdSearch.Columns["img"].DisplayIndex = 2;
dgvProdSearch.Columns["ItemQuantity"].DisplayIndex = 3;
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
LblNoRecord.Visible = true;
dgvProdSearch.DataSource = EmptyproductsearchGrid();
}
}
else if (combosearch.Text == "Select")
{
var searchitem = from prod in ERPManagement.GetInstance.GetProductSearch()
where prod.ItemName.ToLower().Contains(txtSearch.Text.Trim().ToLower()) ||
prod.ItemBarcode.ToLower().Contains(txtSearch.Text.Trim().ToLower())
//select prod;
select new
{
ItemId = prod.ItemID,
Barcode = prod.ItemBarcode,
ItemName = prod.ItemName,
ItemQuantity = prod.ItemQuantity,
Price = prod.ItemPrice,
Isserial = prod.IsSerial,
};
if (searchitem.ToList().Count > 0)
{
LblNoRecord.Visible = false;
dgvProdSearch.DataSource = searchitem.ToList();
DataGridViewImageColumn imgprog = new DataGridViewImageColumn();
imgprog.Name = "img";
dgvProdSearch.Columns.Add(imgprog);
dgvProdSearch.Columns["ItemId"].Visible = false;
dgvProdSearch.Columns["Barcode"].Visible = false;
dgvProdSearch.Columns["Isserial"].Visible = false;
dgvProdSearch.Columns["ItemName"].HeaderText = "Item Name";
dgvProdSearch.Columns["Price"].HeaderText = "Price";
dgvProdSearch.Columns["ItemQuantity"].HeaderText = "";
dgvProdSearch.Columns["img"].HeaderText = "";
this.dgvProdSearch.Columns["Price"].DefaultCellStyle.Format = "f";
SetProdSearchGrid();
SetdgvProdSearchProgressImage();
dgvProdSearch.Columns["img"].DisplayIndex = 2;
dgvProdSearch.Columns["ItemQuantity"].DisplayIndex = 3;
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
LblNoRecord.Visible = true;
dgvProdSearch.DataSource = EmptyproductsearchGrid();
}
}
}
catch
{
}
}
}
private void GetCustomerSearch()
{
try
{
var customer = from cust in ERPManagement.GetInstance.GetCustomerSearch()
where cust.Customer_Name.ToLower().StartsWith(txtCustomerSearch.Text.Trim().ToLower())
select new
{
customerid = cust.Customer_ID,
customername = cust.Customer_Name,
mobileno = cust.CustomerPhone,
};
if (customer.ToList().Count > 0)
{
lblcustNorecord.Visible = false;
dgvCustSearch.DataSource = customer.ToList();
DataGridViewImageColumn imgcust = new DataGridViewImageColumn();
imgcust.Name = "custimg";
dgvCustSearch.Columns.Add(imgcust);
dgvCustSearch.Columns["customerid"].Visible = false;
dgvCustSearch.Columns["customername"].HeaderText = "Customer Name";
dgvCustSearch.Columns["mobileno"].HeaderText = "Phone";
dgvCustSearch.Columns["custimg"].HeaderText = "";
SetCustSearchGrid();
//set position
dgvCustSearch.Columns["customerid"].DisplayIndex = 0;
dgvCustSearch.Columns["custimg"].DisplayIndex = 1;
dgvCustSearch.Columns["customername"].DisplayIndex = 2;
dgvCustSearch.Columns["mobileno"].DisplayIndex = 3;
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
lblcustNorecord.Visible = true;
dgvCustSearch.DataSource = EmptycustomersearchGrid();
}
}
catch
{
}
}
//List<POS_Customer> Customerlist = new List<POS_Customer>();
// Customerlist = ERPManagement.GetInstance.SelectCustomers();
// var lnqCustomer = from customer in Customerlist
// where customer.Customer_ID == custid
// select customer;
// if (lnqCustomer.ToList().Count > 0)
// {
// if (lnqCustomer.ToList()[0].Imag != null)
// {
// byte[] bt = (byte[])lnqCustomer.ToList()[0].Imag;
// MemoryStream ms = new MemoryStream(bt);
// pbCustImage2.Image = Image.FromStream(ms);
// }
public void GetItemDetailInfo(string barcode)
{
List<POS_PointOfSale> Itemlist = new List<POS_PointOfSale>();
Itemlist = ERPManagement.GetInstance.GetSelectItem();
var lnqitem = from item in Itemlist
where item.ItemBarcode == barcode
select item;
if (lnqitem.ToList().Count > 0)
{
if (lnqitem.ToList()[0].ItemImage != null)
{
byte[] bt = (byte[])lnqitem.ToList()[0].ItemImage;
MemoryStream ms = new MemoryStream(bt);
pbitemimg.Image = Image.FromStream(ms);
}
else
{
pbitemimg.Image = POS.Properties.Resources.no_image_avilable;
}
if (lnqitem.ToList()[0].ItemBarcode != "")
{
lblbarcode.Text = "Barcode : " + lnqitem.ToList()[0].ItemBarcode.ToString();
}
else
{
lblbarcode.Text = "Barcode :N/A ";
}
if (lnqitem.ToList()[0].ItemName != "")
{
lblItemName.Text = lnqitem.ToList()[0].ItemName.ToString();
}
else
{
lblItemName.Text = "N/A ";
}
if (lnqitem.ToList()[0].ItemType != "")
{
lblitemtype.Text = "Item Type : " + lnqitem.ToList()[0].ItemType.ToString();
}
else
{
lblitemtype.Text = "Item Type :N/A ";
}
if (lnqitem.ToList()[0].MRP != 0)
{
lblmrp.Text = "MRP : " + lnqitem.ToList()[0].MRP.ToString("F");
}
else
{
lblmrp.Text = "MRP :N/A ";
}
if (lnqitem.ToList()[0].categoryName != "")
{
lblcategory.Text = "Category : " + lnqitem.ToList()[0].categoryName.ToString();
}
else
{
lblcategory.Text = "Category :N/A ";
}
//if (lnqitem.ToList()[0].ItemColor != "")
//{
// lblColor.Text = "Color : " + lnqitem.ToList()[0].ItemColor.ToString();
//}
//else
//{
// lblColor.Text = "Color :N/A ";
//}
//if (lnqitem.ToList()[0].ItemBrand != "")
//{
// lblbrand.Text = "Brand : " + lnqitem.ToList()[0].ItemBrand.ToString();
//}
//else
//{
// lblbrand.Text = "Brand :N/A ";
//}
//if (lnqitem.ToList()[0].GrossWeight != 0)
//{
// lblgrossweight.Text = "Gross Weight : " + lnqitem.ToList()[0].GrossWeight.ToString();
//}
//else
//{
// lblgrossweight.Text = "Gross Weight: N/A";
//}
//if (lnqitem.ToList()[0].StoneWeight != 0)
//{
// lblstoneweight.Text = "Stone Weight : " + lnqitem.ToList()[0].StoneWeight.ToString();
//}
//else
//{
// lblstoneweight.Text = "Stone Weight :N/A";
//}
//if (lnqitem.ToList()[0].PureWeight != 0)
//{
// lblpureweight.Text = "Pure Weight : " + lnqitem.ToList()[0].PureWeight.ToString();
//}
//else
//{
// lblpureweight.Text = "Pure Weight :N/A";
//}
}
else
{
}
}
//define transaction for save
public void SaveTransaction()
{
if (Cust_ID > 0)
{
//check serial no entry or not
if (purpose.ToLower() == "s" || purpose.ToLower() == "ss")
{
if (CheckSerialno() == false)
{
return;
}
}
//------------------
if (SaleId > 0)
{
UpdateData();
}
else
{
SaveData();
}
if (purpose.ToLower() == "s" || purpose.ToLower() == "ss")
{
frmPaymentSell obj = new frmPaymentSell(this);
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
// obj.Location = new Point(obj.Location.X + this.Location.X + 100, 130);
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
if (obj.PayStatus == "P")
{
ResetForm();
//call auto invoiceno
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
//GetCustomer();
tabDisplay.SelectedIndex = 0;
//ResetForm
ResetForm();
}
else if (obj.PayStatus == "C")
{
}
}
else
{
if (purpose == "O")
{
MessageBox.Show("Order Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (purpose == "Q")
{
MessageBox.Show("Quotation Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (purpose == "C")
{
MessageBox.Show("Cancel Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (purpose == "F")
{
return;
}
ResetForm();
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
GetCustomer();
tabDisplay.SelectedIndex = 0;
}
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
//define transaction for hold
public void HoldTransaction()
{
if (Cust_ID > 0)
{
if (SaleId > 0)
{
UpdateData();
}
else
{
SaveData();
}
if (purpose == "F")
{
return;
}
else
{
MessageBox.Show("Data Hold Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
//call auto invoiceno
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
//ResetForm
ResetForm();
}
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
//define transaction for cancel
public void CancelTransaction()
{
//if ((dgvCustSearch.SelectedRows.Count > 0) || Cust_ID > 0)
//{
purpose = "C";
if (SaleId > 0)
{
UpdateData();
}
else
{
SaveData();
}
MessageBox.Show("Cancel Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
//call auto invoiceno
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
//ResetForm
ResetForm();
// }
//else
//{
// purpose = "C";
// MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// tabDisplay.SelectedIndex = 2;
//}
}
//define edit a line item of datagridview
private void EditGridLineItem()
{
try
{
if (GridViewItems.Rows.Count > 0)
{
if (GridViewItems.SelectedRows.Count > 0)
{
isEdit = true;
rowindex = GridViewItems.SelectedRows[0].Index;
GetAllBarcodeDetails();
TxtBarcode.Text = GridViewItems.Rows[rowindex].Cells["ItemBarcode"].Value.ToString();
txtCountNo.Text = GridViewItems.Rows[rowindex].Cells["Item_Quantity"].Value.ToString();
//call focus here
FocusCountNumber();
GridViewItems.Rows[rowindex].Selected = true;
isEdit = false;
}
else
{
MessageBox.Show("Select a item for Edit!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
catch
{ }
}
//focus count textbox
private void FocusCountNumber()
{
txtCountNo.BackColor = System.Drawing.Color.Red;
}
private void RemoveGridLineItem()
{
try
{
if (GridViewItems.Rows.Count > 0)
{
if (GridViewItems.SelectedRows.Count > 0)
{
if (MessageBox.Show("Do you realy want to delete the selected row?", "KenCloud", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
rowindex = GridViewItems.CurrentRow.Index;
DataRow dr;
DataRow dr1;
dr = dtItems.Rows[rowindex];
dr.Delete();
dtItems.AcceptChanges();
dr1 = dtItemForDB.Rows[rowindex];
dr1.Delete();
dtItemForDB.AcceptChanges();
GridViewItems.DataSource = AutoNumberedTable(dtItems);
CalculateFooterData();
// DataTableEditFlag = 2;
ResetItemData();
stockprogressBar.Value = 0;
pnlmark.Visible = false;
}
}
else
{
MessageBox.Show("Select a item for Remove!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
catch
{ }
}
public void ConfirmpopFunctionality()
{
frmpopupConfirm objPOPup = new frmpopupConfirm();
objPOPup.ShowDialog();
btnmode = frmpopupConfirm.Btnmode;
if (btnmode == "SAVE")
{
//call save transaction
SaveTransaction();
}
else if (btnmode == "HOLD")
{
//call Hold transaction
HoldTransaction();
}
else if (btnmode == "CANCEL")
{
//call cancel transaction
CancelTransaction();
}
}
public void GetNuremicpad()
{
frmNumericPad obj = new frmNumericPad();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = tabDisplay.Location; //Cursor.Position;
obj.Location = new Point(obj.Location.X + this.Location.X + 5, this.Location.Y + obj.Location.Y + 25);
obj.ShowDialog();
txtCountNo.Text = obj.textBox1.Text;
if (txtCountNo.Text != "")
{
if (int.Parse(txtCountNo.Text) != 0)
{
// CALL HERE
GetCountItem();
//change normal color
txtCountNo.BackColor = System.Drawing.Color.White;
}
else
{
MessageBox.Show("Item quantity should not zero!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtCountNo.Text = "";
FocusCountNumber();
}
}
}
public void ResetForm()
{
try
{
TxtBarcode.Text = "";
TxtTotalNoOfItems = "";
TxtTotalAmount = "";
TxtTotalTaxAmount = "";
TxtTotalDiscountAmount = "";
TxtTotalAdjustAmount = "";
TxtNetAmount = "";
lblGrandTotal.Text = "";
dtItems.Rows.Clear();
dtItemForDB.Rows.Clear();
GridViewItems.DataSource = AutoNumberedTable(dtItems);
purpose = "S";
chkstockpurpose = "S";
//popup image for details amount
popupimgpurpose = "S";
SaleId = 0;
tabDisplay.SelectedIndex = 0;
BlockItemColumn();
//customer details
lblCustomerName.Text = "N/A";
lblCustIdNo.Text = "CID :N/A";
lblLastVisit.Text = "Last Visit :N/A";
lblTotalVisits.Text = "Total Visit :N/A";
lblTotalSales.Text = "Total Sale :N/A";
lblPhone.Text = "Phone :N/A";
Cust_ID = 0;
LblAddress1.Text = "Address1 : N/A";
LblAddress2.Text = "Address2 : N/A";
LblCity.Text = "City : N/A";
LblState.Text = "State : N/A";
LblCountry.Text = "Country : N/A";
LblZip.Text = "Pin : N/A";
LblShipPhn.Text = "Phone : N/A";
LblShipMail.Text = "E-Mail : N/A";
//Item details
lblItemName.Text = "N/A ";
lblbarcode.Text = "Barcode :N/A ";
lblitemtype.Text = "Item Type :N/A ";
lblmrp.Text = "MRP :N/A ";
lblcategory.Text = "Category :N/A ";
lblColor.Text = "Color :N/A ";
lblbrand.Text = "Brand :N/A ";
lblgrossweight.Text = "Gross Weight: N/A";
lblstoneweight.Text = "Stone Weight :N/A";
lblpureweight.Text = "Pure Weight :N/A";
pbCustomerImage.Image = POS.Properties.Resources._user_icon;
frmPoupSerialNo.dtSerialNo.Rows.Clear();
//row selected false
dgvProdSearch.Rows[0].Selected = false;
dgvCustSearch.Rows[0].Selected = false;
}
catch
{ }
}
public void Transaction(string tran)
{
try
{
EnableControl();
ResetForm();
Point p = GridViewItems.Location;
p = new Point(GridViewItems.Location.X + this.Location.X + 7, p.Y + 126);
frmViewSale obj = new frmViewSale(tran);
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
obj.Location = new Point(p.X, p.Y);
obj.ShowDialog();
SaleId = obj.saleid;
//set saleid to maxsaleid for complee transaction bcoz maxsaleid pass to paymentsell page
maxsaleid = SaleId.ToString();
if (SaleId != 0)
{
GetSaleData();
GetSaleDetails();
GetSaleCustomer();
//false gridview line focus
GridViewItems.Rows[0].Selected = false;
stockprogressBar.Value = 0;
}
else
{
ResetForm();
GetAutoInvoiceNo();
}
}
catch
{
}
}
public void ClearCustomer()
{
// if ((Cust_ID > 0) || (dgvCustSearch.SelectedRows.Count > 0))
if (Cust_ID > 0)
{
DialogResult dr = MessageBox.Show("Are you sure to delete selected Customer.", "KenCloud", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr.ToString() == "OK")
{
ERPManagement.GetInstance.DeleteCustomer(Cust_ID, 1);
LblAddress1.Text = "Address1 : N/A";
LblAddress2.Text = "Address2 : N/A";
LblCity.Text = "City : N/A";
LblState.Text = "State : N/A";
LblCountry.Text = "Country : N/A";
LblZip.Text = "Pin : N/A";
LblShipPhn.Text = "Phone : N/A";
LblShipMail.Text = "E-Mail : N/A";
// LOCAL CUSTOMER HISTORY
lblCustIdNo.Text = "CID : N/A";
lblLastVisit.Text = "Last Visit : N/A";
lblTotalVisits.Text = "Total Visit : N/A ";
lblTotalSales.Text = "Total Sale : N/A";
lblPhone.Text = "Phone : N/A ";
/////
GetCustomer();
}
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
public void EditCustomerDetails()
{
// if ((Cust_ID > 0) || (dgvCustSearch.SelectedRows.Count > 0))
if (Cust_ID > 0)
{
EditCustomerDetails(Cust_ID);
GetCustomer();
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
public void FormExit()
{
if ((GridViewItems.Rows.Count > 0) && isInvoice == false)
{
ConfirmpopFunctionality();
}
else
{
frmCloseApp fmclose = new frmCloseApp();
fmclose.ShowDialog();
if (frmCloseApp.status == "Switch")
{
this.Close();
frmLogin obj = new frmLogin();
obj.ShowDialog();
}
}
}
void AddNewCustomer()
{
frmCustomer obj = new frmCustomer();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = new Point(this.Width + this.Location.X - 333, 7);
obj.ShowDialog();
}
void EditCustomerAllInformation(string id)
{
frmCustomer customer = new frmCustomer();
customer.StartPosition = FormStartPosition.Manual;
customer.Location = new Point(this.Width + this.Location.X - 355, 10);
Control[] ID = customer.Controls.Find("HdnField", true);
//int Customer_ID = (int)gridCustomerList.Rows[e.RowIndex].Cells[0].Value;
//List<POS_Customer> Customers = new List<POS_Customer>();
//Customers = ERPManagement.GetInstance.SelectCustomers();
//var CustomerDet = from cust in Customers
// where cust.Customer_ID == Customer_ID
// select cust;
//if (CustomerDet.Count() > 0)
//{
// ID[0].Text = CustomerDet.ToList()[0].Customer_ID.ToString();
//}
ID[0].Text = id;
customer.ShowDialog();
}
#endregion
#region BarcodeDetails
//-------scan image change --------------------
private void changeScanImage(string code)
{
if (code != string.Empty && code != "")
{
pictureBox5.Image = POS.Properties.Resources._barcode_scanning_gray;
}
else
{
pictureBox5.Image = POS.Properties.Resources._barcode_scanning;
}
}
//--------------scan customer layalitycard------------
private void GetCustomerbyCard(string cardno)
{
List<POS_Customer> customerlist = new List<POS_Customer>();
customerlist = ERPManagement.GetInstance.SelectCustomers();
var customer = from cust in customerlist
where cust.Loyality_Card_No == cardno
select cust;
if (customer.ToList().Count > 0)
{
if (customer.ToList()[0].Customer_ID != null && customer.ToList()[0].Customer_ID != 0)
{
string custid = customer.ToList()[0].Customer_ID.ToString();
tabDisplay.SelectedIndex = 2;
GetcustomergridFocus(custid);
TxtBarcode.Text = "";
}
}
}
void GetcustomergridFocus(string custid)
{
for (int i = 0; i < dgvCustSearch.Rows.Count; i++)
{
if (dgvCustSearch.Rows[i].Cells["customerid"].Value.ToString() == custid)
{
int rowindex = dgvCustSearch.Rows[i].Cells["customerid"].RowIndex;
// dgvCustSearch.CurrentCell = dgvCustSearch.Rows[rowindex].Cells["customername"];
dgvCustSearch.Rows[rowindex].Selected = true;
}
}
}
public void GetCustomerInformation()
{
if (lblCustomerName.InvokeRequired || lblCustIdNo.InvokeRequired || lblLastVisit.InvokeRequired || lblTotalVisits.InvokeRequired
)
{
delGetCustomerInformation del = new delGetCustomerInformation(GetCustomerInformation);
this.Invoke(del, new object[] { });
}
else
{
List<POS_Customer> Customerlist = new List<POS_Customer>();
Customerlist = ERPManagement.GetInstance.SelectCustomers();
var lnqCustomer1 = (from customer in Customerlist
where customer.Customer_ID == customeridshipping
orderby customer.Customer_Shipping_Detail_ID
select customer);
if (lnqCustomer1.ToList().Count > 0)
{
var lnqCustomer = lnqCustomer1.ToList().ElementAt(lnqCustomer1.ToList().Count - 1);
if (lnqCustomer.Imag != null)
{
byte[] bt = (byte[])lnqCustomer.Imag;
MemoryStream ms = new MemoryStream(bt);
pbCustomerImage.Image = Image.FromStream(ms);
}
else
{
pbCustomerImage.Image = POS.Properties.Resources._user_icon;
}
if (lnqCustomer.Customer_Name != null && lnqCustomer.Customer_Name != "")
lblCustomerName.Text = lnqCustomer.Customer_Name.ToString();
if (lnqCustomer.Loyality_Card_No != null && lnqCustomer.Loyality_Card_No != "")
lblCustIdNo.Text = "CID : " + lnqCustomer.Loyality_Card_No.ToString();
if (lnqCustomer.Last_Visit_Date != null && lnqCustomer.Last_Visit_Date != null)
lblLastVisit.Text = "Last Visit : " + lnqCustomer.Last_Visit_Date;
if (lnqCustomer.Total_Visit != null)
lblTotalVisits.Text = "Total Visit : " + lnqCustomer.Total_Visit.ToString();
if (lnqCustomer.Total_Sale != null && lnqCustomer.Total_Sale.ToString() != "")
lblTotalSales.Text = "Total Sale : " + lnqCustomer.Total_Sale.ToString();
if (lnqCustomer.Mobile_No != null && lnqCustomer.Mobile_No.ToString() != "")
lblPhone.Text = "Phone : " + lnqCustomer.Mobile_No.ToString();
if (lnqCustomer.Customer_ID != null && lnqCustomer.Customer_ID.ToString() != "")
{
Cust_ID = lnqCustomer.Customer_ID;
}
//=========== Shipping Info =================
// BlankShipping();
string address = "";
if (lnqCustomer.Ship_Address1 != null && lnqCustomer.Ship_Address1 != "")
{
string[] slist = lnqCustomer.Ship_Address1.ToString().Split(' ');
if (slist.Length > 0) address = slist[0];
if (slist.Length > 1) address += " " + slist[1] + " ...";
LblAddress1.Text = "Address1 : " + address;
ToolTip11.SetToolTip(this.LblAddress1, "");
ToolTip11.SetToolTip(this.LblAddress1, lnqCustomer.Ship_Address1.ToString());
LblAddress1.Cursor = Cursors.Hand;
}
else
{
LblAddress1.Text = "Address1 : N/A";
}
if (lnqCustomer.Ship_Address2 != null && lnqCustomer.Ship_Address2 != "")
{
string[] slist = lnqCustomer.Ship_Address2.ToString().Split(' ');
if (slist.Length > 0) address = slist[0];
if (slist.Length > 1) address += " " + slist[1] + " ...";
LblAddress2.Text = "Address2 : " + address;
ToolTip22.SetToolTip(this.LblAddress1, "");
ToolTip22.SetToolTip(this.LblAddress2, lnqCustomer.Ship_Address2.ToString());
LblAddress2.Cursor = Cursors.Hand;
}
else
{
LblAddress2.Text = "Address2 : N/A";
}
if (lnqCustomer.City_ID != null && lnqCustomer.City_ID.ToString() != "")
{
LblCity.Text = "City : " + lnqCustomer.City_ID.ToString();
}
else
{
LblCity.Text = "City : N/A";
}
if (lnqCustomer.Ship_State != null && lnqCustomer.Ship_State.ToString() != "")
{
LblState.Text = "State : " + lnqCustomer.Ship_State;
}
else
{
LblState.Text = "State : N/A";
}
if (lnqCustomer.Ship_Country != null && lnqCustomer.Ship_Country.ToString() != "")
{
LblCountry.Text = "Country : " + lnqCustomer.Ship_Country.ToString();
}
else
{
LblCountry.Text = "Country : N/A";
}
if (lnqCustomer.Zip_Code != null && lnqCustomer.Zip_Code.ToString() != "")
{
LblZip.Text = "Zip : " + lnqCustomer.Zip_Code.ToString();
}
else
{
LblZip.Text = "Pin : N/A";
}
if (lnqCustomer.Ship_Phone != null && lnqCustomer.Ship_Phone.ToString() != "")
{
LblShipPhn.Text = "Phone : " + lnqCustomer.Ship_Phone.ToString();
}
else
{
LblShipPhn.Text = "Phone : N/A";
}
if (lnqCustomer.Ship_Email != null && lnqCustomer.Ship_Email.ToString() != "")
{
LblShipMail.Text = "E-Mail : " + lnqCustomer.Ship_Email.ToString();
}
else
{
LblShipMail.Text = "E-Mail : N/A";
}
if (lnqCustomer.Total_Amount != 0 && lnqCustomer.Total_Amount.ToString() != "")
{
lblShippingCharge.Text = "Shipping Charge: " + lnqCustomer.Total_Amount.ToString();
// TotalShippingCharge=lnqCustomer.Total_Amount.ToString();
}
else
{
lblShippingCharge.Text = "Shipping Charge: N/A";
}
//=========== End Shipping Info =================
}
}
}
public void BlankShipping()
{
LblAddress1.Text = "Address1 : N/A";
LblAddress2.Text = "Address2 : N/A";
LblCity.Text = "City : N/A";
LblState.Text = "State : N/A";
LblCountry.Text = "Country : N/A";
LblZip.Text = "Pin : N/A";
LblShipPhn.Text = "Phone : N/A";
LblShipMail.Text = "E-Mail : N/A";
}
private void GetCustomerDetailInfo(int custid)
{
List<POS_Customer> Customerlist = new List<POS_Customer>();
Customerlist = ERPManagement.GetInstance.SelectCustomers();
var lnqCustomer = from customer in Customerlist
where customer.Customer_ID == custid
select customer;
if (lnqCustomer.ToList().Count > 0)
{
if (lnqCustomer.ToList()[0].Imag != null)
{
byte[] bt = (byte[])lnqCustomer.ToList()[0].Imag;
MemoryStream ms = new MemoryStream(bt);
pbCustomeImaget2.Image = Image.FromStream(ms);
}
else
{
pbCustomeImaget2.Image = POS.Properties.Resources._user_icon;
}
if (lnqCustomer.ToList()[0].Customer_Name != "")
lblCustomerNameT2.Text = lnqCustomer.ToList()[0].Customer_Name.ToString();
if (lnqCustomer.ToList()[0].Loyality_Card_No != "")
lblCIDT2.Text = "CID: " + lnqCustomer.ToList()[0].Loyality_Card_No.ToString();
if (lnqCustomer.ToList()[0].Mobile_No.ToString() != "")
lblPhonet2.Text = "Phone: " + lnqCustomer.ToList()[0].Mobile_No.ToString();
if (lnqCustomer.ToList()[0].Customer_ID != null && lnqCustomer.ToList()[0].Customer_ID.ToString() != "")
{
Cust_ID = lnqCustomer.ToList()[0].Customer_ID;
}
if (lnqCustomer.ToList()[0].Address.ToString() != "")
{
lblAddresst2.Text = "Address: " + lnqCustomer.ToList()[0].Address.ToString();
}
else
{
lblAddresst2.Text = "Address: N/A";
}
if (lnqCustomer.ToList()[0].City.ToString() != "")
{
lblCityt2.Text = "City: " + lnqCustomer.ToList()[0].City.ToString();
}
else
{
lblCityt2.Text = "City: N/A";
}
if (lnqCustomer.ToList()[0].CustomerState.ToString() != "")
{
lblstateT2.Text = "State: " + lnqCustomer.ToList()[0].CustomerState.ToString();
}
else
{
lblstateT2.Text = "State: N/A";
}
if (lnqCustomer.ToList()[0].CustomerCountry.ToString() != "")
{
lblCountryt2.Text = "Country: " + lnqCustomer.ToList()[0].CustomerCountry.ToString();
}
else
{
lblCountryt2.Text = "Country: N/A";
}
if (lnqCustomer.ToList()[0].Email_ID.ToString() != "")
{
lblEmailt2.Text = "Email Id: " + lnqCustomer.ToList()[0].Email_ID.ToString();
}
else
{
lblEmailt2.Text = "Email Id: N/A";
}
if (lnqCustomer.ToList()[0].DateofBirth != null && lnqCustomer.ToList()[0].DateofBirth.ToString() != "")
{
lblDOBt2.Text = "Date of Birth: " + lnqCustomer.ToList()[0].DateofBirth.Value.ToString("dd/MM/yyyy");
}
else
{
lblDOBt2.Text = "Date of Birth: N/A";
}
if (lnqCustomer.ToList()[0].Marriage_Anniversary != null && lnqCustomer.ToList()[0].Marriage_Anniversary.ToString() != "")
{
lblMarriageAnniversaryT2.Text = "Marriage Anniversary: " + lnqCustomer.ToList()[0].Marriage_Anniversary.Value.ToString("dd/MM/yyyy");
}
else
{
lblMarriageAnniversaryT2.Text = "Marriage Anniversary: N/A";
}
if (lnqCustomer.ToList()[0].IS_Married == true)
{
lblmaritalStatust2.Text = "MaritalStatus: Married";
}
else
{
lblmaritalStatust2.Text = "MaritalStatus: Unmarried";
}
if (lnqCustomer.ToList()[0].Gender != null && lnqCustomer.ToList()[0].Gender.ToString() != "")
{
if (lnqCustomer.ToList()[0].Gender == true)
{
lblGendert2.Text = "Gender : Male";
}
else
{
lblGendert2.Text = "Gender: Female";
}
}
else
{
lblGendert2.Text = "Gender: N/A";
}
}
else
{
}
}
private void CreateDataTable()
{
try
{
dtItems = new DataTable();
dtItems.Columns.Add("BarCode", typeof(string));
dtItems.Columns.Add("ItemName", typeof(string));
dtItems.Columns.Add("Item_Quantity", typeof(int));
dtItems.Columns.Add("Discount_Percent", typeof(int));
dtItems.Columns.Add("Is_Taxable", typeof(bool));
dtItems.Columns.Add("Item_Price", typeof(float));
dtItems.Columns.Add("Net_Amount", typeof(float));
dtItems.Columns.Add("Item_Unit_Price", typeof(float));
dtItems.Columns.Add("Tax_Percent", typeof(float));
dtItems.Columns.Add("Discount_Price", typeof(float));
dtItems.Columns.Add("Extended_Price", typeof(float));
//ADD SCHEMEOFFER ID
dtItems.Columns.Add("SchemeID", typeof(int));
dtItems.Columns.Add("IsSerial", typeof(bool));
dtItemForDB = new DataTable();
dtItemForDB.Columns.Add("BarCode", typeof(string));
dtItemForDB.Columns.Add("Item_ID", typeof(int));
dtItemForDB.Columns.Add("Item_Quantity", typeof(int));
dtItemForDB.Columns.Add("Discount_Percent", typeof(int));
dtItemForDB.Columns.Add("Is_Taxable", typeof(bool));
dtItemForDB.Columns.Add("Item_Price", typeof(float));
dtItemForDB.Columns.Add("Net_Amount", typeof(float));
dtItemForDB.Columns.Add("Item_Unit_Price", typeof(float));
dtItemForDB.Columns.Add("Tax_Percent", typeof(float));
dtItemForDB.Columns.Add("Discount_Price", typeof(float));
dtItemForDB.Columns.Add("Extended_Price", typeof(float));
//ADD SCHEMEOFFER ID
dtItems.Columns.Add("SchemeID", typeof(int));
}
catch (Exception ex)
{
}
}
void GetAllBarcodeDetails()
{
try
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (TxtBarcode.Text != string.Empty)
{
decimal Price = 0;
Price = ERPManagement.GetInstance.GetPrice(TxtBarcode.Text.Trim());
Price = Math.Round(Price, 2);
//TxtInvoiceNumber.Text = Price.ToString();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tax = 0;
var TaxList = (from col in ERPManagement.GetInstance.GetAllTaxsetUpDetails()
where col.Active == true
select new
{
TaxSetUpId = col.Tax_Setup_Id,
TaxTitle = col.Tax_Title,
Percentage = col.Float,
Effective_Date = col.Effective_Date,
active = col.Active
}).ToList();
if (TaxList.ToList().Count == 0)
{
tax = 1;
}
for (int i = 0; i < TaxList.ToList().Count; i++)
{
//if (TaxList[i].active == true)
//{
tax += (decimal)TaxList[i].Percentage;
//}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dtBarcode = new DataTable();
dtBarcode = ERPManagement.GetInstance.GetAllBarcodeDetailsApproveByBarcode(TxtBarcode.Text.Trim());
if (dtBarcode.Rows.Count > 0)
{
Item_ID = int.Parse(dtBarcode.Rows[0]["Item_ID"].ToString());
//TxtItemName.Text = dtBarcode.Rows[0]["item_name"].ToString();
ItemName = dtBarcode.Rows[0]["item_name"].ToString();
if (EditQuantity == true)
{
EditQuantity = false;
}
//check entry counttextbox
else if (iscountqty == true)
{
Quantity = txtCountNo.Text;
iscountqty = false;
}
//check when edit in a row in datagridview and item in count textbox
else if (isEdit == true)
{
Quantity = txtCountNo.Text;
}
else
{
Quantity = "1";
//set sqleqt here
Saleqty = 1;
}
//TxtUnitPrice.Text = Price.ToString();
Unitprice = Price.ToString();
// TxtPrice.Text = (float.Parse(TxtQuantity.Text) * float.Parse(TxtUnitPrice.Text)).ToString();
if (TaxList.ToList().Count > 0)
{
chktaxable = "true";
}
else
{
chktaxable = "false";
}
ItemPrice = (float.Parse(Quantity) * float.Parse(Unitprice)).ToString("F");
Taxpercentage = tax.ToString();
Extendedprice = (Convert.ToDecimal(ItemPrice) + (Convert.ToDecimal(ItemPrice) * tax) / 100).ToString();
Discountprice = "0";
DiscountPercentage = "0";
Netprice = Extendedprice.ToString();
//***********************************Scheme & Offer********************************
//var dis = from disc in ERPManagement.GetInstance.GetAllScheemAndOffer()
// where disc.Barcode1 == TxtBarcode.Text
// select disc;
//if (dis.ToList().Count() > 0)
//{
// IsScheme = true;
// //Disqty = int.Parse(dis.ToList()[0].Quantity1.ToString());
// Byeqty = int.Parse(dis.ToList()[0].Quantity1.ToString());
// Getqty = int.Parse(dis.ToList()[0].Quantity2.ToString());
// FlagScheme = 1;
// SchemeID = int.Parse(dis.ToList()[0].Scheme_ID.ToString());
// Schemebarcode = dis.ToList()[0].Barcode2.ToString();
// // TxtBarcode.Text = dis.ToList()[0].Barcode2.ToString();
//}
//else
//{
// IsScheme = false;
//}
//***********************************end Scheme & Offer********************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (_EditGrid == true)
{
EditGrid();
_EditGrid = false;
}
else
{
AddToGrid();
chktaxable = "true";
}
GridViewItems.DataSource = AutoNumberedTable(dtItems);
//clear first row selected
if (GridViewItems.Rows.Count > 0)
{
GridViewItems.Rows[0].Selected = false;
}
//format currency cell
GridViewItems.Columns["Item_Price"].DefaultCellStyle.Format = "F";
GridViewItems.Columns["Net_Amount"].DefaultCellStyle.Format = "F";
////****************add scheme grid here********************////
//if (IsScheme == true)
//{
// AddSchemeToGrid();
// //ChkTaxable.Checked = true;
// chktaxable = "true";
// GridViewItems.DataSource = AutoNumberedTable(dtItems);
//}
////****************end here********************////
CalculateFooterData();
//SetGrid();
//call image for serial
GetIsserialImage();
//visible false item column
BlockItemColumn();
//price column visible false
ResetItemData();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//button enable
//btnF11Total.Enabled = true;
}
else
{
MessageBox.Show("No item found !", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
TxtBarcode.Text = "";
} //AddToGrid();
}
}
catch (Exception ex)
{
}
}
void AddToGrid()
{
if (TxtBarcode.Text != "")
{
bool valid = true;
int i;
for (i = 0; i < dtItems.Rows.Count; i++)
{
//******************************************************************************************
////for scheme
// if (dtItems.Rows[i][0].ToString().Trim() == TxtBarcode.Text.Trim() && dtItems.Rows[i][10].ToString()=="0")
//***************************************************************************
if (dtItems.Rows[i][0].ToString().Trim() == TxtBarcode.Text.Trim())
{
valid = false;
break;
}
}
if (valid)
{
DataRow row = dtItems.NewRow();
DataRow row2 = dtItemForDB.NewRow();
if (TxtBarcode.Text != "")
{
row[0] = TxtBarcode.Text;
row2[0] = TxtBarcode.Text;
}
if (ItemName != "")
{
row[1] = ItemName;
row2[1] = Item_ID;
}
if (Quantity != "")
{
row[2] = int.Parse(Quantity);
row2[2] = int.Parse(Quantity);
}
if (DiscountPercentage != "")
{
row[3] = float.Parse(DiscountPercentage);
row2[3] = float.Parse(DiscountPercentage);
}
if (chktaxable == "true")
{
row[4] = true;
row2[4] = true;
}
else
{
row[4] = false;
row2[4] = false;
}
if (ItemPrice != "")
{
row[5] = float.Parse(ItemPrice).ToString("F");
row2[5] = float.Parse(ItemPrice).ToString("F");
}
if (Extendedprice != "")
{
row[6] = float.Parse(Extendedprice).ToString("F");
row2[6] = float.Parse(Extendedprice).ToString("F");
}
if (Unitprice != "")
{
row[7] = float.Parse(Unitprice).ToString("F");
row2[7] = float.Parse(Unitprice).ToString("F");
}
if (Taxpercentage != "")
{
row[8] = float.Parse(Taxpercentage).ToString();
row2[8] = float.Parse(Taxpercentage).ToString();
}
if (Discountprice != "")
{
row[9] = float.Parse(Discountprice).ToString("F");
row2[9] = float.Parse(Discountprice).ToString("F");
}
if (Extendedprice != "")
{
row[10] = float.Parse(Extendedprice).ToString("F"); //Test for which control
row2[10] = float.Parse(Extendedprice).ToString("F"); //Test for which control
}
//assign schemeid
if (Saleqty >= Byeqty)
{
row[11] = SchemeID;
}
else
{
row[11] = 0;
}
row[12] = Isserial;
//check stock when add 1 quantity
List<POS_FranchiseItemPurchase> objPO = new List<POS_FranchiseItemPurchase>();
objPO = ERPManagement.GetInstance.GetQCApproveStockQuantity();
objPO = objPO.Where(lst => lst.Barcode == TxtBarcode.Text).ToList();
if (objPO.Count > 0)
{
int stockqty = objPO.ToList()[0].StockQuantity;
if (int.Parse(Quantity) > stockqty)
{
MessageBox.Show("Stock not available!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
else
{
MessageBox.Show("Stock not available!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
dtItems.Rows.Add(row);
dtItemForDB.Rows.Add(row2);
}
else
{
//Add with existing if Baecode ia already entered
if (dtItems.Rows[i][7].ToString() != "")
{
int qt = 0;
//check is row edit or not?if edit quantity column set 0
if (isEdit == true)
{
qt = 0;
// isEdit = false;
}
else
{
qt = int.Parse(dtItems.Rows[i][2].ToString());
}
qt += int.Parse(Quantity);
Saleqty = qt;
//check stock
List<POS_FranchiseItemPurchase> objPO = new List<POS_FranchiseItemPurchase>();
objPO = ERPManagement.GetInstance.GetQCApproveStockQuantity();
objPO = objPO.Where(lst => lst.Barcode == TxtBarcode.Text).ToList();
if (objPO.Count > 0)
{
int stockqty = objPO.ToList()[0].StockQuantity;
if (Saleqty > stockqty)
{
MessageBox.Show("Stock not available!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
else
{
MessageBox.Show("Stock not available!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
//CHECK QUANTITY IS SCHEME OR ORIGINAL
if (dtItems.Rows[i][11].ToString().Trim() == "0")
{
dtItems.Rows[i][2] = qt;
dtItemForDB.Rows[i][2] = qt;
}
else if (Convert.ToInt32(dtItems.Rows[i][11].ToString()) > 0)
{
dtItems.Rows[i][2] = int.Parse(Quantity);
dtItemForDB.Rows[i][2] = int.Parse(Quantity);
}
//dtItemForDB.Rows[i][2] = qt;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
float qtprice = float.Parse(dtItems.Rows[i][5].ToString());
if (isEdit == true)
{
//qtprice = float.Parse(ItemPrice);
}
else
{
//qtprice += float.Parse(ItemPrice);
}
dtItems.Rows[i][5] = qtprice.ToString("F");
dtItemForDB.Rows[i][5] = qtprice.ToString("F");
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
float qtextnprice = float.Parse(dtItems.Rows[i][6].ToString());
if (isEdit == true)
{
qtextnprice = float.Parse(Extendedprice);
}
else
{
qtextnprice += float.Parse(Extendedprice);
}
dtItems.Rows[i][6] = qtextnprice;
dtItemForDB.Rows[i][6] = qtextnprice;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
float qtdisprice = float.Parse(dtItems.Rows[i][9].ToString());
if (isEdit == true)
{
qtdisprice += float.Parse(Discountprice);
}
else
{
qtdisprice += float.Parse(Discountprice);
}
dtItems.Rows[i][9] = qtdisprice.ToString("F");
dtItemForDB.Rows[i][9] = qtdisprice.ToString("F");
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
float qtnetprice = float.Parse(dtItems.Rows[i][10].ToString());
if (isEdit == true)
{
qtnetprice = float.Parse(Netprice);
}
else
{
qtnetprice += float.Parse(Netprice);
}
dtItems.Rows[i][10] = qtnetprice.ToString("F");
dtItemForDB.Rows[i][10] = qtnetprice.ToString("F");
}
}
}
else
{
}
}
void AddSchemeToGrid()
{
bool schemevalid = true;
if (IsScheme == true)
{
if (Saleqty >= Byeqty)
{
if (FlagScheme == 1)
{
//if Byeqty=getqty
if (Byeqty - Getqty == 0)
{
Quantity = Saleqty.ToString();
Unitprice = "0";
ItemPrice = "0";
Taxpercentage = "0";
Extendedprice = "0";
Discountprice = "0";
Netprice = "0";
chktaxable = "false";
}
//if Byeqty<getqty
if (Byeqty < Getqty)
{
int mod = Byeqty % 2;
int n = Saleqty / Byeqty;
int qty = Byeqty + (n - 1) * Byeqty;
int actualqty = qty + n;
Quantity = actualqty.ToString();
Unitprice = "0";
ItemPrice = "0";
Taxpercentage = "0";
Extendedprice = "0";
Discountprice = "0";
Netprice = "0";
chktaxable = "false";
}
//if Byeqty>getqty
if (Byeqty > Getqty)
{
int mod = Byeqty % Getqty;
//if (mod == 0)
//{
// TxtQuantity.Text = (int.Parse(TxtQuantity.Text) * Saleqty / Disqty).ToString();
//TxtQuantity.Text = (Saleqty / Byeqty).ToString();
int n = Saleqty / Byeqty;
int qty = Byeqty + (n - 1) * Byeqty;
int actualqty = qty - n;
Quantity = actualqty.ToString();
Unitprice = "0";
ItemPrice = "0";
Taxpercentage = "0";
Extendedprice = "0";
Discountprice = "0";
Netprice = "0";
chktaxable = "false";
}
}
int i;
for (i = 0; i < dtItems.Rows.Count; i++)
{
if (dtItems.Rows[i][0].ToString().Trim() == Schemebarcode && dtItems.Rows[i][11].ToString() != "0")
{
schemevalid = false;
break;
}
}
if (schemevalid)
{
DataRow row = dtItems.NewRow();
DataRow row2 = dtItemForDB.NewRow();
if (TxtBarcode.Text != "")
{
row[0] = Schemebarcode;
row2[0] = Schemebarcode;
}
//if (TxtItemName.Text != "")
if (ItemName != "")
{
row[1] = ItemName;
row2[1] = Item_ID;
}
//if (TxtQuantity.Text != "")
if (Quantity != "")
{
row[2] = int.Parse(Quantity);
row2[2] = int.Parse(Quantity);
}
// if (TxtUnitPrice.Text != "")
if (Unitprice != "")
{
row[3] = float.Parse(Unitprice);
row2[3] = float.Parse(Unitprice);
}
//if (TxtPrice.Text != "")
if (ItemPrice != "")
{
row[4] = float.Parse(ItemPrice);
row2[4] = float.Parse(ItemPrice);
}
// if (ChkTaxable.Checked)
if (chktaxable == "true")
{
row[5] = true;
row[6] = float.Parse(Taxpercentage);
row2[5] = true;
row2[6] = float.Parse(Taxpercentage);
}
else
{
row[5] = false;
row[6] = 0;
row2[5] = false;
row2[6] = 0;
}
//if (TxtExtendedPrice.Text != "")
if (Extendedprice != "")
{
row[7] = float.Parse(Extendedprice).ToString("f");
row2[7] = float.Parse(Extendedprice).ToString("f");
}
// if (TxtDiscountPrice.Text != "")
if (Discountprice != "")
{
row[8] = float.Parse(Discountprice).ToString("f");
row2[8] = float.Parse(Discountprice).ToString("f");
}
// if (TxtExtendedPrice.Text != "")
if (Extendedprice != "")
{
row[9] = float.Parse(Extendedprice).ToString("f"); //Test for which control
row2[9] = float.Parse(Extendedprice).ToString("f"); //Test for which control
}
//assign schemeid
row[10] = SchemeID;
dtItems.Rows.Add(row);
dtItemForDB.Rows.Add(row2);
}
else
{
//Add with existing if Baecode ia already entered
if (dtItems.Rows[i][3].ToString() != "")
{
int qt = int.Parse(dtItems.Rows[i][2].ToString());
//qt += int.Parse(TxtQuantity.Text);
qt += int.Parse(Quantity);
Saleqty = qt;
//CHECK QUANTITY IS SCHEME OR ORIGINAL
if (dtItems.Rows[i][10].ToString().Trim() == "0")
{
dtItems.Rows[i][2] = qt;
dtItemForDB.Rows[i][2] = qt;
}
else if (Convert.ToInt32(dtItems.Rows[i][10].ToString()) > 0)
{
//dtItems.Rows[i][2] = int.Parse(TxtQuantity.Text);
//dtItemForDB.Rows[i][2] = int.Parse(TxtQuantity.Text);
dtItems.Rows[i][2] = int.Parse(Quantity);
dtItemForDB.Rows[i][2] = int.Parse(Quantity);
}
//dtItemForDB.Rows[i][2] = qt;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
qt = int.Parse(dtItems.Rows[i][4].ToString());
//qt += int.Parse(TxtPrice.Text);
qt += int.Parse(ItemPrice);
dtItems.Rows[i][4] = qt;
dtItemForDB.Rows[i][4] = qt;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
float qt1 = float.Parse(dtItems.Rows[i][7].ToString());
//qt1 += float.Parse(TxtExtendedPrice.Text);
qt1 += float.Parse(Extendedprice);
dtItems.Rows[i][7] = qt1;
dtItemForDB.Rows[i][7] = qt1;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
qt1 = float.Parse(dtItems.Rows[i][8].ToString());
//qt1 += float.Parse(TxtDiscountPrice.Text);
qt1 += float.Parse(Discountprice);
dtItems.Rows[i][8] = qt1;
dtItemForDB.Rows[i][8] = qt;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
qt1 = float.Parse(dtItems.Rows[i][9].ToString());
//qt1 += float.Parse(TxtNet.Text);
qt1 += float.Parse(Netprice);
dtItems.Rows[i][9] = qt1;
dtItemForDB.Rows[i][9] = qt1;
}
}
}//salebyeqty
}//isscheme
}
//visible false item grid column
void BlockItemColumn()
{
try
{
GridViewItems.Columns["Item_Unit_Price"].Visible = false;
GridViewItems.Columns["Tax_Percent"].Visible = false;
GridViewItems.Columns["Discount_Price"].Visible = false;
GridViewItems.Columns["Extended_Price"].Visible = false;
GridViewItems.Columns["SchemeID"].Visible = false;
GridViewItems.Columns["IsSerial"].Visible = false;
}
catch (Exception) { }
}
//disable form control
void DisableControl()
{
tabDisplay.Enabled = false;
btnF1Item.Enabled = false;
btnF2Customer.Enabled = false;
btnF3Transaction.Enabled = false;
btnF4Tasks.Enabled = false;
btnF5Tools.Enabled = false;
btnF6Return.Enabled = false;
btnF11Total.Enabled = false;
btnTransactionHistory.Enabled = false;
btnConvertSTO.Enabled = false;
btnOrdersbottom.Enabled = false;
btnPurchaseHistory.Enabled = false;
btnClearHistory.Enabled = false;
btnCustomerDetails.Enabled = false;
GridViewItems.Enabled = false;
TxtBarcode.Enabled = false;
txtCountNo.Enabled = false;
pbPlus.Enabled = false;
pbMinus.Enabled = false;
}
//disable form control
void EnableControl()
{
tabDisplay.Enabled = true;
btnF1Item.Enabled = true;
btnF2Customer.Enabled = true;
btnF3Transaction.Enabled = true;
btnF4Tasks.Enabled = true;
btnF5Tools.Enabled = true;
btnF6Return.Enabled = true;
btnF11Total.Enabled = true;
btnTransactionHistory.Enabled = true;
btnConvertSTO.Enabled = true;
btnOrdersbottom.Enabled = true;
btnPurchaseHistory.Enabled = true;
btnClearHistory.Enabled = true;
btnCustomerDetails.Enabled = true;
GridViewItems.Enabled = true;
TxtBarcode.Enabled = true;
// txtCountNo.Enabled = true;
pbPlus.Enabled = true;
pbMinus.Enabled = true;
}
void EditGrid()
{
if (dtItems.Rows.Count > 0)
{
//---------------------------
dtItems.Rows[index][0] = TxtBarcode.Text;
dtItems.Rows[index][1] = ItemName;
dtItems.Rows[index][2] = int.Parse(Quantity);
dtItems.Rows[index][3] = float.Parse(Unitprice);
dtItems.Rows[index][4] = float.Parse(ItemPrice);
//dtItems.Rows[index][5] = TxtRatePerGram.Text;
dtItems.Rows[index][6] = float.Parse(Taxpercentage);
dtItems.Rows[index][7] = float.Parse(Extendedprice);
dtItems.Rows[index][8] = float.Parse(Discountprice);
dtItems.Rows[index][9] = float.Parse(Extendedprice);
//--------------------------
dtItemForDB.Rows[index][0] = TxtBarcode.Text;
dtItemForDB.Rows[index][1] = Item_ID;
dtItemForDB.Rows[index][2] = int.Parse(Quantity);
dtItemForDB.Rows[index][3] = float.Parse(Unitprice);
dtItemForDB.Rows[index][4] = float.Parse(ItemPrice);
//dtItemForDB.Rows[index][5] = TxtRatePerGram.Text;
dtItemForDB.Rows[index][6] = float.Parse(Taxpercentage);
dtItemForDB.Rows[index][7] = float.Parse(Extendedprice);
dtItemForDB.Rows[index][8] = float.Parse(Discountprice);
dtItemForDB.Rows[index][9] = float.Parse(Extendedprice);
}
else
{
AddToGrid();
}
}
void FillData()
{
GridViewItems.DataSource = dtItems;
ResetItemData();
CalculateFooterData();
//SetGrid();
}
void ResetItemData()
{
TxtBarcode.Text = "";
txtCountNo.Text = "";
ItemName = "";
Quantity = "";
Unitprice = "";
ItemPrice = "";
chktaxable = "false";
Taxpercentage = "";
Extendedprice = "";
Discountprice = "";
Netprice = "";
FlagScheme = 0;
SchemeID = 0;
//stockprogressBar.Value = 0;
GridViewItems.Rows[0].Selected = false;
}
void CalculateFooterData()
{
ResetVariables();
for (int i = 0; i < dtItems.Rows.Count; i++)
{
TotalItems += int.Parse(dtItems.Rows[i]["Item_Quantity"].ToString());
//if (dtItems.Rows[i]["Item_Price"].ToString() != "")
//{
// TotalTaxableAmount += Convert.ToDecimal(dtItems.Rows[i]["Item_Price"].ToString());
//}
if (dtItems.Rows[i]["Item_Price"].ToString() != "" && dtItems.Rows[i]["Item_Unit_Price"].ToString() != "")
{
float TotItemprice = (float.Parse(dtItems.Rows[i]["Item_Quantity"].ToString()) * float.Parse(dtItems.Rows[i]["Item_Unit_Price"].ToString()));
TotalTaxableAmount += Convert.ToDecimal(TotItemprice.ToString());
}
if (dtItems.Rows[i]["Extended_Price"].ToString() != "")
{
TotalNetAmount += Convert.ToDecimal(dtItems.Rows[i]["Extended_Price"].ToString());
}
if (dtItems.Rows[i]["Discount_Price"].ToString() != "")
{
TotalDiscountAmount += Convert.ToDecimal(dtItems.Rows[i]["Discount_Price"].ToString());
}
TotalAmount = (TotalNetAmount - TotalDiscountAmount);
TotalTaxAmount = (TotalNetAmount - TotalTaxableAmount);
TotalAdjustAmount = 0;
}
TxtTotalNoOfItems = TotalItems.ToString();
TxtTotalAmount = TotalTaxableAmount.ToString("F"); //Doubt
TxtTotalTaxAmount = TotalTaxAmount.ToString("F");
TxtTotalDiscountAmount = TotalDiscountAmount.ToString("F");
TxtTotalAdjustAmount = TotalAdjustAmount.ToString("F");
TxtNetAmount = TotalNetAmount.ToString(); //Doubt
//total net amount with shiping amount
TotalNetwithship = TotalNetAmount + TotalShippingCharge;
lblGrandTotal.Text = TotalNetwithship.ToString("F");
}
void ResetVariables()
{
TotalItems = 0;
TotalAmount = 0; TotalDiscountAmount = 0; TotalTaxableAmount = 0; TotalTaxAmount = 0; TotalAdjustAmount = 0; TotalNetAmount = 0;
}
//discount
public void ApplyDiscountOnGrid()
{
int _operation = frmDiscount.StaticoperationValue;
decimal _discount = frmDiscount.StaticdiscountValue;
decimal _discountpercentage = frmDiscount.StaticDiscountPercentage;
if (_operation == 2) //% in unit price
{
float price = float.Parse(dtItems.Rows[index][5].ToString());//unitprice
_discount = Convert.ToDecimal(dtItems.Rows[index][7].ToString()) - frmDiscount.StaticdiscountValue;
//dtItems.Rows[index][7] = _discount.ToString();
// dtItems.Rows[index][5] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][2].ToString()) * Convert.ToDecimal(dtItems.Rows[index][7].ToString())), 2).ToString();
dtItems.Rows[index][5] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][2].ToString()) * Convert.ToDecimal(_discount.ToString())), 2).ToString();
dtItems.Rows[index][6] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][5].ToString()) + (Convert.ToDecimal(dtItems.Rows[index][5].ToString()) * tax) / 100), 2).ToString();
dtItems.Rows[index][9] = Math.Round((frmDiscount.StaticdiscountValue * Convert.ToDecimal(dtItems.Rows[index][2].ToString())), 2).ToString();
dtItems.Rows[index][10] = dtItems.Rows[index][6].ToString();
dtItems.Rows[index][3] = _discountpercentage.ToString();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// dtItemForDB.Rows[index][7] = _discount.ToString();
dtItemForDB.Rows[index][5] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][2].ToString()) * Convert.ToDecimal(dtItems.Rows[index][3].ToString())), 2).ToString();
dtItemForDB.Rows[index][6] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][5].ToString()) + (Convert.ToDecimal(dtItems.Rows[index][5].ToString()) * tax) / 100), 2).ToString();
dtItemForDB.Rows[index][9] = Math.Round((frmDiscount.StaticdiscountValue * Convert.ToDecimal(dtItems.Rows[index][2].ToString())), 2).ToString();
dtItemForDB.Rows[index][10] = dtItems.Rows[index][6].ToString();
dtItems.Rows[index][3] = _discountpercentage.ToString();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
}
else if (_operation == 1) //% in extended price
{
dtItems.Rows[index][9] = Math.Round(frmDiscount.StaticdiscountValue, 2).ToString();
dtItems.Rows[index][10] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][6]) - frmDiscount.StaticdiscountValue), 2).ToString();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
dtItemForDB.Rows[index][9] = Math.Round(frmDiscount.StaticdiscountValue, 2).ToString();
dtItemForDB.Rows[index][10] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][6]) - frmDiscount.StaticdiscountValue), 2).ToString();
dtItems.Rows[index][3] = _discountpercentage.ToString();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
}
else if (_operation == 3) // Amount in extended price
{
dtItems.Rows[index][9] = Math.Round(frmDiscount.StaticdiscountValue, 2).ToString();
dtItems.Rows[index][10] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][6]) - frmDiscount.StaticdiscountValue), 2).ToString();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
dtItemForDB.Rows[index][9] = Math.Round(frmDiscount.StaticdiscountValue, 2).ToString();
dtItemForDB.Rows[index][10] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][6]) - frmDiscount.StaticdiscountValue), 2).ToString();
dtItems.Rows[index][3] = _discountpercentage.ToString();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
}
else if (_operation == 4)
{
float price = float.Parse(dtItems.Rows[index][5].ToString());
//
_discount = Convert.ToDecimal(dtItems.Rows[index][5]) - frmDiscount.StaticdiscountValue;
// dtItems.Rows[index][7] = Math.Round(_discount, 2).ToString();
dtItems.Rows[index][5] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][2]) * Convert.ToDecimal(dtItems.Rows[index][3])), 2).ToString();
dtItems.Rows[index][6] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][5]) + (Convert.ToDecimal(dtItems.Rows[index][5]) * tax) / 100), 2).ToString();
dtItems.Rows[index][9] = Math.Round((frmDiscount.StaticdiscountValue * Convert.ToDecimal(dtItems.Rows[index][2])), 2).ToString();
dtItems.Rows[index][10] = dtItems.Rows[index][6];
dtItems.Rows[index][3] = _discountpercentage.ToString();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// dtItemForDB.Rows[index][7] = Math.Round(_discount, 2).ToString();
dtItemForDB.Rows[index][5] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][2]) * Convert.ToDecimal(dtItems.Rows[index][3])), 2).ToString();
dtItemForDB.Rows[index][6] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][5]) + (Convert.ToDecimal(dtItems.Rows[index][5]) * tax) / 100), 2).ToString();
dtItemForDB.Rows[index][9] = Math.Round((frmDiscount.StaticdiscountValue * Convert.ToDecimal(dtItems.Rows[index][2])), 2).ToString();
dtItemForDB.Rows[index][10] = dtItems.Rows[index][6];
dtItems.Rows[index][3] = _discountpercentage.ToString();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
}
GridViewItems.DataSource = AutoNumberedTable(dtItems);
}
//barcode event
private void btnFind_Click(object sender, EventArgs e)
{
GetProductSearch();
}
private void btnCustFind_Click(object sender, EventArgs e)
{
GetCustomerSearch();
}
private void TxtBarcode_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyValue == 13)
{
GetAllBarcodeDetails();
}
}
private void TxtBarcode_TextChanged(object sender, EventArgs e)
{
//------change image at the time of scann------
changeScanImage(TxtBarcode.Text);
if (_EditGrid == true)
{
}
else if (isEdit == true)
{
}
else if (isItemGridClick == true) { }
else if (TxtBarcode.Text.Length == 14)
{
//get focus in datagridview row
GetDatagridFocus(TxtBarcode.Text);
BarcodeMarker(TxtBarcode.Text);
GetAllBarcodeDetails();
}
if (TxtBarcode.Text.Length == 12)
{
GetCustomerbyCard(TxtBarcode.Text);
}
}
//textbox enter event for virtual keyboard
private void TxtBarcode_Enter(object sender, EventArgs e)
{
j = 1;
if (TxtBarcode.Text == string.Empty)
{
UC_virtual_keyboard.UserControl1.s = "";
changeScanImage(TxtBarcode.Text);
}
else
{
UC_virtual_keyboard.UserControl1.s = TxtBarcode.Text;
}
}
//-------get focus to search customer ------------------------
void GetDatagridFocus(string barcode)
{
for (int i = 0; i < dgvProdSearch.Rows.Count; i++)
{
if (dgvProdSearch.Rows[i].Cells["Barcode"].Value.ToString() == barcode)
{
int rowindex = dgvProdSearch.Rows[i].Cells["Barcode"].RowIndex;
//dgvProdSearch.CurrentCell = dgvProdSearch.Rows[rowindex].Cells["ItemName"];
dgvProdSearch.Rows[rowindex].Selected = true;
}
}
}
public Image NewImage(Image image, int width, int height)
{
Image resizedImage = new Bitmap(width, height);
using (Graphics graphics = Graphics.FromImage(resizedImage))
{
graphics.Clear(Color.White);
graphics.DrawImage(image, new Rectangle(0, 0, 25, 15), new Rectangle(0, 0, 25, 15), GraphicsUnit.Pixel);
}
return resizedImage;
}
private void GetIsserialImage()
{
Image img = Resources._key_board;
for (int i = 0; i < GridViewItems.Rows.Count; i++)
{
//if (GridViewItems.Rows[i].Cells["Column1"].Value.ToString() == barcode)
//{
// int rowindex = GridViewItems.Rows[i].Cells["Column1"].RowIndex;
if (GridViewItems.Rows[i].Cells["Isserial"].Value.ToString() == "True")
{
GridViewItems.Rows[i].Cells["srlimg"].Value = NewImage(img, 15, 15);
}
else
{
GridViewItems.Rows[i].Cells["srlimg"].Value = NewImage(img, 1, 1);
}
//}
//else
//{
//}
}
}
private void txtCountNo_KeyDown()
{
//iscountqty = true;
//GetAllBarcodeDetails();
//TxtBarcode.Text = "";
////focus current grid row
//if (isEdit == true)
//{
// GridViewItems.Rows[rowindex].Selected = true;
// isEdit = false;
//}
}
private void GridViewItems_RowEnter(object sender, DataGridViewCellEventArgs e)
{
GridViewItems.Rows[e.RowIndex].Selected = true;
}
frmDiscount ob = null;
private void GridViewItems_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
isItemGridClick = true;
//TxtBarcode.Text = GridViewItems.Rows[e.RowIndex].Cells["ItemBarcode"].Value.ToString();
txtCountNo.Text = GridViewItems.Rows[e.RowIndex].Cells["Item_Quantity"].Value.ToString();
//assign for popup serial page
QtyForSerialno = int.Parse(GridViewItems.Rows[e.RowIndex].Cells["Item_Quantity"].Value.ToString());
BarcodeForSerialno = GridViewItems.Rows[e.RowIndex].Cells["ItemBarcode"].Value.ToString();
isItemGridClick = false;
try
{
if (GridViewItems.CurrentCell == GridViewItems.Rows[e.RowIndex].Cells["Discount_Price"])
{
//EditGrid = true;
ob = new frmDiscount("");
try
{
TempSale t = listTempSale.Single(a => a.RowNo == e.RowIndex);
if (t != null)
ob = new frmDiscount(t.Percentage + ":" + t.Type);
}
catch { }
index = GridViewItems.CurrentRow.Index;
if (dtItems.Rows[index]["Item_Unit_Price"].ToString() != "")//change 27-02-2013
{
ob.UnitPrice = decimal.Parse(dtItems.Rows[index]["Item_Unit_Price"].ToString());
}
if (dtItems.Rows[index]["Extended_Price"].ToString() != "")
{
ob.ExtendedPrice = Convert.ToDecimal(dtItems.Rows[index]["Extended_Price"]);
}
ob.StartPosition = FormStartPosition.Manual;
ob.Location = tabDisplay.Location; //Cursor.Position;
ob.Location = new Point(ob.Location.X + this.Location.X + 5, this.Location.Y + ob.Location.Y + 25);
ob.ShowDialog();
CalculateDiscount(index);
ApplyDiscountOnGrid();
CalculateFooterData();
}
//open srial popup
try
{
if (GridViewItems.CurrentCell == GridViewItems.Rows[e.RowIndex].Cells["srlimg"])
{
frmPoupSerialNo obj = new frmPoupSerialNo();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = new Point(Cursor.Position.X, Cursor.Position.Y);
obj.ShowDialog();
}
}
catch { }
//check stock progressbar
/*
List<POS_FranchiseItemPurchase> objPO = new List<POS_FranchiseItemPurchase>();
objPO = ERPManagement.GetInstance.GetQCApproveStockQuantity();
int stockqty = 0;
objPO = objPO.Where(lst => lst.Barcode == TxtBarcode.Text).ToList();
if (objPO.Count > 0)
{
stockqty = objPO.ToList()[0].StockQuantity;
//set value here
stockprogressBar.Minimum = 0;
stockprogressBar.Maximum = 100;
stockprogressBar.Value = stockqty;
}
else
{
//set value here
stockprogressBar.Minimum = 0;
stockprogressBar.Maximum = 100;
stockprogressBar.Value = stockqty;
}*/
// BarcodeMarker(TxtBarcode.Text);
BarcodeMarker(BarcodeForSerialno);
}
catch { }
}
}
void CalculateDiscount(int rowno)
{
List<TempSale> preTemp = (from f in listTempSale
where f.RowNo != rowno
select f).ToList();
listTempSale.Clear();
TempSale obj = new TempSale();
obj.Value = frmDiscount.StaticdiscountValue.ToString();
obj.Percentage = frmDiscount.StaticDiscountPercentage.ToString();
obj.RowNo = index;
obj.Type = frmDiscount.Type;
foreach (TempSale item in preTemp) listTempSale.Add(item);
listTempSale.Add(obj);
}
List<TempSale> listTempSale = new List<TempSale>();
public class TempSale
{
public int RowNo { get; set; }
public string Value { get; set; }
public string Percentage { get; set; }
public string Type { get; set; }
}
#endregion
#region RightsideGridviewEvent
private void dgvProdSearch_DoubleClick(object sender, EventArgs e)
{
try
{
string barcode = dgvProdSearch.CurrentRow.Cells["Barcode"].Value.ToString();
Isserial = bool.Parse(dgvProdSearch.CurrentRow.Cells["Isserial"].Value.ToString());
//check row click or not
_rowclickGrid = true;
TxtBarcode.Text = dgvProdSearch.CurrentRow.Cells["Barcode"].Value.ToString();
//change normal color
txtCountNo.BackColor = System.Drawing.Color.White;
}
catch { }
}
private void dgvCustSearch_DoubleClick(object sender, EventArgs e)
{
try
{
dgvCustSearch.CurrentRow.Selected = true;
customeridshipping = int.Parse(dgvCustSearch.CurrentRow.Cells["customerid"].Value.ToString());
//GetCustomerInformation();
// GetCustomerDetailInfo(customeridshipping);
Thread thcustomer = new Thread(new ThreadStart(GetCustomerInformation));
thcustomer.IsBackground = true;
thcustomer.Start();
}
catch { }
}
private void dgvCustSearch_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
if (dgvCustSearch.Columns[e.ColumnIndex].Name.ToString() == "Edit")
{
try
{
customeridshipping = int.Parse(dgvCustSearch.Rows[e.RowIndex].Cells["customerid"].Value.ToString());
EditCustomerDetails(customeridshipping);
}
catch
{ }
GetCustomer();
}
//try
//{
// dgvCustSearch.Rows[e.RowIndex].Selected = true;
// customeridshipping = int.Parse(dgvCustSearch.Rows[e.RowIndex].Cells["customerid"].Value.ToString());
// //GetCustomerDetailInfo(customeridshipping);
// //GetCustomerInformation(customeridshipping);
// //lblcu
// lblmrp.Visible = true;
// lblbrand.Visible = true;
// lblcategory.Visible = true;
//}
//catch { }
}
}
private void dgvProdSearch_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
try
{
dgvProdSearch.Rows[e.RowIndex].Selected = true;
Barcode = dgvProdSearch.Rows[e.RowIndex].Cells["Barcode"].Value.ToString();
Itemid = int.Parse(dgvProdSearch.Rows[e.RowIndex].Cells["ItemId"].Value.ToString());
GetItemDetailInfo(Barcode);
if (GridViewItems.Rows.Count > 0)
{
GridViewItems.Rows[0].Selected = false;
}
//change normal color
txtCountNo.BackColor = System.Drawing.Color.White;
stockprogressBar.Value = 0;
//call variation details here
GetVariationProduct(Itemid);
////if (!loading)
////{
//// //if (TxtBarcode.Text.Trim() == dgvProdSearch.Rows[e.RowIndex].Cells[1].Value.ToString()) IsBarcode = true;
//// //else IsBarcode = false;
//// //TxtBarcode.Text = dgvProdSearch.Rows[e.RowIndex].Cells[1].Value.ToString();
//// //if (IsBarcode)
//// // GetAllBarcodeDetails();
//// //IsBarcode = true;
////}
}
catch
{ }
}
}
private void dgvProdSearch_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
TxtBarcode.Text = dgvProdSearch.CurrentRow.Cells[1].Value.ToString();
}
else
{
}
}
private void dgvProdSearch_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
TxtBarcode.Text = dgvProdSearch.CurrentRow.Cells[1].Value.ToString();
}
else
{
}
}
private void dgvCustSearch_KeyUp(object sender, KeyEventArgs e)
{
try
{
customeridshipping = int.Parse(dgvCustSearch.CurrentRow.Cells["customerid"].Value.ToString());
GetCustomerInformation();
}
catch { }
}
private void dgvCustSearch_KeyDown(object sender, KeyEventArgs e)
{
try
{
customeridshipping = int.Parse(dgvCustSearch.CurrentRow.Cells["customerid"].Value.ToString());
GetCustomerInformation();
}
catch { }
}
private void txtCustomerSearch_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
GetCustomerBySearch();
}
}
private void txtSearch_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
GetProductSearch();
}
}
private void txtSearch_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
if (combosearch.SelectedIndex == 0)
{
if (char.IsDigit(e.KeyChar) == false && (Keys)e.KeyChar != Keys.Back)
{
e.Handled = true;
return;
}
}
if (combosearch.SelectedIndex == 1)
{
if (char.IsDigit(e.KeyChar) == true && char.IsLetter(e.KeyChar) == false && char.IsControl(e.KeyChar) == false && e.KeyChar != '.' && e.KeyChar != ' ')
{
e.Handled = true;
return;
}
}
}
catch (Exception ex)
{
}
}
private void txtCustomerSearch_KeyPress(object sender, KeyPressEventArgs e)
{
if (cmbCustomer.Text == "By Name")
{
txtCustomerSearch.MaxLength = 50;
try
{
if (char.IsDigit(e.KeyChar) == true && char.IsLetter(e.KeyChar) == false && char.IsControl(e.KeyChar) == false && e.KeyChar != '.' && e.KeyChar != ' ')
{
e.Handled = true;
return;
}
}
catch (Exception ex)
{
}
}
if (cmbCustomer.Text == "By Phone No")
{
txtCustomerSearch.MaxLength = 14;
try
{
if (char.IsDigit(e.KeyChar) == false && (Keys)e.KeyChar != Keys.Back)
{
e.Handled = true;
return;
}
}
catch (Exception ex)
{
}
}
if (cmbCustomer.Text == "By Card No")
{
txtCustomerSearch.MaxLength = 20;
try
{
if (char.IsDigit(e.KeyChar) == false && (Keys)e.KeyChar != Keys.Back)
{
e.Handled = true;
return;
}
}
catch (Exception ex)
{
}
}
}
#endregion
#endregion
#region PagecontrolEvent
private void btnClose_Click(object sender, EventArgs e)
{
FormExit();
}
private void btnLock_Click(object sender, EventArgs e)
{
frmLockScreen fmlock = new frmLockScreen();
fmlock.ShowDialog();
}
private void btnHelp_Click(object sender, EventArgs e)
{
}
private void btnMail_Click(object sender, EventArgs e)
{
}
private void btnGroupUser_Click(object sender, EventArgs e)
{
}
private void btnChat_Click(object sender, EventArgs e)
{
}
private void btnFn_Click(object sender, EventArgs e)
{
}
private void btnKeyboard_Click(object sender, EventArgs e)
{
if (i == 0)
{
i = 1;
userControl11.Visible = true;
}
else
{
i = 0;
userControl11.Visible = false;
}
}
private void btnF1Item_Click(object sender, EventArgs e)
{
Point p = btnF1Item.Location;
p = new Point(p.X + this.Location.X, this.Location.Y + p.Y - 164);
cmItems.Show(this, this.PointToClient(p));
}
private void tsmNewItem_Click(object sender, EventArgs e)
{
}
private void tsVEItem_Click(object sender, EventArgs e)
{
}
private void tsSearchItem_Click(object sender, EventArgs e)
{
//frmSearchItem obj = new frmSearchItem();
//obj.ShowDialog();
tabDisplay.SelectedIndex = 1;
combosearch.Text = "Search";
combosearch.Enabled = true;
txtSearch.Enabled = true;
txtSearch.Focus();
}
private void tsItemNo_Click(object sender, EventArgs e)
{
tabDisplay.SelectedIndex = 1;
// combosearch.SelectedIndex = 1;
combosearch.Text = "Item";
combosearch.Enabled = true;
txtSearch.Enabled = true;
txtSearch.Focus();
}
private void tsDescription_Click(object sender, EventArgs e)
{
tabDisplay.SelectedIndex = 1;
//combosearch.SelectedIndex = 0;
combosearch.Text = "Barcode";
combosearch.Enabled = true;
txtSearch.Enabled = true;
txtSearch.Focus();
}
private void tsSubstitutes_Click(object sender, EventArgs e)
{
}
private void tsRInventory_Click(object sender, EventArgs e)
{
}
private void btnF2Customer_Click(object sender, EventArgs e)
{
Point p = btnF2Customer.Location;
p = new Point(p.X + this.Location.X, this.Location.Y + p.Y - 292);
cmCustomer.Show(this, this.PointToClient(p));
}
private void tsmNewCustomer_Click(object sender, EventArgs e)
{
AddNewCustomer();
GetCustomer();
}
private void tsmVECustomerInfo_Click(object sender, EventArgs e)
{
//frmSearchCustomer obj = new frmSearchCustomer();
// obj.ShowDialog();
if (Cust_ID > 0)
{
EditCustomerDetails(Cust_ID);
GetCustomer();
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
private void tsmSearch_Click(object sender, EventArgs e)
{
//frmSearchCustomer obj = new frmSearchCustomer("search");
//obj.Location = new Point(this.Width + this.Location.X - 333, 132);
//obj.ShowDialog();
//if (obj.CloseFor == "add") AddNewCustomer();
//else
//{
// if (obj.customerId != "") EditCustomerAllInformation(obj.customerId);
//}
tabDisplay.SelectedIndex = 2;
cmbCustomer.SelectedItem = "Select";
dgvCustSearch.DataSource = null;
txtCustomerSearch.Focus();
txtCustomerSearch.Text = "";
}
private void tsmCustomerNo_Click(object sender, EventArgs e)
{
//frmSearchCustomer obj = new frmSearchCustomer("no");
//obj.Location = new Point(this.Width + this.Location.X - 333, 132);
//obj.ShowDialog();
//if (obj.CloseFor == "add") AddNewCustomer();
//else
//{
// if (obj.customerId != "") EditCustomerAllInformation(obj.customerId);
//}
tabDisplay.SelectedIndex = 2;
cmbCustomer.SelectedItem = "By Card No";
dgvCustSearch.DataSource = null;
txtCustomerSearch.Focus();
txtCustomerSearch.Text = "";
}
private void tsmByCName_Click(object sender, EventArgs e)
{
//frmSearchCustomer obj = new frmSearchCustomer("name");
//obj.Location = new Point(this.Width + this.Location.X - 333, 132);
//obj.ShowDialog();
//if (obj.CloseFor == "add") AddNewCustomer();
//else
//{
// if (obj.customerId != "") EditCustomerAllInformation(obj.customerId);
//}
tabDisplay.SelectedIndex = 2;
cmbCustomer.SelectedItem = "By Name";
dgvCustSearch.DataSource = null;
txtCustomerSearch.Focus();
txtCustomerSearch.Text = "";
}
private void tsmCphoneNo_Click(object sender, EventArgs e)
{
//frmSearchCustomer obj = new frmSearchCustomer("phone");
//obj.Location = new Point(this.Width + this.Location.X - 333, 132);
//obj.ShowDialog();
//if (obj.CloseFor == "add") AddNewCustomer();
//else
//{
// if (obj.customerId != "") EditCustomerAllInformation(obj.customerId);
//}
tabDisplay.SelectedIndex = 2;
cmbCustomer.SelectedItem = "By Phone No";
dgvCustSearch.DataSource = null;
txtCustomerSearch.Focus();
txtCustomerSearch.Text = "";
}
private void tsmShippingAddress_Click(object sender, EventArgs e)
{
EditCustomerDetails();
}
private void tsmCClear_Click(object sender, EventArgs e)
{
ClearCustomer();
}
private void tsmMakePayment_Click(object sender, EventArgs e)
{
//frmPayments obj = new frmPayments();
//obj.ShowDialog();
}
private void btnF3Transaction_Click(object sender, EventArgs e)
{
Point p = btnF3Transaction.Location;
p = new Point(p.X + this.Location.X, this.Location.Y + p.Y - 250);
cmTransactionMenu.Show(this, this.PointToClient(p));
}
private void tsmEditTransction_Click(object sender, EventArgs e)
{
}
private void tsmEditLineItem_Click(object sender, EventArgs e)
{
EditGridLineItem();
}
private void tsmRemoveLineI_Click(object sender, EventArgs e)
{
RemoveGridLineItem();
}
private void tsmHold_Click_1(object sender, EventArgs e)
{
if (GridViewItems.Rows.Count > 0)
{
HoldTransaction();
}
else
{
MessageBox.Show("No Item for sale!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 0;
}
//if (dgvCustSearch.SelectedRows.Count > 0)
//{
// SaveData();
// MessageBox.Show("Data Hold Successfully", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
// //call auto invoiceno
// GetAutoInvoiceNo();
// GetTotalSale();
// GetOnHoldSale();
// GetProduct();
// //ResetForm
// ResetForm();
// //clear control
// TxtBarcode.Text = "";
// txtCountNo.Text = "";
//}
//else
//{
// MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// tabDisplay.SelectedIndex = 1;
//}
}
private void tsmRecallTrans_Click(object sender, EventArgs e)
{
Point p = GridViewItems.Location;
p = new Point(GridViewItems.Location.X + this.Location.X + 7, p.Y + 126);
frmViewSale obj = new frmViewSale("0");
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
obj.Location = new Point(p.X, p.Y);
obj.ShowDialog();
SaleId = obj.saleid;
//set saleid to maxsaleid for complee transaction bcoz maxsaleid pass to paymentsell page
maxsaleid = SaleId.ToString();
if (SaleId != 0)
{
GetSaleData();
GetSaleDetails();
GetSaleCustomer();
}
//btnF11Total.Enabled = true;
}
private void tsmCancelTrans_Click(object sender, EventArgs e)
{
try
{
btnmode = "CANCEL";
if ((GridViewItems.Rows.Count > 0) && isInvoice == false)
{
CancelTransaction();
}
else
{
MessageBox.Show("No Item for cancel!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 1;
}
btnmode = "";
}
catch { }
}
private void tsmNoSale_Click(object sender, EventArgs e)
{
}
private void btnF4Tasks_Click(object sender, EventArgs e)
{
Point p = btnF4Tasks.Location;
p = new Point(p.X + this.Location.X, this.Location.Y + p.Y - 260);
cmTaskMenuOptions.Show(this, this.PointToClient(p));
}
private void tsmOpenClose_Click(object sender, EventArgs e)
{
}
private void tsmDropPayout_Click(object sender, EventArgs e)
{
}
private void tsmFindReceipts_Click(object sender, EventArgs e)
{
frmReprintlastrcpt obj = new frmReprintlastrcpt();
obj.Location = Cursor.Position;
//obj.Location = new Point(obj.Location.X, obj.Location.Y - 432);
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
}
private void tsmReprintLR_Click(object sender, EventArgs e)
{
frmReprintlastrcpt obj = new frmReprintlastrcpt();
obj.Location = Cursor.Position;
//obj.Location = new Point(obj.Location.X, obj.Location.Y - 432);
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
}
private void tsmPrinterOff_Click(object sender, EventArgs e)
{
}
private void tsmVoid_Click(object sender, EventArgs e)
{
}
private void tsmVoucher_Click(object sender, EventArgs e)
{
}
private void tsmSwitchUserExit_Click(object sender, EventArgs e)
{
FormExit();
}
private void btnF5Tools_Click(object sender, EventArgs e)
{
Point p = btnF5Tools.Location;
p = new Point(p.X + this.Location.X, this.Location.Y + p.Y - 292);
cmToolsMenuOption.Show(this, this.PointToClient(p));
}
private void tsmCalculator_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("calc.exe");
}
private void tsmTimeClock_Click(object sender, EventArgs e)
{
frmTimeClock obj = new frmTimeClock();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
}
private void tsmGraphs_Click(object sender, EventArgs e)
{
}
private void tsmCurrency_Click(object sender, EventArgs e)
{
frmCurrencyConvertor obj = new frmCurrencyConvertor();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
}
private void tsmFind_Click(object sender, EventArgs e)
{
FrmFind obj = new FrmFind();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
int statusvalue = obj.status;
if (statusvalue == 1)
{
FindItem();
}
if (statusvalue == 2)
{
FindCustomer();
}
if (statusvalue == 3)
{
Transaction("O");
}
if (statusvalue == 4)
{
GetQuotationDetails();
}
if (statusvalue == 5)
{
GetHoldItemDetails();
}
if (statusvalue == 6)
{
GetInvoiceDetails();
}
}
private void tsmEPracticeMode_Click(object sender, EventArgs e)
{
}
private void tsmSystem_Click(object sender, EventArgs e)
{
}
private void tsmManagerView_Click(object sender, EventArgs e)
{
}
private void btnF6Return_Click(object sender, EventArgs e)
{
Point p = btnF6Return.Location;
p = new Point(p.X + this.Location.X, this.Location.Y + p.Y - 100);
cmReturnMenu.Show(this, this.PointToClient(p));
}
private void tsmByReciept_Click(object sender, EventArgs e)
{
}
private void tsmRmCustomer_Click(object sender, EventArgs e)
{
}
private void tsmEReturnMode_Click(object sender, EventArgs e)
{
}
private bool CheckSerialno()
{
// string grditembarcode,serial="";
for (int i = 0; i < GridViewItems.Rows.Count; i++)
{
if (GridViewItems.Rows[i].Cells["Isserial"].Value.ToString() == "True")
{
BarcodeForSerialno = GridViewItems.Rows[i].Cells["ItemBarcode"].Value.ToString();
QtyForSerialno = int.Parse(GridViewItems.Rows[i].Cells["Item_Quantity"].Value.ToString());
//check
bool contains = frmPoupSerialNo.dtSerialNo.AsEnumerable()
.Any(row => BarcodeForSerialno == row.Field<String>("Barcode"));
if (contains == false)
{
frmPoupSerialNo obj = new frmPoupSerialNo();
obj.StartPosition = FormStartPosition.Manual;
//obj.Location = new Point(Cursor.Position.X, Cursor.Position.Y);
obj.Location = GridViewItems.PointToScreen(GridViewItems.GetCellDisplayRectangle(4, i, false).Location);
//GridViewItems.Rows[i].Cells["Isserial"]
obj.ShowDialog();
return false;
}
}
}
return true;
}
private void btnF11Total_Click(object sender, EventArgs e)
{
if (GridViewItems.Rows.Count > 0)
{
// if ((dgvCustSearch.SelectedRows.Count > 0) || Cust_ID > 0)
if (Cust_ID > 0)
{
//check serial no entry or not
if (purpose.ToLower() == "s" || purpose.ToLower() == "ss")
{
if (CheckSerialno() == false)
{
return;
}
}
//------------------
if (SaleId > 0)
{
UpdateData();
}
else
{
SaveData();
}
//SaveData();
if (purpose.ToLower() == "s" || purpose.ToLower() == "ss")
{
frmPaymentSell obj = new frmPaymentSell(this);
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
// obj.Location = new Point(obj.Location.X + this.Location.X + 100, 130);
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
if (obj.PayStatus == "P")
{
ResetForm();
//call auto invoiceno
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
//GetCustomer();
tabDisplay.SelectedIndex = 0;
}
else if (obj.PayStatus == "C")
{
}
}
else
{
// MessageBox.Show("Data Saved Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (purpose == "O")
{
MessageBox.Show("Order Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (purpose == "Q")
{
MessageBox.Show("Quotation Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (purpose == "C")
{
MessageBox.Show("Cancel Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (purpose == "F")
{
return;
}
ResetForm();
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
GetCustomer();
tabDisplay.SelectedIndex = 0;
}
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
else
{
MessageBox.Show("No Item for sale!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 1;
}
}
private void btnOrders_Click(object sender, EventArgs e)
{
Transaction("O");
}
private void btnInvoices_Click(object sender, EventArgs e)
{
GetInvoiceDetails();
}
private void btnNewSales_Click(object sender, EventArgs e)
{
EnableControl();
CurrentDate();
btnF11Total.BackgroundImage = Resources.n_total;
if ((GridViewItems.Rows.Count > 0) && isInvoice == false)
{
ConfirmpopFunctionality();
}
else
{
ResetForm();
lblHeader1.Text = "";
lblHeader1.Text = "Sale Invoices No." + AutoinvoiceNo;
popupimgpurpose = "S";
purpose = "S";
chkstockpurpose = "S";
//reset invoice button click
isInvoice = false;
tabDisplay.SelectedIndex = 1;
}
}
private void btnNewQuotes_Click(object sender, EventArgs e)
{
EnableControl();
CurrentDate();
btnF11Total.BackgroundImage = Resources.saveF11;
if ((GridViewItems.Rows.Count > 0) && isInvoice == false)
{
ConfirmpopFunctionality();
}
else
{
ResetForm();
lblHeader1.Text = "";
lblHeader1.Text = "Quote No." + AutoinvoiceNo;
popupimgpurpose = "Q";
purpose = "Q";
chkstockpurpose = "Q";
//reset invoice button click
isInvoice = false;
tabDisplay.SelectedIndex = 1;
}
}
private void btnNewOrder_Click(object sender, EventArgs e)
{
EnableControl();
CurrentDate();
btnF11Total.BackgroundImage = Resources.saveF11;
if ((GridViewItems.Rows.Count > 0) && isInvoice == false)
{
ConfirmpopFunctionality();
}
else
{
ResetForm();
lblHeader1.Text = "";
popupimgpurpose = "O";
purpose = "O";
chkstockpurpose = "O";
lblHeader1.Text = "Order No." + AutoinvoiceNo;
//reset invoice button click
isInvoice = false;
tabDisplay.SelectedIndex = 1;
}
}
private void pbUpSale_Click(object sender, EventArgs e)
{
frmForOrderQuoteSales objFOQS = new frmForOrderQuoteSales(this);
objFOQS.StartPosition = FormStartPosition.Manual;
// obj.Location = Cursor.Position;
objFOQS.Location = new Point(btnTransactionHistory.Location.X + this.Location.X, btnTransactionHistory.Location.Y + this.Location.Y);
objFOQS.ShowDialog();
}
#endregion
private void pbPlus_Click(object sender, EventArgs e)
{
if (GridViewItems.Rows.Count > 0)
{
if (GridViewItems.SelectedRows.Count > 0)
{
GetNuremicpad();
}
else
{
MessageBox.Show("Select one Item!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
private bool CheckStock()
{
if (purpose == "C")
{
return true;
}
else
{
for (int i = 0; i < dtItems.Rows.Count; i++)
{
string barcode = dtItems.Rows[i]["BarCode"].ToString();
int Itemqty = int.Parse(dtItems.Rows[i]["Item_Quantity"].ToString());
string ItemName = dtItems.Rows[i]["ItemName"].ToString();
List<POS_FranchiseItemPurchase> objPO = new List<POS_FranchiseItemPurchase>();
objPO = ERPManagement.GetInstance.GetQCApproveStockQuantity();
objPO = objPO.Where(lst => lst.Barcode == barcode).ToList();
if (objPO.Count > 0)
{
int stockqty = objPO.ToList()[0].StockQuantity;
if (Itemqty > stockqty)
{
msgstock += Environment.NewLine + ItemName;
foreach (DataGridViewRow dgvr in GridViewItems.Rows)
{
if (dgvr.Cells["ItemBarcode"].Value.ToString() == barcode)
{
dgvr.DefaultCellStyle.BackColor = Color.Thistle;
}
}
// MessageBox.Show("Stock not available!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
if (msgstock.Length > 0)
{
return false;
}
else
{
//reset purpose default value after check stock
purpose = chkstockpurpose;
return true;
}
}
}
private void SaveData()
{
//create default datatable if not in popupserial no
SerialDatatable();
if (CheckStock() == true)
{
try
{
POS_PointOfSale obj = new POS_PointOfSale();
ResetVariables();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for (int i = 0; i < dtItems.Rows.Count; i++)
{
TotalItems += int.Parse(dtItems.Rows[i]["Item_Quantity"].ToString());
TotalTaxableAmount += Convert.ToDecimal(dtItems.Rows[i]["Item_Price"].ToString());
TotalNetAmount += Convert.ToDecimal(dtItems.Rows[i]["Extended_Price"].ToString());
TotalDiscountAmount += Convert.ToDecimal(dtItems.Rows[i]["Discount_Price"].ToString());
TotalAmount += (TotalNetAmount - TotalDiscountAmount);
TotalTaxAmount += (TotalNetAmount - TotalTaxableAmount);
TotalAdjustAmount = 0;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
obj.Sale_Employee_ID = userid; //Will be update after login
obj.Customer_ID = Cust_ID;
obj.Sale_Invoice_Date = DateTime.ParseExact(lblcurrentdate.Text, "M/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
//if (ChkIsAgainstAdvance.Checked)
//{
// obj.Is_Against_Advance = true;
// //obj.Advance_Invoice_No = TxtIsAgainstAdvance.Text;
// obj.Advance_Invoice_No = cmbAdvanced.Text;
//}
//else
//{
// obj.Is_Against_Advance = false;
//}
obj.Is_Against_Advance = false;
obj.Total_No_Of_Items = TotalItems;//
obj.Total_Amount = TotalAmount;//
obj.Total_Discount_Amount = TotalDiscountAmount;//
obj.Total_Taxable_Amount = TotalTaxableAmount;//
obj.Total_Tax_Amount = TotalTaxAmount;//
obj.Total_Adjust_Amount = TotalAdjustAmount;//
obj.Total_Net_Amount = TotalNetAmount;//
obj.DataTableItemSaleDetails = dtItemForDB;
obj.DMLOperation = 1;
obj.DataTableItemSaleSerial = dtserial;// frmPoupSerialNo.dtSerialNo;
obj.Payment_Amount = Decimal.Parse(lblGrandTotal.Text);
obj.FunctionalStatus = purpose;
obj.TranctionStatus = 1;//commit in fisrt time not cancel
obj.PaymentStatus = 0;//paystatus false in firsttime
string ReturnVal = ERPManagement.GetInstance.InsertSales(obj);
string[] Val = ReturnVal.Split('@');
TxtInvoiceNumber = Val[0];
TxtNet = Val[1];
maxsaleid = Val[1];
SaleId = int.Parse(Val[1]);
EditInvoiceNumber = Val[0];
// MessageBox.Show("Data Saved Successfully with Invoice No: " + TxtInvoiceNumber, "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
catch { }
}
else
{
//set defalut purpose to assign variable
chkstockpurpose = purpose;
//set purpose false for not enter to payment or order or qutation
purpose = "F";
MessageBox.Show("Required stock not available for marked item!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
msgstock = "";
}
}
private void UpdateData()
{
//create default datatable if not in popupserial no
SerialDatatable();
if (CheckStock() == true)
{
try
{
POS_PointOfSale obj = new POS_PointOfSale();
ResetVariables();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for (int i = 0; i < dtItems.Rows.Count; i++)
{
TotalItems += int.Parse(dtItems.Rows[i]["Item_Quantity"].ToString());
TotalTaxableAmount += Convert.ToDecimal(dtItems.Rows[i]["Item_Price"].ToString());
TotalNetAmount += Convert.ToDecimal(dtItems.Rows[i]["Extended_Price"].ToString());
TotalDiscountAmount += Convert.ToDecimal(dtItems.Rows[i]["Discount_Price"].ToString());
TotalAmount += (TotalNetAmount - TotalDiscountAmount);
TotalTaxAmount += (TotalNetAmount - TotalTaxableAmount);
TotalAdjustAmount = 0;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
obj.Sale_Employee_ID = userid; //Will be update after login
obj.Customer_ID = Cust_ID;
obj.Sale_Invoice_Date = DateTime.Parse(lblcurrentdate.Text);
//if (ChkIsAgainstAdvance.Checked)
//{
// obj.Is_Against_Advance = true;
// //obj.Advance_Invoice_No = TxtIsAgainstAdvance.Text;
// obj.Advance_Invoice_No = cmbAdvanced.Text;
//}
//else
//{
// obj.Is_Against_Advance = false;
//}
obj.Sale_ID = SaleId;
obj.Sale_Invoice_No = EditInvoiceNumber.ToString();
obj.Is_Against_Advance = false;
obj.Total_No_Of_Items = TotalItems;//
obj.Total_Amount = TotalAmount;//
obj.Total_Discount_Amount = TotalDiscountAmount;//
obj.Total_Taxable_Amount = TotalTaxableAmount;//
obj.Total_Tax_Amount = TotalTaxAmount;//
obj.Total_Adjust_Amount = TotalAdjustAmount;//
obj.Total_Net_Amount = TotalNetAmount;//
obj.DataTableItemSaleDetails = dtItemForDB;
obj.DataTableItemSaleSerial = dtserial;// frmPoupSerialNo.dtSerialNo;
obj.DMLOperation = 2;
obj.Payment_Amount = Decimal.Parse(lblGrandTotal.Text);
obj.FunctionalStatus = purpose;
obj.TranctionStatus = 1;//commit in fisrt time not cancel
obj.PaymentStatus = 0;//paystatus false in firsttime
string ReturnVal = ERPManagement.GetInstance.InsertSales(obj);
//string[] Val = ReturnVal.Split('@');
//TxtInvoiceNumber = Val[0];
//TxtNet = Val[1];
//maxsaleid = Val[1];
// MessageBox.Show("Data Saved Successfully with Invoice No: " + TxtInvoiceNumber, "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
catch { }
}
else
{
//set defalut purpose to assign variable
chkstockpurpose = purpose;
//set purpose false for not enter to payment or order or qutation
purpose = "F";
MessageBox.Show("Required stock not available for marked item!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
msgstock = "";
}
}
#region Method for FIND Page
public void FindItem()
{
tabDisplay.SelectedIndex = 1;
combosearch.Text = "Search";
combosearch.Enabled = true;
txtSearch.Enabled = true;
txtSearch.Focus();
}
public void FindCustomer()
{
tabDisplay.SelectedIndex = 2;
cmbCustomer.Text = "Search";
cmbCustomer.Enabled = true;
txtCustomerSearch.Enabled = true;
txtCustomerSearch.Focus();
}
public void GetHoldItemDetails()
{
FrmFind obj1 = new FrmFind();
obj1.Close();
Point p = GridViewItems.Location;
p = new Point(GridViewItems.Location.X + this.Location.X + 7, p.Y + 126);
frmViewSale obj = new frmViewSale("0");
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
obj.Location = new Point(p.X, p.Y);
obj.ShowDialog();
SaleId = obj.saleid;
//set saleid to maxsaleid for complee transaction bcoz maxsaleid pass to paymentsell page
maxsaleid = SaleId.ToString();
if (SaleId != 0)
{
GetSaleData();
GetSaleDetails();
GetSaleCustomer();
}
}
public void GetQuotationDetails()
{
try
{
FrmFind obj1 = new FrmFind();
obj1.Close();
EnableControl();
ResetForm();
Point p = GridViewItems.Location;
p = new Point(GridViewItems.Location.X + this.Location.X + 7, p.Y + 126);
frmViewSale obj = new frmViewSale("Q");
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
obj.Location = new Point(p.X, p.Y);
obj.ShowDialog();
SaleId = obj.saleid;
//set saleid to maxsaleid for complee transaction bcoz maxsaleid pass to paymentsell page
maxsaleid = SaleId.ToString();
if (SaleId != 0)
{
GetSaleData();
GetSaleDetails();
GetSaleCustomer();
//false gridview line focus
GridViewItems.Rows[0].Selected = false;
stockprogressBar.Value = 0;
}
else
{
ResetForm();
GetAutoInvoiceNo();
}
}
catch
{
}
}
#endregion
#region EditRecord
private void GetSaleData()
{
DataTable dtsale = new DataTable();
dtsale = ERPManagement.GetInstance.GetSale(SaleId);
if (dtsale.Rows.Count > 0)
{
string functionalstatus = dtsale.Rows[0]["Functional_Status"].ToString();
EditInvoiceNumber = dtsale.Rows[0]["Sale_Invoice_No"].ToString();
if (functionalstatus == "S")
{
purpose = "S";
chkstockpurpose = "S";
lblHeader1.Text = "Sale Invoices No." + dtsale.Rows[0]["Sale_Invoice_No"].ToString();
}
if (functionalstatus == "O")
{
purpose = "O";
chkstockpurpose = "O";
lblHeader1.Text = "Order No." + dtsale.Rows[0]["Sale_Invoice_No"].ToString();
}
if (functionalstatus == "Q")
{
purpose = "Q";
chkstockpurpose = "Q";
lblHeader1.Text = "Quote No." + dtsale.Rows[0]["Sale_Invoice_No"].ToString();
}
// lblDate.Text = dtsale.Rows[0]["Invoice_Date"].ToString();
lblcurrentdate.Text = dtsale.Rows[0]["Invoice_Date"].ToString();
DateTime editdate = DateTime.Parse(lblcurrentdate.Text);
lblHeader3.Text = string.Format("{0:f}", editdate);
// lblHeader3.Text = string.Format("{0:dd/MM/yyyy}",editdate);
}
}
private void GetSaleDetails()
{
dtItems.Rows.Clear();
dtItemForDB.Rows.Clear();
DataTable dtsale = new DataTable();
dtsale = ERPManagement.GetInstance.GetSaleDetails(SaleId);
if (dtsale.Rows.Count > 0)
{
for (int i = 0; i < dtsale.Rows.Count; i++)
{
DataRow row = dtItems.NewRow();
DataRow row2 = dtItemForDB.NewRow();
if (dtsale.Rows[i]["Barcode"].ToString() != "")
{
row[0] = dtsale.Rows[i]["Barcode"].ToString();
row2[0] = dtsale.Rows[i]["Barcode"].ToString();
}
if (dtsale.Rows[i]["Item_Name"].ToString() != "")
{
row[1] = dtsale.Rows[i]["Item_Name"].ToString();
row2[1] = dtsale.Rows[i]["Item_ID"].ToString();
}
if (dtsale.Rows[i]["Item_Quantity"].ToString() != "")
{
row[2] = int.Parse(dtsale.Rows[i]["Item_Quantity"].ToString());
row2[2] = int.Parse(dtsale.Rows[i]["Item_Quantity"].ToString());
}
if (dtsale.Rows[i]["Discount_Percent"].ToString() != "")
{
row[3] = float.Parse(dtsale.Rows[i]["Discount_Percent"].ToString());
row2[3] = float.Parse(dtsale.Rows[i]["Discount_Percent"].ToString());
}
if (dtsale.Rows[i]["Is_Taxable"].ToString() == "True")
{
row[4] = true;
row[8] = float.Parse(dtsale.Rows[i]["Tax_Percent"].ToString());
row2[4] = true;
row2[8] = float.Parse(dtsale.Rows[i]["Tax_Percent"].ToString());
}
else
{
row[4] = false;
row[8] = i;
row2[4] = false;
row2[8] = i;
}
if (dtsale.Rows[i]["Item_Price"].ToString() != "")
{
row[5] = float.Parse(dtsale.Rows[i]["Item_Price"].ToString());
row2[5] = float.Parse(dtsale.Rows[i]["Item_Price"].ToString());
}
if (dtsale.Rows[i]["Extended_Price"].ToString() != "")
{
row[6] = float.Parse(dtsale.Rows[i]["Extended_Price"].ToString()).ToString("f");
row2[6] = float.Parse(dtsale.Rows[i]["Extended_Price"].ToString()).ToString("f");
}
if (dtsale.Rows[i]["Item_Unit_Price"].ToString() != "")
{
row[7] = float.Parse(dtsale.Rows[i]["Item_Unit_Price"].ToString());
row2[7] = float.Parse(dtsale.Rows[i]["Item_Unit_Price"].ToString());
}
if (dtsale.Rows[i]["Discount_Price"].ToString() != "")
{
row[9] = float.Parse(dtsale.Rows[i]["Discount_Price"].ToString()).ToString("f");
row2[9] = float.Parse(dtsale.Rows[i]["Discount_Price"].ToString()).ToString("f");
}
if (dtsale.Rows[i]["Extended_Price"].ToString() != "")
{
row[10] = float.Parse(dtsale.Rows[i]["Extended_Price"].ToString()).ToString("f");
row2[10] = float.Parse(dtsale.Rows[i]["Extended_Price"].ToString()).ToString("f");
}
if (dtsale.Rows[i]["Needs_Serial"].ToString() != "")
{
row[12] = bool.Parse(dtsale.Rows[i]["Needs_Serial"].ToString());
}
row[11] = 0;
dtItems.Rows.Add(row);
dtItemForDB.Rows.Add(row2);
GridViewItems.DataSource = AutoNumberedTable(dtItems);
CalculateFooterData();
//call image for serial
GetIsserialImage();
BlockItemColumn();
GridViewItems.Rows[0].Selected = false;
}
}
else
{
dtItemForDB.Clear();
dtItems.Rows.Clear();
GridViewItems.DataSource = AutoNumberedTable(dtItems);
}
}
private void GetSaleCustomer()
{
DataTable dtsale = new DataTable();
dtsale = ERPManagement.GetInstance.GetSaleCustomer(SaleId);
if (dtsale.Rows.Count > 0)
{
Cust_ID = int.Parse(dtsale.Rows[0]["Customer_ID"].ToString());
if (dtsale.Rows[0]["Img_Photo"].ToString() != "")
{
byte[] bt = (byte[])dtsale.Rows[0]["Img_Photo"];
MemoryStream ms = new MemoryStream(bt);
pbCustomerImage.Image = Image.FromStream(ms);
}
else
{
pbCustomerImage.Image = POS.Properties.Resources._user_icon;
}
lblCustomerName.Text = dtsale.Rows[0]["Customer_Name"].ToString();
//lblCustlevel.Text = dtsale.Rows[0]["Loyalty_Card_No"].ToString();
lblCustIdNo.Text = dtsale.Rows[0]["Loyalty_Card_No"].ToString();
//lblCustAddress.Text = dtsale.Rows[0]["Address"].ToString();
lblLastVisit.Text = "Last Visit : " + dtsale.Rows[0]["Last_Visit_Date"].ToString();
lblTotalVisits.Text = "Total Visit : " + dtsale.Rows[0]["Total_Visit"].ToString();
lblTotalSales.Text = "Total Sale : " + dtsale.Rows[0]["Total_Sale"].ToString();
lblPhone.Text = "Phone : " + dtsale.Rows[0]["Mobile_No"].ToString();
}
}
#endregion
private void btnTasks_Click(object sender, EventArgs e)
{
}
private void btnF1Item_MouseLeave()
{
try
{
if (pbLastAccess != null)
{
switch (pbLastAccess.Name)
{
case "btnF1Item": cmItems.Close(); break;
case "btnF2Customer": cmCustomer.Close(); break;
case "btnF3Transaction": cmTransactionMenu.Close(); break;
case "btnF4Tasks": cmTaskMenuOptions.Close(); break;
case "btnF5Tools": cmToolsMenuOption.Close(); break;
case "btnF6Return": cmReturnMenu.Close(); break;
}
}
}
catch { }
}
#region Customer Operation
//private void linkPurchaseHistory_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
//{
// //frmViewSale obj = new frmViewSale("C");
// //obj.ShowDialog();
// Point p = GridViewItems.Location;
// p = new Point(GridViewItems.Location.X + this.Location.X, p.Y + 120);
// frmViewSale obj = new frmViewSale("C");
// obj.StartPosition = FormStartPosition.Manual;
// obj.Location = btnF11Total.Location; //Cursor.Position;
// obj.Location = new Point(p.X, p.Y);
// obj.ShowDialog();
// SaleId = frmViewSale.saleid;
// //set saleid to maxsaleid for complee transaction bcoz maxsaleid pass to paymentsell page
// maxsaleid = SaleId.ToString();
// if (SaleId != 0)
// {
// GetSaleData();
// GetSaleDetails();
// GetSaleCustomer();
// }
//}
private void linkClearCustomer_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (MessageBox.Show("Do you want to delete ?", "kenCloud", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int ModifiedBy = 10;
ERPManagement.GetInstance.DeleteCustomer(Cust_ID, ModifiedBy);
MessageBox.Show("Data Delete Successfully", "kenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
GetCustomer();
Cust_ID = 0;
}
}
private void linkCustomerDetails_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
EditCustomerDetails(Cust_ID);
}
private void EditCustomerDetails(int Cust_ID)
{
frmCustomer customer = new frmCustomer();
customer.StartPosition = FormStartPosition.Manual;
customer.Location = new Point(this.Width + this.Location.X - 333, 7);
Control[] ID = customer.Controls.Find("HdnField", true);
//int Customer_ID = Cust_ID;
//List<POS_Customer> Customers = new List<POS_Customer>();
//Customers = ERPManagement.GetInstance.SelectCustomers();
//var CustomerDet = from cust in Customers
// where cust.Customer_ID == Customer_ID
// select cust;
//if (CustomerDet.Count() > 0)
//{
// ID[0].Text = CustomerDet.ToList()[0].Customer_ID.ToString();
//}
ID[0].Text = Cust_ID.ToString();
customer.ShowDialog();
}
#endregion Customer Operation
private void messageToolStripMenuItem_Click(object sender, EventArgs e)
{
d_Message obj = new d_Message();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
}
#region CODE FOR CUSTOMER SEARCH
// =====================CODE FOR CUSTOMER SEARCH BY NAME,CARNO,PHONE NO.=================
public void CustomerButtonDisable()
{
btnPurchaseHistory.Enabled = false;
btnClearHistory.Enabled = false;
btnCustomerDetails.Enabled = false;
btnAddShipping.Enabled = false;
btnSelectAddress.Enabled = false;
btnClearAddress.Enabled = false;
}
public void CustomerButtonEnable()
{
btnPurchaseHistory.Enabled = true;
btnClearHistory.Enabled = true;
btnCustomerDetails.Enabled = true;
btnAddShipping.Enabled = true;
btnSelectAddress.Enabled = true;
btnClearAddress.Enabled = true;
}
private void pbCustomer_Click(object sender, EventArgs e)
{
if (txtCustomerSearch.Text == "")
{
//MessageBox.Show("Please enter in search field !", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
GetCustomer();
}
else
{
GetCustomerBySearch();
}
}
private void linkClearCustomer_LinkClicked(object sender, EventArgs e)
{
ClearCustomer();
}
private void linkCustomerDetails_LinkClicked(object sender, EventArgs e)
{
EditCustomerDetails();
}
private void linkPurchaseHistory_LinkClicked(object sender, EventArgs e)
{
frmViewSale obj = new frmViewSale("C");
// if ((Cust_ID > 0) || (dgvCustSearch.SelectedRows.Count > 0))
if (Cust_ID > 0)
{
Point p = GridViewItems.Location;
p = new Point(GridViewItems.Location.X + this.Location.X + 7, p.Y + 126);
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
obj.Location = new Point(p.X, p.Y);
obj.ShowDialog();
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
SaleId = obj.saleid;
//set saleid to maxsaleid for complee transaction bcoz maxsaleid pass to paymentsell page
maxsaleid = SaleId.ToString();
if (SaleId != 0)
{
GetSaleData();
GetSaleDetails();
GetSaleCustomer();
//DisableControl();
}
else
{
EnableControl();
}
}
private void btnNewCustomer_Click(object sender, EventArgs e)
{
//Point p = tabDisplay.Location;
//p = new Point(p.X + this.Location.X + 5, this.Location.Y + p.Y + 25);
//frmPopUpCustomer customer = new frmPopUpCustomer();
//customer.StartPosition = FormStartPosition.Manual;
//customer.Location = new Point(p.X, p.Y);
//customer.ShowDialog();
//customer.Close();
frmCustomer obj = new frmCustomer();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = new Point(this.Width + this.Location.X - 333, 7);
obj.ShowDialog();
obj.Close();
GetCustomer();
}
private void btnDeleteCustomer_Click(object sender, EventArgs e)
{
if (dgvCustSearch.Rows.Count > 0)
{
// if (dgvCustSearch.SelectedRows.Count > 0)
if (Cust_ID > 0)
{
DialogResult dr = MessageBox.Show("Are you sure want to delete selected Customer.", "KenCloud", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr.ToString() == "OK")
{
foreach (DataGridViewRow row in dgvCustSearch.Rows)
{
if (row.Selected == true)
{
// row is selected
dgvCustSearch.Columns["customerid"].Visible = false;
customerid = int.Parse(row.Cells["customerid"].Value.ToString());
ERPManagement.GetInstance.DeleteCustomer(customerid, 1);
GetCustomer();
}
else { }
}
}
}
else
{
MessageBox.Show("Please select a Customer for Delete!", "KenCloud", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
}
}
}
private void btnConvertSTO_Click(object sender, EventArgs e)
{
if (GridViewItems.Rows.Count > 0)
{
if (purpose.ToLower() != "s" && purpose.ToLower() != "ss")
{
Point p = btnConvertSTO.Location;
if (purpose.ToLower() == "q" || purpose.ToLower() == "qs")
{
tsmOrder.Visible = true;
p = new Point(p.X + this.Location.X, this.Location.Y + p.Y - 50);
}
else
{
tsmOrder.Visible = false;
p = new Point(p.X + this.Location.X, this.Location.Y + p.Y - 28);
}
cmConvert.Show(this, this.PointToClient(p));
}
}
}
private void tsmSale_Click(object sender, EventArgs e)
{
try
{
purpose = "S";
chkstockpurpose = "S";
if (GridViewItems.Rows.Count > 0)
{
//if ((Cust_ID > 0) || (dgvCustSearch.SelectedRows.Count > 0))
if (Cust_ID > 0)
{
//check serial no entry or not
if (purpose.ToLower() == "s" || purpose.ToLower() == "ss")
{
if (CheckSerialno() == false)
{
purpose = "O";
return;
}
}
//------------------
if (SaleId > 0)
{
UpdateData();
}
else
{
SaveData();
}
//SaveData();
if (purpose.ToLower() == "s" || purpose.ToLower() == "ss")
{
frmPaymentSell obj = new frmPaymentSell(this);
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
// obj.Location = new Point(obj.Location.X + this.Location.X + 100, 130);
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
if (obj.PayStatus == "P")
{
ResetForm();
//call auto invoiceno
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
//GetCustomer();
tabDisplay.TabIndex = 0;
}
else if (obj.PayStatus == "C")
{
}
}
else if (purpose == "F")
{
}
else
{
ResetForm();
}
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
else
{
MessageBox.Show("No Item for sale!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 1;
}
}
catch (Exception ex)
{ }
}
private void tsmOrder_Click(object sender, EventArgs e)
{
try
{
if (GridViewItems.Rows.Count > 0)
{
//if ((Cust_ID > 0) || (dgvCustSearch.SelectedRows.Count > 0))
if (Cust_ID > 0)
{
purpose = "O";
if (SaleId > 0)
{
UpdateData();
}
else
{
SaveData();
}
MessageBox.Show("Data Order Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
//SaveData();
if (purpose.ToLower() == "s" || purpose.ToLower() == "ss")
{
frmPaymentSell obj = new frmPaymentSell(this);
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
// obj.Location = new Point(obj.Location.X + this.Location.X + 100, 130);
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
if (obj.PayStatus == "P")
{
ResetForm();
//call auto invoiceno
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
//GetCustomer();
tabDisplay.TabIndex = 0;
}
else if (obj.PayStatus == "C")
{
}
}
else if (purpose == "F")
{
}
else
{
ResetForm();
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
tabDisplay.TabIndex = 0;
}
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
else
{
MessageBox.Show("No Item for sale!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 1;
}
}
catch (Exception ex)
{ }
}
private void tsmDelete_Click(object sender, EventArgs e)
{
RemoveGridLineItem();
}
private void tsmEdit_Click(object sender, EventArgs e)
{
EditGridLineItem();
}
private void dgvCustSearch_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.RowIndex >= 0)
{
if (dgvCustSearch.Columns[e.ColumnIndex].Name.ToString() == "custimg")
{
try
{
customerid = int.Parse(dgvCustSearch.Rows[e.RowIndex].Cells["customerid"].Value.ToString());
List<POS_PointOfSale> Customers = new List<POS_PointOfSale>();
Customers = ERPManagement.GetInstance.GetCustomerSearch();
var Customer = from Cust in Customers
where Cust.Customer_ID == customerid
select Cust;
if (Customer.Count() > 0)
{
DataGridViewCell cell = this.dgvCustSearch.Rows[e.RowIndex].Cells[e.ColumnIndex];
cell.ToolTipText = Customer.ToList()[0].CustDetails;
}
}
catch
{ }
}
}
}
private void cmCustomer_Opening(object sender, CancelEventArgs e)
{
}
private void TxtBarcode_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
if (char.IsDigit(e.KeyChar) == false && (Keys)e.KeyChar != Keys.Back)
{
e.Handled = true;
//MessageBox.Show("Special characters are not allowed.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
TxtBarcode.Focus();
return;
}
}
catch (Exception ex)
{
}
}
private void combosearch_SelectedIndexChanged(object sender, EventArgs e)
{
if (combosearch.SelectedIndex == 0)
{
txtSearch.Enabled = true;
txtSearch.Text = "";
}
else if (combosearch.SelectedIndex == 1)
{
txtSearch.Enabled = true;
txtSearch.Text = "";
}
else
{
txtSearch.Enabled = true;
}
}
private void cmbCustomer_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbCustomer.SelectedIndex == 0)
{
txtCustomerSearch.Enabled = true;
txtCustomerSearch.Text = "";
txtCustomerSearch.Focus();
}
else if (cmbCustomer.SelectedIndex == 1)
{
txtCustomerSearch.Enabled = true;
txtCustomerSearch.Text = "";
txtCustomerSearch.Focus();
}
else if (cmbCustomer.SelectedIndex == 2)
{
txtCustomerSearch.Enabled = true;
txtCustomerSearch.Text = "";
txtCustomerSearch.Focus();
}
else
{
txtCustomerSearch.Enabled = true;
txtCustomerSearch.Focus();
}
}
private void btnAddShipping_Click(object sender, EventArgs e)
{
if (dgvCustSearch.Rows.Count > 0)
{
if (Cust_ID > 0 || lblCustomerName.Text.Trim() != "N/A")
{
if (LblAddress1.Text.Trim() != "Address1 : N/A")
{
frmShippingDetails obj = new frmShippingDetails();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
GetCustomerInformation();
// frmShippingDetails objship = new frmShippingDetails();
//if click back button for cancel
if (frmShippingDetails.status == "SC")
{
popupimgpurpose = "S";
}
else
{
//initialize status for popup
popupimgpurpose = "SS";//for ship image popup
TotalShippingCharge = frmShippingDetails.totalshipamount;
decimal shipchag = TotalNetAmount + TotalShippingCharge;
TxtNetAmount = shipchag.ToString("F");
lblGrandTotal.Text = shipchag.ToString("F");
}
}
else
{
DialogResult dr = MessageBox.Show("Please enter Customer Shipping Address Details!", "KenCloud", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
if (dr.ToString() == "OK")
{
EditCustomerDetails(Cust_ID);
frmCustomer obj = new frmCustomer();
obj.Txtaddress1.Focus();
}
}
GetCustomerInformation();
}
else
{
MessageBox.Show("Please select a Customer for Shipping!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
}
private void btnSelectAddress_Click(object sender, EventArgs e)
{
if (Cust_ID > 0 || lblCustomerName.Text.Trim() != "N/A")
{
EditCustomerDetails(Cust_ID);
GetCustomer();
GetCustomerInformation();
}
else
{
MessageBox.Show("Please select a Customer !", "KenCloud", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
}
}
private void pnlShippingDetails_Click(object sender, EventArgs e)
{
if (Cust_ID > 0 || lblCustomerName.Text.Trim() != "N/A")
{
Point p = pnlShippingDetails.Location;
p = new Point(p.X + this.Location.X + 0, this.Location.Y + p.Y + 0);
frmShippingDetailsexpand ship = new frmShippingDetailsexpand();
ship.StartPosition = FormStartPosition.Manual;
ship.Location = new Point(p.X, p.Y);
ship.ShowDialog();
GetCustomerInformation();
//if click back button for cancel
if (frmShippingDetails.status == "SC")
{
popupimgpurpose = "S";
TotalShippingCharge = frmShippingDetails.totalshipamount;
decimal shipchag = TotalNetAmount + TotalShippingCharge;
TxtNetAmount = shipchag.ToString("F");
lblGrandTotal.Text = shipchag.ToString("F");
}
else
{
//initialize status for popup
popupimgpurpose = "SS";//for ship image popup
TotalShippingCharge = frmShippingDetails.totalshipamount;
decimal shipchag = TotalNetAmount + TotalShippingCharge;
TxtNetAmount = shipchag.ToString("F");
lblGrandTotal.Text = shipchag.ToString("F");
}
}
else
{
MessageBox.Show("Please select a Customer for Shipping!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
private void btnTillCount_Click(object sender, EventArgs e)
{
frmTillCount obj = new frmTillCount();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
}
public void clearShippdetails()
{
LblAddress1.Text = "Address1 : N/A";
LblAddress2.Text = "Address2 : N/A";
LblCity.Text = "City : N/A";
LblState.Text = "State : N/A";
LblCountry.Text = "Country : N/A";
LblZip.Text = "Pin : N/A";
LblShipPhn.Text = "Phone : N/A";
LblShipMail.Text = "E-Mail : N/A";
lblShippingCharge.Text = "Shipping Charge :N/A";
//GetCustomer();
}
private void btnClearAddress_Click(object sender, EventArgs e)
{
if (Cust_ID > 0 || lblCustomerName.Text.Trim() != "N/A")
{
if (LblAddress1.Text.Trim() != "Address1 : N/A")
{
DialogResult dr = MessageBox.Show("Are you sure to delete selected Customer Shipping Details.", "KenCloud", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr.ToString() == "OK")
{
ERPManagement.GetInstance.ClearShippingAddress(Cust_ID, 1);
LblAddress1.Text = "Address1 : N/A";
LblAddress2.Text = "Address2 : N/A";
LblCity.Text = "City : N/A";
LblState.Text = "State : N/A";
LblCountry.Text = "Country : N/A";
LblZip.Text = "Pin : N/A";
LblShipPhn.Text = "Phone : N/A";
LblShipMail.Text = "E-Mail : N/A";
lblShippingCharge.Text = "Shipping Charge :N/A";
//GetCustomer();
}
}
else
{
MessageBox.Show("No records for Delete !", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
//tabDisplay.SelectedIndex = 2;
}
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
private void BarcodeMarker(string barcode)
{
try
{
int availlevel = 0;
int maxlevel = 0;
int reqlevel = 0;
if (TxtBarcode.Text.Trim() != "")
{
List<POS_PointOfSale> listPOS = ERPManagement.GetInstance.GetBarcodeLevel(barcode);
if (listPOS.Count > 0)
{
availlevel = Convert.ToInt16(Convert.ToString(listPOS.ToArray()[0].Available_Stock));
maxlevel = Convert.ToInt16(Convert.ToString(listPOS.ToArray()[0].Maximum_Stock) == "" ? "0" : Convert.ToString(listPOS.ToArray()[0].Maximum_Stock));
reqlevel = Convert.ToInt16(Convert.ToString(listPOS.ToArray()[0].Minimum_Stock));
}
decimal percentage = 0;
if (maxlevel > 0)
{
percentage = ((decimal)reqlevel * 100) / (decimal)maxlevel;
}
else
{
maxlevel = availlevel;
}
int needwidth = (int)((percentage * stockprogressBar.Width) / 100);
pnlmark.Location = new Point(locationX + needwidth, locationY);
stockprogressBar.Maximum = maxlevel;
stockprogressBar.Minimum = 0;
if (availlevel >= maxlevel)
{
stockprogressBar.Value = maxlevel;
}
else
{
stockprogressBar.Value = availlevel;
}
pnlmark.Visible = true;
}
else
{
pnlmark.Visible = false;
}
}
catch (Exception)
{
}
}
private void quoteToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
EnableControl();
ResetForm();
Point p = GridViewItems.Location;
p = new Point(GridViewItems.Location.X + this.Location.X + 7, p.Y + 126);
frmViewSale obj = new frmViewSale("Q");
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
obj.Location = new Point(p.X, p.Y);
obj.ShowDialog();
SaleId = obj.saleid;
//set saleid to maxsaleid for complee transaction bcoz maxsaleid pass to paymentsell page
maxsaleid = SaleId.ToString();
if (SaleId != 0)
{
GetSaleData();
GetSaleDetails();
GetSaleCustomer();
//false gridview line focus
GridViewItems.Rows[0].Selected = false;
stockprogressBar.Value = 0;
}
else
{
ResetForm();
GetAutoInvoiceNo();
}
}
catch
{
}
}
private void btnOrdersbottom_Click(object sender, EventArgs e)
{
Transaction("O");
}
private void tabDisplay_Click(object sender, EventArgs e)
{
if (tabDisplay.SelectedTab.Text == "Products")
{
if (z == 1)
{
GetProduct();
//assign default value
z = 0;
}
//else
//{
// i = 0;
//}
}
}
private void dgvProdSearch_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
//===========================================================
#endregion
}
public class POSCustomer
{
public int Customer_ID
{
set;
get;
}
public string Customer_Name
{
set;
get;
}
public string CustomerPhone
{
set;
get;
}
public Image Imagevalue
{
get;
set;
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Swash.Objects;
using Swash.BusinessLayer;
using System.IO;
using System.Text.RegularExpressions;
using POS.Properties;
using System.Drawing.Drawing2D;
using System.Threading;
namespace POS
{
public partial class FrmMain : Form
{
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x84:
base.WndProc(ref m);
if ((int)m.Result == 0x1) m.Result = (IntPtr)0x2;
return;
}
base.WndProc(ref m);
}
public FrmMain()
{
InitializeComponent();
imgGridBack = POS.Properties.Resources.grid_view_back;
}
#region Variables
Image imgGridBack = null;
// public static string ShipBack;
public string popupimgpurpose = "S";//for popup image
public string chkstockpurpose = "S";//for stock check
public string purpose = "S";//for transaction status
public string TxtTotalNoOfItems = "";
public string TxtTotalAmount = "";
public string TxtTotalTaxAmount = "";
public string TxtTotalDiscountAmount = "";
public string TxtTotalAdjustAmount = "";
public string TxtNetAmount = "";
public string AutoinvoiceNo = "";
public decimal TotalShippingCharge = 0;
public static bool ShipStatus = false;
// public string ShippingAmount = "";
//insert variable
string TxtInvoiceNumber;
string TxtNet;
public string maxsaleid = string.Empty;
public static int customeridshipping = 0;
//update variable
public string EditInvoiceNumber;
public int SaleId = 0;
//bool value for datagrid search check
private bool loading = true;
//****************************//
delegate void delGetCustomerInformation();
private System.Windows.Forms.Timer _Timer = new System.Windows.Forms.Timer();
private System.Windows.Forms.Timer _Timerstock = new System.Windows.Forms.Timer();
public static int Cust_ID;
int index; //Keps the gridview row ID
public DataTable dtItems = new DataTable();
public DataTable dtItemForDB = new DataTable();
DataTable dtBarcode = new DataTable();
public DataTable dtserial = new DataTable();
//--------tooltip declaration for showing in shipping details section label---------------------------
System.Windows.Forms.ToolTip ToolTip11 = new System.Windows.Forms.ToolTip();
System.Windows.Forms.ToolTip ToolTip22 = new System.Windows.Forms.ToolTip();
//------------------------------
decimal tax;
public int Choice;
int Item_ID;
string ItemName, Quantity, Unitprice, chktaxable, ItemPrice, Taxpercentage, Extendedprice, DiscountPercentage, Discountprice, Netprice;
int stockQuantity;
int TotalItems;
public decimal TotalAmount, TotalDiscountAmount, TotalTaxableAmount, TotalTaxAmount, TotalAdjustAmount, TotalNetAmount, TotalNetwithship;
bool EditQuantity = false;
bool _EditGrid = false;
bool _rowclickGrid = false;
string Barcode;
int Itemid = 0;
int Saleqty, Disqty, Byeqty, Getqty;
int FlagScheme, SchemeID = 0;
string checkscheme = "";
string Schemebarcode = "";
bool IsScheme = false;
bool iscountqty = false;
int customerid;
int rowindex;
bool isEdit = false;
bool IsBarcode = false;
bool isItemGridClick = false;
bool isInvoice = false;
string btnmode = "";
public static int x = 0;
public static int y = 0;
int locationX = 0;//pnl progress marking variable
int locationY = 0;//pnl progress marking variable
int i = 0;
int j, z = 0;
PictureBox pbLastAccess = null;
string msgstock = "";
//for user login id
int userid = 0;
//for check serial no of a item
bool Isserial;
//for popupserialno page
public static int QtyForSerialno;
public static string BarcodeForSerialno;
public static int ItemQtyForSerialno;
#endregion
private void FrmMain_Load(object sender, EventArgs e)
{
//location choosen to set the stockprogress bar and mark a red pont
locationX = pnlmark.Location.X;
locationY = pnlmark.Location.Y;
//current date
lblcurrentdate.Text = DateTime.Now.ToString("M/dd/yyyy hh:mm:ss tt");
//for clock
_Timer.Interval = 1000;
_Timer.Tick += new EventHandler(_Timer_Tick);
_Timer.Start();
//===================//
//for update stock in datagridview
_Timerstock.Interval = 2 * 60 * 1000;
_Timerstock.Tick += new EventHandler(_Timerstock_Tick);
_Timerstock.Start();
//===================//
GetProduct();
GetCustomer();
//currentdate
CurrentDate();
//header date
string headerdate = string.Format("{0:f}", DateTime.Now);
lblHeader3.Text = headerdate;
CreateDataTable();
//get autoinvoice no
GetAutoInvoiceNo();
//lblHeader1.Text = "Sale Invoices No." + AutoinvoiceNo;
//wish message
if (DateTime.Now.Hour < 12)
{
lblWishTime.Text = "Good Morning";
}
else if (DateTime.Now.Hour < 17)
{
lblWishTime.Text = "Good Afternoon";
}
else
{
lblWishTime.Text = "Good Evening";
}
//get totalsale
GetTotalSale();
//onhold
GetOnHoldSale();
TxtBarcode.Focus();
tabDisplay.SelectedIndex = 0;
//visible false item column
BlockItemColumn();
//user control
userControl11.Click1 += new UC_virtual_keyboard.UserControl1.sender1(userControl11_Click1);
x = this.Location.X; y = this.Location.Y;
//get sale userid
//SaleId = 1;
userid = int.Parse(frmLogin.userid.ToString());
//assign 0 index value in product combobox
combosearch.SelectedIndex = 0;
cmbCustomer.SelectedIndex = 0;
//set focus false in search grid
dgvProdSearch.Rows[0].Selected = false;
// dgvCustSearch.Rows[0].Selected = false;
}
private void userControl11_Click1(string s)
{
if (j == 1)
TxtBarcode.Text = s;
else if (j == 2)
TxtBarcode.Text = s;
else if (j == 3)
TxtBarcode.Text = s;
}
#region Defined By Salman
private void GetContextMenu()
{
if (GridViewItems.Rows.Count > 0)
{
GridViewItems.ContextMenuStrip = cmOperation;
}
}
//click timer for time
private void _Timer_Tick(object sender, EventArgs e)
{
this.lblTime.Text = DateTime.Now.ToString("hh:mm:ss tt");
}
//update stock after 2 mnts in datagridview
private void _Timerstock_Tick(object sender, EventArgs e)
{
//GetProduct();
//GetCustomer();
}
// attach the wire handler after the form is loaded
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
loading = false;
//if (this.GridViewItems.SelectedCells.Count > 0)
//{
// for (int i = 0; i < this.GridViewItems.SelectedCells.Count; i++)
// this.GridViewItems.SelectedCells[i].Selected = false;
//}
}
private DataTable EmptyGrid()
{
DataTable emptgrd = new DataTable();
GridViewItems.AutoGenerateColumns = false;
DataGridViewTextBoxColumn Barcode = new DataGridViewTextBoxColumn();
Barcode.Name = "barcode";
Barcode.HeaderText = "Barcode";
GridViewItems.Columns.Add(Barcode);
DataGridViewTextBoxColumn Itemname = new DataGridViewTextBoxColumn();
Itemname.HeaderText = "Item Name";
GridViewItems.Columns.Add(Itemname);
DataGridViewTextBoxColumn Quantity = new DataGridViewTextBoxColumn();
Quantity.HeaderText = "Quantity";
GridViewItems.Columns.Add(Quantity);
DataGridViewTextBoxColumn Unitprice = new DataGridViewTextBoxColumn();
Unitprice.HeaderText = "Unit Price";
GridViewItems.Columns.Add(Unitprice);
DataGridViewTextBoxColumn price = new DataGridViewTextBoxColumn();
price.HeaderText = "price";
GridViewItems.Columns.Add(price);
DataGridViewTextBoxColumn Taxable = new DataGridViewTextBoxColumn();
Taxable.HeaderText = "Taxable";
GridViewItems.Columns.Add(Taxable);
DataGridViewTextBoxColumn tax = new DataGridViewTextBoxColumn();
tax.HeaderText = "Tax";
GridViewItems.Columns.Add(tax);
DataGridViewTextBoxColumn Extendedprice = new DataGridViewTextBoxColumn();
Extendedprice.HeaderText = "Extended Price";
GridViewItems.Columns.Add(Extendedprice);
DataGridViewTextBoxColumn discountprice = new DataGridViewTextBoxColumn();
discountprice.HeaderText = "Discount Price";
GridViewItems.Columns.Add(discountprice);
DataGridViewTextBoxColumn netprice = new DataGridViewTextBoxColumn();
netprice.HeaderText = "Net Price";
GridViewItems.Columns.Add(netprice);
return emptgrd;
}
private DataTable AutoNumberedTable(DataTable SourceTable)
{
DataTable ResultTable = new DataTable();
DataColumn AutoNumberColumn = new DataColumn();
AutoNumberColumn.ColumnName = "SL.No.";
AutoNumberColumn.DataType = typeof(int);
AutoNumberColumn.AutoIncrement = true;
AutoNumberColumn.AutoIncrementSeed = 1;
AutoNumberColumn.AutoIncrementStep = 1;
ResultTable.Columns.Add(AutoNumberColumn);
ResultTable.Merge(SourceTable);
return ResultTable;
}
#region Procedure
//create a datatable for intialize data from popup and if not any record then create new one
private void SerialDatatable()
{
if (frmPoupSerialNo.dtSerialNo.Rows.Count > 0)
{
dtserial = frmPoupSerialNo.dtSerialNo;
}
else
{
if (dtserial.Columns.Count == 0)
{
dtserial.Columns.Add("BarCode", typeof(string));
dtserial.Columns.Add("SerialNo", typeof(string));
}
}
}
private void CurrentDate()
{
string currentdate = string.Format("{0:ddd, MMM d, yyyy}", DateTime.Now);
lblDate.Text = currentdate;
}
private void GetAutoInvoiceNo()
{
try
{
lblHeader1.Text = "";
List<POS_PointOfSale> objinvoice = new List<POS_PointOfSale>();
objinvoice = ERPManagement.GetInstance.AutoInvoiceNo();
AutoinvoiceNo = objinvoice.ToList()[0].ReturnInvoiceNo;
lblHeader1.Text = "Sale Invoices No." + AutoinvoiceNo;
}
catch
{
}
}
private DataTable EmptyproductsearchGrid()
{
DataTable emptgrd = new DataTable();
DataColumn ItemName = new DataColumn();
DataColumn ItemQuantity = new DataColumn();
ItemName.ColumnName = "Item Name";
ItemQuantity.ColumnName = "Item Quantity";
emptgrd.Columns.Add(ItemName);
emptgrd.Columns.Add(ItemQuantity);
return emptgrd;
}
private DataTable EmptycustomersearchGrid()
{
DataTable emptcustgrd = new DataTable();
DataColumn customername = new DataColumn();
DataColumn phone = new DataColumn();
customername.ColumnName = "Customer Name";
phone.ColumnName = "Phone";
emptcustgrd.Columns.Add(customername);
emptcustgrd.Columns.Add(phone);
return emptcustgrd;
}
private void SetProdSearchGrid()
{
int totalWidth = dgvProdSearch.Width;
dgvProdSearch.Columns["img"].Width = 30;
dgvProdSearch.Columns["ItemQuantity"].Width = 38;
dgvProdSearch.Columns["ItemName"].Width = 158;
dgvProdSearch.Columns["Price"].Width = 52;
}
private void GetProduct()
{
try
{
dgvProdSearch.Columns.Clear();
var product = from prod in ERPManagement.GetInstance.GetProductSearch()
select new
{
ItemId = prod.ItemID,
Barcode = prod.ItemBarcode,
ItemQuantity = prod.ItemQuantity,
ItemName = prod.ItemName,
Price = prod.ItemPrice.ToString("f"),
Isserial = prod.IsSerial,
};
if (product.ToList().Count > 0)
{
LblNoRecord.Visible = false;
dgvProdSearch.DataSource = product.ToList();
DataGridViewImageColumn imgprog = new DataGridViewImageColumn();
imgprog.Name = "img";
dgvProdSearch.Columns.Add(imgprog);
dgvProdSearch.Columns["ItemId"].Visible = false;
dgvProdSearch.Columns["Barcode"].Visible = false;
dgvProdSearch.Columns["Isserial"].Visible = false;
dgvProdSearch.Columns["ItemName"].HeaderText = "Item Name";
dgvProdSearch.Columns["Price"].HeaderText = "Price";
dgvProdSearch.Columns["ItemQuantity"].HeaderText = "";
dgvProdSearch.Columns["img"].HeaderText = "";
this.dgvProdSearch.Columns["Price"].DefaultCellStyle.Format = "f";
SetProdSearchGrid();
SetdgvProdSearchProgressImage();
dgvProdSearch.Columns["img"].DisplayIndex = 2;
dgvProdSearch.Columns["ItemQuantity"].DisplayIndex = 3;
dgvProdSearch.Rows[0].Selected = false;
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
LblNoRecord.Visible = true;
// dgvProdSearch.DataSource = EmptyproductsearchGrid();
}
}
catch { }
}
private void GetVariationProduct(int itemid)
{
try
{
var product = from prod in ERPManagement.GetInstance.GetVariationProduct(itemid)
select new
{
ItemId = prod.ItemID,
Barcode = prod.ItemBarcode,
ItemQuantity = prod.ItemQuantity,
ItemName = prod.ItemName,
Price = prod.ItemPrice.ToString("f"),
Isserial = prod.IsSerial,
};
if (product.ToList().Count > 0)
{
//assign z=1 for back to main product and it is work in tadisplay click event
z = 1;
dgvProdSearch.Columns.Clear();
LblNoRecord.Visible = false;
dgvProdSearch.DataSource = product.ToList();
DataGridViewImageColumn imgprog = new DataGridViewImageColumn();
imgprog.Name = "img";
dgvProdSearch.Columns.Add(imgprog);
dgvProdSearch.Columns["ItemId"].Visible = false;
dgvProdSearch.Columns["Barcode"].Visible = false;
dgvProdSearch.Columns["Isserial"].Visible = false;
dgvProdSearch.Columns["ItemName"].HeaderText = "Item Name";
dgvProdSearch.Columns["Price"].HeaderText = "Price";
dgvProdSearch.Columns["ItemQuantity"].HeaderText = "";
dgvProdSearch.Columns["img"].HeaderText = "";
this.dgvProdSearch.Columns["Price"].DefaultCellStyle.Format = "f";
SetProdSearchGrid();
SetdgvProdSearchProgressImage();
dgvProdSearch.Columns["img"].DisplayIndex = 2;
dgvProdSearch.Columns["ItemQuantity"].DisplayIndex = 3;
dgvProdSearch.Rows[0].Selected = false;
}
else
{
z = 0;
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
// LblNoRecord.Visible = true;
// dgvProdSearch.DataSource = EmptyproductsearchGrid();
}
}
catch { }
}
//set image for item
private void SetdgvProdSearchProgressImage()
{
tabDisplay.SelectedIndex = 1;
int minstock = 0;
//if (dgvProdSearch.Rows.Count > 0)
//{
// string barcode = dgvProdSearch.Rows[i].Cells["Barcode"].Value.ToString();
// List<POS_PointOfSale> listPOS = ERPManagement.GetInstance.GetBarcodeLevel(barcode);
// if (listPOS.Count > 0)
// {
// minstock = Convert.ToInt16(Convert.ToString(listPOS.ToArray()[0].Minimum_Stock) == "" ? "0" : Convert.ToString(listPOS.ToArray()[0].Minimum_Stock));
// }
//}
for (int i = 0; i <= dgvProdSearch.Rows.Count - 1; i++)
{
try
{
Image myImage = null;
decimal per = 0;
int quantity = int.Parse(dgvProdSearch.Rows[i].Cells["ItemQuantity"].Value.ToString());
string barcode = dgvProdSearch.Rows[i].Cells["Barcode"].Value.ToString();
List<POS_PointOfSale> listPOS = ERPManagement.GetInstance.GetBarcodeLevel(barcode);
if (listPOS.Count > 0)
{
minstock = Convert.ToInt16(Convert.ToString(listPOS.ToArray()[0].Minimum_Stock) == "" ? "0" : Convert.ToString(listPOS.ToArray()[0].Minimum_Stock));
per = (quantity / (decimal)minstock) * 100;
}
// decimal per = (quantity * 100) / 100;
if (per == 0)
{
myImage = POS.Properties.Resources.grp0;
}
else if (per <= 10)
{
myImage = POS.Properties.Resources.progress10;
}
else if (per <= 20)
{
myImage = POS.Properties.Resources.progress20;
}
else if (per <= 30)
{
myImage = POS.Properties.Resources.progress30;
}
else if (per <= 40)
{
myImage = POS.Properties.Resources.progress40;
}
else if (per <= 50)
{
myImage = POS.Properties.Resources.progress50;
}
else if (per <= 60)
{
myImage = POS.Properties.Resources.progress60;
}
else if (per <= 70)
{
myImage = POS.Properties.Resources.progress70;
}
else if (per <= 80)
{
myImage = POS.Properties.Resources.progress80;
}
else if (per <= 90)
{
myImage = POS.Properties.Resources.progress90;
}
else if (per < 100)
{
myImage = POS.Properties.Resources.progress90;
}
else if (per >= 100)
{
myImage = POS.Properties.Resources.progress100;
}
dgvProdSearch.Rows[i].Cells["img"].Value = myImage;
}
catch { }
}
}
public void GetCustomer()
{
try
{
dgvCustSearch.Columns.Clear();
var customer = (from cust in ERPManagement.GetInstance.GetCustomerSearch()
select new
{
customerid = cust.Customer_ID,
custimg = GetImageFromByteArrary(cust.CustImage),
customername = cust.Customer_NameLC,
mobileno = cust.CustomerPhone
}).ToList();
if (customer.Count > 0)
{
dgvCustSearch.Width = 270;
lblcustNorecord.Visible = false;
dgvCustSearch.DataSource = customer.ToList();
DisplayCustomerGridFormat();
dgvCustSearch.Rows[0].Selected = false;
//List<POSCustomer> listpos = new List<POSCustomer>();
//for (int i = 0; i < customer.Count; i++)
//{
// POSCustomer objnew = new POSCustomer();
// objnew.Customer_ID = customer[i].customerid;
// objnew.Customer_Name = customer[i].customername;
// objnew.CustomerPhone = customer[i].mobileno;
// objnew.Imagevalue = funImagecroping(customer[i].custimg);
// listpos.Add(objnew);
//}
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
lblcustNorecord.Visible = true;
dgvCustSearch.DataSource = EmptycustomersearchGrid();
}
}
catch
{
}
}
public void GetInvoiceDetails()
{
try
{
//frmViewSale obj = new frmViewSale("I");
//obj.ShowDialog();
isInvoice = true;
ResetForm();
Point p = GridViewItems.Location;
p = new Point(GridViewItems.Location.X + this.Location.X + 7, p.Y + 126);
frmViewSale obj = new frmViewSale("S");
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
obj.Location = new Point(p.X, p.Y);
obj.ShowDialog();
SaleId = obj.saleid;
//set saleid to maxsaleid for complee transaction bcoz maxsaleid pass to paymentsell page
maxsaleid = SaleId.ToString();
if (SaleId != 0)
{
GetSaleData();
GetSaleDetails();
GetSaleCustomer();
DisableControl();
GridViewItems.Rows[0].Selected = false;
stockprogressBar.Value = 0;
}
else
{
ResetForm();
GetAutoInvoiceNo();
EnableControl();
}
}
catch { }
}
//Image funImagecroping(Image img)
//{
// Image icon=new Image();
// using (Graphics gr = Graphics.FromImage(img))
// {
// gr.SmoothingMode = SmoothingMode.HighQuality;
// gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
// gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
// gr.DrawImage(icon, new Rectangle(0, 0, 17, 17));
// //gr.CreateObjRef(typeof
// }
//}
#region Generating a new Image
public Image NewImage(Image image)
{
int width = 30, height = 25;
// Image resizedImage = new Bitmap(image.Width, image.Height);
Image resizedImage = new Bitmap(width, height);
using (Graphics graphics = Graphics.FromImage(resizedImage))
{
graphics.Clear(Color.White);
//graphics.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height), new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
graphics.DrawImage(image, new Rectangle(0, 0, width, height), new Rectangle(0, 0, width, height), GraphicsUnit.Pixel);
}
return resizedImage;
}
#endregion
Image GetImageFromByteArrary(byte[] bt)
{
Image img = POS.Properties.Resources.custimg;
try
{
if (bt.Length > 0 && bt != null)
{
MemoryStream ms = new MemoryStream(bt);
img = Image.FromStream(ms);
//img = NewImage(img);
}
}
catch (Exception) { }
return img;
}
void DisplayCustomerGridFormat()
{
dgvCustSearch.Columns["customerid"].Visible = false;
//DataGridViewImageColumn imgcust = new DataGridViewImageColumn();
//Image image1 = POS.Properties.Resources.custimg;
//imgcust.Image = image1;
//imgcust.Name = "custimg";
//dgvCustSearch.Columns.Add(imgcust);
dgvCustSearch.Columns["custimg"].HeaderText = "";
dgvCustSearch.Columns["custimg"].MinimumWidth = 25;
dgvCustSearch.Columns["custimg"].Width = 25;
dgvCustSearch.Columns["customername"].HeaderText = "Customer Name";
dgvCustSearch.Columns["mobileno"].HeaderText = "Phone";
DataGridViewImageColumn imgedit = new DataGridViewImageColumn();
Image image = POS.Properties.Resources.customer_panel_icon;
imgedit.Image = image;
imgedit.MinimumWidth = 20;
imgedit.Width = 20;
dgvCustSearch.Columns.Add(imgedit);
imgedit.HeaderText = "";
imgedit.Name = "Edit";
this.dgvCustSearch.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
SetCustSearchGrid();
//set position
}
private void SetCustSearchGrid()
{
int totalWidth = dgvCustSearch.Width;
dgvCustSearch.Columns["custimg"].MinimumWidth = 30;
dgvCustSearch.Columns["custimg"].Width = 30;
dgvCustSearch.Columns["customername"].MinimumWidth = 130;
dgvCustSearch.Columns["customername"].Width = 130;
dgvCustSearch.Columns["mobileno"].MinimumWidth = 90;
dgvCustSearch.Columns["mobileno"].Width = 90;
}
public void GetCustomerBySearch()
{
if (cmbCustomer.SelectedIndex == -1)
{
MessageBox.Show(" Select any type Of search!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
cmbCustomer.Focus();
}
else
{
try
{
List<POS_PointOfSale> Customers = new List<POS_PointOfSale>();
Customers = ERPManagement.GetInstance.GetCustomerSearch();
dgvCustSearch.Columns.Clear();
if (cmbCustomer.Text == "By Name")
{
var customer = from cust in Customers
where cust.Customer_Name.ToLower().Contains(txtCustomerSearch.Text.Trim().ToLower())
select new
{
customerid = cust.Customer_ID,
custimg = GetImageFromByteArrary(cust.CustImage),
customername = cust.Customer_NameLC,
mobileno = cust.CustomerPhone
};
if (customer.ToList().Count > 0)
{
tabDisplay.SelectedIndex = 2;
lblcustNorecord.Visible = false;
dgvCustSearch.DataSource = customer.ToList();
DisplayCustomerGridFormat();
}
else
{
lblcustNorecord.Visible = true;
dgvCustSearch.DataSource = EmptycustomersearchGrid();
}
}
else if (cmbCustomer.Text == "By Card No")
{
var customer = from cust in Customers
where cust.Loyalty_Card_No.ToLower().Contains(txtCustomerSearch.Text.Trim().ToLower())
select new
{
customerid = cust.Customer_ID,
custimg = GetImageFromByteArrary(cust.CustImage),
customername = cust.Customer_NameLC,
mobileno = cust.CustomerPhone
};
if (customer.ToList().Count > 0)
{
tabDisplay.SelectedIndex = 2;
lblcustNorecord.Visible = false;
dgvCustSearch.DataSource = customer.ToList();
DisplayCustomerGridFormat();
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
lblcustNorecord.Visible = true;
dgvCustSearch.DataSource = EmptycustomersearchGrid();
}
}
else if (cmbCustomer.Text == "By Phone No")
{
var customer = from cust in Customers
where cust.CustomerPhone.ToLower().StartsWith(txtCustomerSearch.Text.Trim().ToLower())
select new
{
customerid = cust.Customer_ID,
custimg = GetImageFromByteArrary(cust.CustImage),
customername = cust.Customer_NameLC,
mobileno = cust.CustomerPhone
};
if (customer.ToList().Count > 0)
{
tabDisplay.SelectedIndex = 2;
lblcustNorecord.Visible = false;
dgvCustSearch.DataSource = customer.ToList();
DisplayCustomerGridFormat();
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
lblcustNorecord.Visible = true;
dgvCustSearch.DataSource = EmptycustomersearchGrid();
}
}
else if (cmbCustomer.Text == "Select")
{
var customer = from cust in Customers
where cust.CustomerPhone.ToLower().StartsWith(txtCustomerSearch.Text.Trim().ToLower()) ||
cust.Customer_Name.Trim().StartsWith(txtCustomerSearch.Text.Trim().ToLower()) ||
cust.Loyalty_Card_No.Trim().StartsWith(txtCustomerSearch.Text.Trim().ToLower())
select new
{
customerid = cust.Customer_ID,
custimg = GetImageFromByteArrary(cust.CustImage),
customername = cust.Customer_NameLC,
mobileno = cust.CustomerPhone
};
if (customer.ToList().Count > 0)
{
tabDisplay.SelectedIndex = 2;
lblcustNorecord.Visible = false;
dgvCustSearch.DataSource = customer.ToList();
DisplayCustomerGridFormat();
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
lblcustNorecord.Visible = true;
dgvCustSearch.DataSource = EmptycustomersearchGrid();
}
}
}
catch { }
}
}
private void GetTotalSale()
{
try
{
List<POS_PointOfSale> objtotsale = new List<POS_PointOfSale>();
objtotsale = ERPManagement.GetInstance.GetTotalSale();
if (objtotsale.Count > 0)
{
lblSales.Text = objtotsale.ToList()[0].TotalSale.ToString() == null ? "0" : objtotsale.ToList()[0].TotalSale.ToString();
lblReceipts.Text = objtotsale.ToList()[0].TotalSaleAmount.ToString() == null ? "0.00" : objtotsale.ToList()[0].TotalSaleAmount.ToString("f");
if (lblReceipts.Text.Length < 5) lblReceipts.Location = new Point(25, lblReceipts.Location.Y);
else if (lblReceipts.Text.Length <= 7)
lblReceipts.Location = new Point(8, lblReceipts.Location.Y);
else if (lblReceipts.Text.Length <= 12)
{
lblReceipts.Font = new Font("Verdana", 8, FontStyle.Regular);
lblReceipts.Location = new Point(6, lblReceipts.Location.Y);
}
else if (lblReceipts.Text.Length <= 16)
{
lblReceipts.Font = new Font("Verdana", 7, FontStyle.Regular);
lblReceipts.Location = new Point(4, lblReceipts.Location.Y);
}
}
else
{ }
}
catch
{
}
}
private void GetOnHoldSale()
{
try
{
List<POS_PointOfSale> objholdsale = new List<POS_PointOfSale>();
objholdsale = ERPManagement.GetInstance.GetOnHoldSale();
if (objholdsale.Count > 0)
{
lblOnHold.Text = objholdsale.ToList()[0].TotalHoldSale.ToString() == null ? "0" : objholdsale.ToList()[0].TotalHoldSale.ToString();
}
else
{ }
}
catch
{
}
}
/// <summary>
/// edit countitem
/// </summary>
private void GetCountItem()
{
try
{
if (GridViewItems.Rows.Count > 0)
{
if (GridViewItems.SelectedRows.Count > 0)
{
isEdit = true;
rowindex = GridViewItems.SelectedRows[0].Index;
GetAllBarcodeDetails();
TxtBarcode.Text = GridViewItems.Rows[rowindex].Cells[1].Value.ToString();
txtCountNo.Text = GridViewItems.Rows[rowindex].Cells[3].Value.ToString();
GridViewItems.Rows[rowindex].Selected = true;
isEdit = false;
}
}
}
catch
{ }
}
private void GetProductSearch()
{
if (combosearch.SelectedIndex == -1)
{
MessageBox.Show(" Select one Item!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
combosearch.Focus();
}
else
{
try
{
dgvProdSearch.Columns.Clear();
if (combosearch.Text == "Barcode")
{
var searchitem = from prod in ERPManagement.GetInstance.GetProductSearch()
where prod.ItemBarcode.ToUpper().StartsWith(txtSearch.Text.ToUpper())
//select prod;
select new
{
ItemId = prod.ItemID,
Barcode = prod.ItemBarcode,
ItemName = prod.ItemName,
ItemQuantity = prod.ItemQuantity,
Price = prod.ItemPrice,
Isserial = prod.IsSerial,
};
if (searchitem.ToList().Count > 0)
{
LblNoRecord.Visible = false;
dgvProdSearch.DataSource = searchitem.ToList();
DataGridViewImageColumn imgprog = new DataGridViewImageColumn();
imgprog.Name = "img";
dgvProdSearch.Columns.Add(imgprog);
dgvProdSearch.Columns["ItemId"].Visible = false;
dgvProdSearch.Columns["Barcode"].Visible = false;
dgvProdSearch.Columns["Isserial"].Visible = false;
dgvProdSearch.Columns["ItemName"].HeaderText = "Item Name";
dgvProdSearch.Columns["Price"].HeaderText = "Price";
dgvProdSearch.Columns["ItemQuantity"].HeaderText = "";
dgvProdSearch.Columns["img"].HeaderText = "";
this.dgvProdSearch.Columns["Price"].DefaultCellStyle.Format = "f";
SetProdSearchGrid();
SetdgvProdSearchProgressImage();
dgvProdSearch.Columns["img"].DisplayIndex = 2;
dgvProdSearch.Columns["ItemQuantity"].DisplayIndex = 3;
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
LblNoRecord.Visible = true;
dgvProdSearch.DataSource = EmptyproductsearchGrid();
}
}
else if (combosearch.Text == "Item")
{
var searchitem = from prod in ERPManagement.GetInstance.GetProductSearch()
where prod.ItemName.ToLower().Contains(txtSearch.Text.Trim().ToLower())
//select prod;
select new
{
ItemId = prod.ItemID,
Barcode = prod.ItemBarcode,
ItemName = prod.ItemName,
ItemQuantity = prod.ItemQuantity,
Price = prod.ItemPrice,
Isserial = prod.IsSerial,
};
if (searchitem.ToList().Count > 0)
{
LblNoRecord.Visible = false;
dgvProdSearch.DataSource = searchitem.ToList();
DataGridViewImageColumn imgprog = new DataGridViewImageColumn();
imgprog.Name = "img";
dgvProdSearch.Columns.Add(imgprog);
dgvProdSearch.Columns["ItemId"].Visible = false;
dgvProdSearch.Columns["Barcode"].Visible = false;
dgvProdSearch.Columns["Isserial"].Visible = false;
dgvProdSearch.Columns["ItemName"].HeaderText = "Item Name";
dgvProdSearch.Columns["Price"].HeaderText = "Price";
dgvProdSearch.Columns["ItemQuantity"].HeaderText = "";
dgvProdSearch.Columns["img"].HeaderText = "";
this.dgvProdSearch.Columns["Price"].DefaultCellStyle.Format = "f";
SetProdSearchGrid();
SetdgvProdSearchProgressImage();
dgvProdSearch.Columns["img"].DisplayIndex = 2;
dgvProdSearch.Columns["ItemQuantity"].DisplayIndex = 3;
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
LblNoRecord.Visible = true;
dgvProdSearch.DataSource = EmptyproductsearchGrid();
}
}
else if (combosearch.Text == "Select")
{
var searchitem = from prod in ERPManagement.GetInstance.GetProductSearch()
where prod.ItemName.ToLower().Contains(txtSearch.Text.Trim().ToLower()) ||
prod.ItemBarcode.ToLower().Contains(txtSearch.Text.Trim().ToLower())
//select prod;
select new
{
ItemId = prod.ItemID,
Barcode = prod.ItemBarcode,
ItemName = prod.ItemName,
ItemQuantity = prod.ItemQuantity,
Price = prod.ItemPrice,
Isserial = prod.IsSerial,
};
if (searchitem.ToList().Count > 0)
{
LblNoRecord.Visible = false;
dgvProdSearch.DataSource = searchitem.ToList();
DataGridViewImageColumn imgprog = new DataGridViewImageColumn();
imgprog.Name = "img";
dgvProdSearch.Columns.Add(imgprog);
dgvProdSearch.Columns["ItemId"].Visible = false;
dgvProdSearch.Columns["Barcode"].Visible = false;
dgvProdSearch.Columns["Isserial"].Visible = false;
dgvProdSearch.Columns["ItemName"].HeaderText = "Item Name";
dgvProdSearch.Columns["Price"].HeaderText = "Price";
dgvProdSearch.Columns["ItemQuantity"].HeaderText = "";
dgvProdSearch.Columns["img"].HeaderText = "";
this.dgvProdSearch.Columns["Price"].DefaultCellStyle.Format = "f";
SetProdSearchGrid();
SetdgvProdSearchProgressImage();
dgvProdSearch.Columns["img"].DisplayIndex = 2;
dgvProdSearch.Columns["ItemQuantity"].DisplayIndex = 3;
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
LblNoRecord.Visible = true;
dgvProdSearch.DataSource = EmptyproductsearchGrid();
}
}
}
catch
{
}
}
}
private void GetCustomerSearch()
{
try
{
var customer = from cust in ERPManagement.GetInstance.GetCustomerSearch()
where cust.Customer_Name.ToLower().StartsWith(txtCustomerSearch.Text.Trim().ToLower())
select new
{
customerid = cust.Customer_ID,
customername = cust.Customer_Name,
mobileno = cust.CustomerPhone,
};
if (customer.ToList().Count > 0)
{
lblcustNorecord.Visible = false;
dgvCustSearch.DataSource = customer.ToList();
DataGridViewImageColumn imgcust = new DataGridViewImageColumn();
imgcust.Name = "custimg";
dgvCustSearch.Columns.Add(imgcust);
dgvCustSearch.Columns["customerid"].Visible = false;
dgvCustSearch.Columns["customername"].HeaderText = "Customer Name";
dgvCustSearch.Columns["mobileno"].HeaderText = "Phone";
dgvCustSearch.Columns["custimg"].HeaderText = "";
SetCustSearchGrid();
//set position
dgvCustSearch.Columns["customerid"].DisplayIndex = 0;
dgvCustSearch.Columns["custimg"].DisplayIndex = 1;
dgvCustSearch.Columns["customername"].DisplayIndex = 2;
dgvCustSearch.Columns["mobileno"].DisplayIndex = 3;
}
else
{
// MessageBox.Show("No record found.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
lblcustNorecord.Visible = true;
dgvCustSearch.DataSource = EmptycustomersearchGrid();
}
}
catch
{
}
}
//List<POS_Customer> Customerlist = new List<POS_Customer>();
// Customerlist = ERPManagement.GetInstance.SelectCustomers();
// var lnqCustomer = from customer in Customerlist
// where customer.Customer_ID == custid
// select customer;
// if (lnqCustomer.ToList().Count > 0)
// {
// if (lnqCustomer.ToList()[0].Imag != null)
// {
// byte[] bt = (byte[])lnqCustomer.ToList()[0].Imag;
// MemoryStream ms = new MemoryStream(bt);
// pbCustImage2.Image = Image.FromStream(ms);
// }
public void GetItemDetailInfo(string barcode)
{
List<POS_PointOfSale> Itemlist = new List<POS_PointOfSale>();
Itemlist = ERPManagement.GetInstance.GetSelectItem();
var lnqitem = from item in Itemlist
where item.ItemBarcode == barcode
select item;
if (lnqitem.ToList().Count > 0)
{
if (lnqitem.ToList()[0].ItemImage != null)
{
byte[] bt = (byte[])lnqitem.ToList()[0].ItemImage;
MemoryStream ms = new MemoryStream(bt);
pbitemimg.Image = Image.FromStream(ms);
}
else
{
pbitemimg.Image = POS.Properties.Resources.no_image_avilable;
}
if (lnqitem.ToList()[0].ItemBarcode != "")
{
lblbarcode.Text = "Barcode : " + lnqitem.ToList()[0].ItemBarcode.ToString();
}
else
{
lblbarcode.Text = "Barcode :N/A ";
}
if (lnqitem.ToList()[0].ItemName != "")
{
lblItemName.Text = lnqitem.ToList()[0].ItemName.ToString();
}
else
{
lblItemName.Text = "N/A ";
}
if (lnqitem.ToList()[0].ItemType != "")
{
lblitemtype.Text = "Item Type : " + lnqitem.ToList()[0].ItemType.ToString();
}
else
{
lblitemtype.Text = "Item Type :N/A ";
}
if (lnqitem.ToList()[0].MRP != 0)
{
lblmrp.Text = "MRP : " + lnqitem.ToList()[0].MRP.ToString("F");
}
else
{
lblmrp.Text = "MRP :N/A ";
}
if (lnqitem.ToList()[0].categoryName != "")
{
lblcategory.Text = "Category : " + lnqitem.ToList()[0].categoryName.ToString();
}
else
{
lblcategory.Text = "Category :N/A ";
}
//if (lnqitem.ToList()[0].ItemColor != "")
//{
// lblColor.Text = "Color : " + lnqitem.ToList()[0].ItemColor.ToString();
//}
//else
//{
// lblColor.Text = "Color :N/A ";
//}
//if (lnqitem.ToList()[0].ItemBrand != "")
//{
// lblbrand.Text = "Brand : " + lnqitem.ToList()[0].ItemBrand.ToString();
//}
//else
//{
// lblbrand.Text = "Brand :N/A ";
//}
//if (lnqitem.ToList()[0].GrossWeight != 0)
//{
// lblgrossweight.Text = "Gross Weight : " + lnqitem.ToList()[0].GrossWeight.ToString();
//}
//else
//{
// lblgrossweight.Text = "Gross Weight: N/A";
//}
//if (lnqitem.ToList()[0].StoneWeight != 0)
//{
// lblstoneweight.Text = "Stone Weight : " + lnqitem.ToList()[0].StoneWeight.ToString();
//}
//else
//{
// lblstoneweight.Text = "Stone Weight :N/A";
//}
//if (lnqitem.ToList()[0].PureWeight != 0)
//{
// lblpureweight.Text = "Pure Weight : " + lnqitem.ToList()[0].PureWeight.ToString();
//}
//else
//{
// lblpureweight.Text = "Pure Weight :N/A";
//}
}
else
{
}
}
//define transaction for save
public void SaveTransaction()
{
if (Cust_ID > 0)
{
//check serial no entry or not
if (purpose.ToLower() == "s" || purpose.ToLower() == "ss")
{
if (CheckSerialno() == false)
{
return;
}
}
//------------------
if (SaleId > 0)
{
UpdateData();
}
else
{
SaveData();
}
if (purpose.ToLower() == "s" || purpose.ToLower() == "ss")
{
frmPaymentSell obj = new frmPaymentSell(this);
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
// obj.Location = new Point(obj.Location.X + this.Location.X + 100, 130);
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
if (obj.PayStatus == "P")
{
ResetForm();
//call auto invoiceno
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
//GetCustomer();
tabDisplay.SelectedIndex = 0;
//ResetForm
ResetForm();
}
else if (obj.PayStatus == "C")
{
}
}
else
{
if (purpose == "O")
{
MessageBox.Show("Order Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (purpose == "Q")
{
MessageBox.Show("Quotation Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (purpose == "C")
{
MessageBox.Show("Cancel Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (purpose == "F")
{
return;
}
ResetForm();
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
GetCustomer();
tabDisplay.SelectedIndex = 0;
}
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
//define transaction for hold
public void HoldTransaction()
{
if (Cust_ID > 0)
{
if (SaleId > 0)
{
UpdateData();
}
else
{
SaveData();
}
if (purpose == "F")
{
return;
}
else
{
MessageBox.Show("Data Hold Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
//call auto invoiceno
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
//ResetForm
ResetForm();
}
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
//define transaction for cancel
public void CancelTransaction()
{
//if ((dgvCustSearch.SelectedRows.Count > 0) || Cust_ID > 0)
//{
purpose = "C";
if (SaleId > 0)
{
UpdateData();
}
else
{
SaveData();
}
MessageBox.Show("Cancel Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
//call auto invoiceno
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
//ResetForm
ResetForm();
// }
//else
//{
// purpose = "C";
// MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// tabDisplay.SelectedIndex = 2;
//}
}
//define edit a line item of datagridview
private void EditGridLineItem()
{
try
{
if (GridViewItems.Rows.Count > 0)
{
if (GridViewItems.SelectedRows.Count > 0)
{
isEdit = true;
rowindex = GridViewItems.SelectedRows[0].Index;
GetAllBarcodeDetails();
TxtBarcode.Text = GridViewItems.Rows[rowindex].Cells["ItemBarcode"].Value.ToString();
txtCountNo.Text = GridViewItems.Rows[rowindex].Cells["Item_Quantity"].Value.ToString();
//call focus here
FocusCountNumber();
GridViewItems.Rows[rowindex].Selected = true;
isEdit = false;
}
else
{
MessageBox.Show("Select a item for Edit!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
catch
{ }
}
//focus count textbox
private void FocusCountNumber()
{
txtCountNo.BackColor = System.Drawing.Color.Red;
}
private void RemoveGridLineItem()
{
try
{
if (GridViewItems.Rows.Count > 0)
{
if (GridViewItems.SelectedRows.Count > 0)
{
if (MessageBox.Show("Do you realy want to delete the selected row?", "KenCloud", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
rowindex = GridViewItems.CurrentRow.Index;
DataRow dr;
DataRow dr1;
dr = dtItems.Rows[rowindex];
dr.Delete();
dtItems.AcceptChanges();
dr1 = dtItemForDB.Rows[rowindex];
dr1.Delete();
dtItemForDB.AcceptChanges();
GridViewItems.DataSource = AutoNumberedTable(dtItems);
CalculateFooterData();
// DataTableEditFlag = 2;
ResetItemData();
stockprogressBar.Value = 0;
pnlmark.Visible = false;
}
}
else
{
MessageBox.Show("Select a item for Remove!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
catch
{ }
}
public void ConfirmpopFunctionality()
{
frmpopupConfirm objPOPup = new frmpopupConfirm();
objPOPup.ShowDialog();
btnmode = frmpopupConfirm.Btnmode;
if (btnmode == "SAVE")
{
//call save transaction
SaveTransaction();
}
else if (btnmode == "HOLD")
{
//call Hold transaction
HoldTransaction();
}
else if (btnmode == "CANCEL")
{
//call cancel transaction
CancelTransaction();
}
}
public void GetNuremicpad()
{
frmNumericPad obj = new frmNumericPad();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = tabDisplay.Location; //Cursor.Position;
obj.Location = new Point(obj.Location.X + this.Location.X + 5, this.Location.Y + obj.Location.Y + 25);
obj.ShowDialog();
txtCountNo.Text = obj.textBox1.Text;
if (txtCountNo.Text != "")
{
if (int.Parse(txtCountNo.Text) != 0)
{
// CALL HERE
GetCountItem();
//change normal color
txtCountNo.BackColor = System.Drawing.Color.White;
}
else
{
MessageBox.Show("Item quantity should not zero!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtCountNo.Text = "";
FocusCountNumber();
}
}
}
public void ResetForm()
{
try
{
TxtBarcode.Text = "";
TxtTotalNoOfItems = "";
TxtTotalAmount = "";
TxtTotalTaxAmount = "";
TxtTotalDiscountAmount = "";
TxtTotalAdjustAmount = "";
TxtNetAmount = "";
lblGrandTotal.Text = "";
dtItems.Rows.Clear();
dtItemForDB.Rows.Clear();
GridViewItems.DataSource = AutoNumberedTable(dtItems);
purpose = "S";
chkstockpurpose = "S";
//popup image for details amount
popupimgpurpose = "S";
SaleId = 0;
tabDisplay.SelectedIndex = 0;
BlockItemColumn();
//customer details
lblCustomerName.Text = "N/A";
lblCustIdNo.Text = "CID :N/A";
lblLastVisit.Text = "Last Visit :N/A";
lblTotalVisits.Text = "Total Visit :N/A";
lblTotalSales.Text = "Total Sale :N/A";
lblPhone.Text = "Phone :N/A";
Cust_ID = 0;
LblAddress1.Text = "Address1 : N/A";
LblAddress2.Text = "Address2 : N/A";
LblCity.Text = "City : N/A";
LblState.Text = "State : N/A";
LblCountry.Text = "Country : N/A";
LblZip.Text = "Pin : N/A";
LblShipPhn.Text = "Phone : N/A";
LblShipMail.Text = "E-Mail : N/A";
//Item details
lblItemName.Text = "N/A ";
lblbarcode.Text = "Barcode :N/A ";
lblitemtype.Text = "Item Type :N/A ";
lblmrp.Text = "MRP :N/A ";
lblcategory.Text = "Category :N/A ";
lblColor.Text = "Color :N/A ";
lblbrand.Text = "Brand :N/A ";
lblgrossweight.Text = "Gross Weight: N/A";
lblstoneweight.Text = "Stone Weight :N/A";
lblpureweight.Text = "Pure Weight :N/A";
pbCustomerImage.Image = POS.Properties.Resources._user_icon;
frmPoupSerialNo.dtSerialNo.Rows.Clear();
//row selected false
dgvProdSearch.Rows[0].Selected = false;
dgvCustSearch.Rows[0].Selected = false;
}
catch
{ }
}
public void Transaction(string tran)
{
try
{
EnableControl();
ResetForm();
Point p = GridViewItems.Location;
p = new Point(GridViewItems.Location.X + this.Location.X + 7, p.Y + 126);
frmViewSale obj = new frmViewSale(tran);
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
obj.Location = new Point(p.X, p.Y);
obj.ShowDialog();
SaleId = obj.saleid;
//set saleid to maxsaleid for complee transaction bcoz maxsaleid pass to paymentsell page
maxsaleid = SaleId.ToString();
if (SaleId != 0)
{
GetSaleData();
GetSaleDetails();
GetSaleCustomer();
//false gridview line focus
GridViewItems.Rows[0].Selected = false;
stockprogressBar.Value = 0;
}
else
{
ResetForm();
GetAutoInvoiceNo();
}
}
catch
{
}
}
public void ClearCustomer()
{
// if ((Cust_ID > 0) || (dgvCustSearch.SelectedRows.Count > 0))
if (Cust_ID > 0)
{
DialogResult dr = MessageBox.Show("Are you sure to delete selected Customer.", "KenCloud", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr.ToString() == "OK")
{
ERPManagement.GetInstance.DeleteCustomer(Cust_ID, 1);
LblAddress1.Text = "Address1 : N/A";
LblAddress2.Text = "Address2 : N/A";
LblCity.Text = "City : N/A";
LblState.Text = "State : N/A";
LblCountry.Text = "Country : N/A";
LblZip.Text = "Pin : N/A";
LblShipPhn.Text = "Phone : N/A";
LblShipMail.Text = "E-Mail : N/A";
// LOCAL CUSTOMER HISTORY
lblCustIdNo.Text = "CID : N/A";
lblLastVisit.Text = "Last Visit : N/A";
lblTotalVisits.Text = "Total Visit : N/A ";
lblTotalSales.Text = "Total Sale : N/A";
lblPhone.Text = "Phone : N/A ";
/////
GetCustomer();
}
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
public void EditCustomerDetails()
{
// if ((Cust_ID > 0) || (dgvCustSearch.SelectedRows.Count > 0))
if (Cust_ID > 0)
{
EditCustomerDetails(Cust_ID);
GetCustomer();
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
public void FormExit()
{
if ((GridViewItems.Rows.Count > 0) && isInvoice == false)
{
ConfirmpopFunctionality();
}
else
{
frmCloseApp fmclose = new frmCloseApp();
fmclose.ShowDialog();
if (frmCloseApp.status == "Switch")
{
this.Close();
frmLogin obj = new frmLogin();
obj.ShowDialog();
}
}
}
void AddNewCustomer()
{
frmCustomer obj = new frmCustomer();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = new Point(this.Width + this.Location.X - 333, 7);
obj.ShowDialog();
}
void EditCustomerAllInformation(string id)
{
frmCustomer customer = new frmCustomer();
customer.StartPosition = FormStartPosition.Manual;
customer.Location = new Point(this.Width + this.Location.X - 355, 10);
Control[] ID = customer.Controls.Find("HdnField", true);
//int Customer_ID = (int)gridCustomerList.Rows[e.RowIndex].Cells[0].Value;
//List<POS_Customer> Customers = new List<POS_Customer>();
//Customers = ERPManagement.GetInstance.SelectCustomers();
//var CustomerDet = from cust in Customers
// where cust.Customer_ID == Customer_ID
// select cust;
//if (CustomerDet.Count() > 0)
//{
// ID[0].Text = CustomerDet.ToList()[0].Customer_ID.ToString();
//}
ID[0].Text = id;
customer.ShowDialog();
}
#endregion
#region BarcodeDetails
//-------scan image change --------------------
private void changeScanImage(string code)
{
if (code != string.Empty && code != "")
{
pictureBox5.Image = POS.Properties.Resources._barcode_scanning_gray;
}
else
{
pictureBox5.Image = POS.Properties.Resources._barcode_scanning;
}
}
//--------------scan customer layalitycard------------
private void GetCustomerbyCard(string cardno)
{
List<POS_Customer> customerlist = new List<POS_Customer>();
customerlist = ERPManagement.GetInstance.SelectCustomers();
var customer = from cust in customerlist
where cust.Loyality_Card_No == cardno
select cust;
if (customer.ToList().Count > 0)
{
if (customer.ToList()[0].Customer_ID != null && customer.ToList()[0].Customer_ID != 0)
{
string custid = customer.ToList()[0].Customer_ID.ToString();
tabDisplay.SelectedIndex = 2;
GetcustomergridFocus(custid);
TxtBarcode.Text = "";
}
}
}
void GetcustomergridFocus(string custid)
{
for (int i = 0; i < dgvCustSearch.Rows.Count; i++)
{
if (dgvCustSearch.Rows[i].Cells["customerid"].Value.ToString() == custid)
{
int rowindex = dgvCustSearch.Rows[i].Cells["customerid"].RowIndex;
// dgvCustSearch.CurrentCell = dgvCustSearch.Rows[rowindex].Cells["customername"];
dgvCustSearch.Rows[rowindex].Selected = true;
}
}
}
public void GetCustomerInformation()
{
if (lblCustomerName.InvokeRequired || lblCustIdNo.InvokeRequired || lblLastVisit.InvokeRequired || lblTotalVisits.InvokeRequired
)
{
delGetCustomerInformation del = new delGetCustomerInformation(GetCustomerInformation);
this.Invoke(del, new object[] { });
}
else
{
List<POS_Customer> Customerlist = new List<POS_Customer>();
Customerlist = ERPManagement.GetInstance.SelectCustomers();
var lnqCustomer1 = (from customer in Customerlist
where customer.Customer_ID == customeridshipping
orderby customer.Customer_Shipping_Detail_ID
select customer);
if (lnqCustomer1.ToList().Count > 0)
{
var lnqCustomer = lnqCustomer1.ToList().ElementAt(lnqCustomer1.ToList().Count - 1);
if (lnqCustomer.Imag != null)
{
byte[] bt = (byte[])lnqCustomer.Imag;
MemoryStream ms = new MemoryStream(bt);
pbCustomerImage.Image = Image.FromStream(ms);
}
else
{
pbCustomerImage.Image = POS.Properties.Resources._user_icon;
}
if (lnqCustomer.Customer_Name != null && lnqCustomer.Customer_Name != "")
lblCustomerName.Text = lnqCustomer.Customer_Name.ToString();
if (lnqCustomer.Loyality_Card_No != null && lnqCustomer.Loyality_Card_No != "")
lblCustIdNo.Text = "CID : " + lnqCustomer.Loyality_Card_No.ToString();
if (lnqCustomer.Last_Visit_Date != null && lnqCustomer.Last_Visit_Date != null)
lblLastVisit.Text = "Last Visit : " + lnqCustomer.Last_Visit_Date;
if (lnqCustomer.Total_Visit != null)
lblTotalVisits.Text = "Total Visit : " + lnqCustomer.Total_Visit.ToString();
if (lnqCustomer.Total_Sale != null && lnqCustomer.Total_Sale.ToString() != "")
lblTotalSales.Text = "Total Sale : " + lnqCustomer.Total_Sale.ToString();
if (lnqCustomer.Mobile_No != null && lnqCustomer.Mobile_No.ToString() != "")
lblPhone.Text = "Phone : " + lnqCustomer.Mobile_No.ToString();
if (lnqCustomer.Customer_ID != null && lnqCustomer.Customer_ID.ToString() != "")
{
Cust_ID = lnqCustomer.Customer_ID;
}
//=========== Shipping Info =================
// BlankShipping();
string address = "";
if (lnqCustomer.Ship_Address1 != null && lnqCustomer.Ship_Address1 != "")
{
string[] slist = lnqCustomer.Ship_Address1.ToString().Split(' ');
if (slist.Length > 0) address = slist[0];
if (slist.Length > 1) address += " " + slist[1] + " ...";
LblAddress1.Text = "Address1 : " + address;
ToolTip11.SetToolTip(this.LblAddress1, "");
ToolTip11.SetToolTip(this.LblAddress1, lnqCustomer.Ship_Address1.ToString());
LblAddress1.Cursor = Cursors.Hand;
}
else
{
LblAddress1.Text = "Address1 : N/A";
}
if (lnqCustomer.Ship_Address2 != null && lnqCustomer.Ship_Address2 != "")
{
string[] slist = lnqCustomer.Ship_Address2.ToString().Split(' ');
if (slist.Length > 0) address = slist[0];
if (slist.Length > 1) address += " " + slist[1] + " ...";
LblAddress2.Text = "Address2 : " + address;
ToolTip22.SetToolTip(this.LblAddress1, "");
ToolTip22.SetToolTip(this.LblAddress2, lnqCustomer.Ship_Address2.ToString());
LblAddress2.Cursor = Cursors.Hand;
}
else
{
LblAddress2.Text = "Address2 : N/A";
}
if (lnqCustomer.City_ID != null && lnqCustomer.City_ID.ToString() != "")
{
LblCity.Text = "City : " + lnqCustomer.City_ID.ToString();
}
else
{
LblCity.Text = "City : N/A";
}
if (lnqCustomer.Ship_State != null && lnqCustomer.Ship_State.ToString() != "")
{
LblState.Text = "State : " + lnqCustomer.Ship_State;
}
else
{
LblState.Text = "State : N/A";
}
if (lnqCustomer.Ship_Country != null && lnqCustomer.Ship_Country.ToString() != "")
{
LblCountry.Text = "Country : " + lnqCustomer.Ship_Country.ToString();
}
else
{
LblCountry.Text = "Country : N/A";
}
if (lnqCustomer.Zip_Code != null && lnqCustomer.Zip_Code.ToString() != "")
{
LblZip.Text = "Zip : " + lnqCustomer.Zip_Code.ToString();
}
else
{
LblZip.Text = "Pin : N/A";
}
if (lnqCustomer.Ship_Phone != null && lnqCustomer.Ship_Phone.ToString() != "")
{
LblShipPhn.Text = "Phone : " + lnqCustomer.Ship_Phone.ToString();
}
else
{
LblShipPhn.Text = "Phone : N/A";
}
if (lnqCustomer.Ship_Email != null && lnqCustomer.Ship_Email.ToString() != "")
{
LblShipMail.Text = "E-Mail : " + lnqCustomer.Ship_Email.ToString();
}
else
{
LblShipMail.Text = "E-Mail : N/A";
}
if (lnqCustomer.Total_Amount != 0 && lnqCustomer.Total_Amount.ToString() != "")
{
lblShippingCharge.Text = "Shipping Charge: " + lnqCustomer.Total_Amount.ToString();
// TotalShippingCharge=lnqCustomer.Total_Amount.ToString();
}
else
{
lblShippingCharge.Text = "Shipping Charge: N/A";
}
//=========== End Shipping Info =================
}
}
}
public void BlankShipping()
{
LblAddress1.Text = "Address1 : N/A";
LblAddress2.Text = "Address2 : N/A";
LblCity.Text = "City : N/A";
LblState.Text = "State : N/A";
LblCountry.Text = "Country : N/A";
LblZip.Text = "Pin : N/A";
LblShipPhn.Text = "Phone : N/A";
LblShipMail.Text = "E-Mail : N/A";
}
private void GetCustomerDetailInfo(int custid)
{
List<POS_Customer> Customerlist = new List<POS_Customer>();
Customerlist = ERPManagement.GetInstance.SelectCustomers();
var lnqCustomer = from customer in Customerlist
where customer.Customer_ID == custid
select customer;
if (lnqCustomer.ToList().Count > 0)
{
if (lnqCustomer.ToList()[0].Imag != null)
{
byte[] bt = (byte[])lnqCustomer.ToList()[0].Imag;
MemoryStream ms = new MemoryStream(bt);
pbCustomeImaget2.Image = Image.FromStream(ms);
}
else
{
pbCustomeImaget2.Image = POS.Properties.Resources._user_icon;
}
if (lnqCustomer.ToList()[0].Customer_Name != "")
lblCustomerNameT2.Text = lnqCustomer.ToList()[0].Customer_Name.ToString();
if (lnqCustomer.ToList()[0].Loyality_Card_No != "")
lblCIDT2.Text = "CID: " + lnqCustomer.ToList()[0].Loyality_Card_No.ToString();
if (lnqCustomer.ToList()[0].Mobile_No.ToString() != "")
lblPhonet2.Text = "Phone: " + lnqCustomer.ToList()[0].Mobile_No.ToString();
if (lnqCustomer.ToList()[0].Customer_ID != null && lnqCustomer.ToList()[0].Customer_ID.ToString() != "")
{
Cust_ID = lnqCustomer.ToList()[0].Customer_ID;
}
if (lnqCustomer.ToList()[0].Address.ToString() != "")
{
lblAddresst2.Text = "Address: " + lnqCustomer.ToList()[0].Address.ToString();
}
else
{
lblAddresst2.Text = "Address: N/A";
}
if (lnqCustomer.ToList()[0].City.ToString() != "")
{
lblCityt2.Text = "City: " + lnqCustomer.ToList()[0].City.ToString();
}
else
{
lblCityt2.Text = "City: N/A";
}
if (lnqCustomer.ToList()[0].CustomerState.ToString() != "")
{
lblstateT2.Text = "State: " + lnqCustomer.ToList()[0].CustomerState.ToString();
}
else
{
lblstateT2.Text = "State: N/A";
}
if (lnqCustomer.ToList()[0].CustomerCountry.ToString() != "")
{
lblCountryt2.Text = "Country: " + lnqCustomer.ToList()[0].CustomerCountry.ToString();
}
else
{
lblCountryt2.Text = "Country: N/A";
}
if (lnqCustomer.ToList()[0].Email_ID.ToString() != "")
{
lblEmailt2.Text = "Email Id: " + lnqCustomer.ToList()[0].Email_ID.ToString();
}
else
{
lblEmailt2.Text = "Email Id: N/A";
}
if (lnqCustomer.ToList()[0].DateofBirth != null && lnqCustomer.ToList()[0].DateofBirth.ToString() != "")
{
lblDOBt2.Text = "Date of Birth: " + lnqCustomer.ToList()[0].DateofBirth.Value.ToString("dd/MM/yyyy");
}
else
{
lblDOBt2.Text = "Date of Birth: N/A";
}
if (lnqCustomer.ToList()[0].Marriage_Anniversary != null && lnqCustomer.ToList()[0].Marriage_Anniversary.ToString() != "")
{
lblMarriageAnniversaryT2.Text = "Marriage Anniversary: " + lnqCustomer.ToList()[0].Marriage_Anniversary.Value.ToString("dd/MM/yyyy");
}
else
{
lblMarriageAnniversaryT2.Text = "Marriage Anniversary: N/A";
}
if (lnqCustomer.ToList()[0].IS_Married == true)
{
lblmaritalStatust2.Text = "MaritalStatus: Married";
}
else
{
lblmaritalStatust2.Text = "MaritalStatus: Unmarried";
}
if (lnqCustomer.ToList()[0].Gender != null && lnqCustomer.ToList()[0].Gender.ToString() != "")
{
if (lnqCustomer.ToList()[0].Gender == true)
{
lblGendert2.Text = "Gender : Male";
}
else
{
lblGendert2.Text = "Gender: Female";
}
}
else
{
lblGendert2.Text = "Gender: N/A";
}
}
else
{
}
}
private void CreateDataTable()
{
try
{
dtItems = new DataTable();
dtItems.Columns.Add("BarCode", typeof(string));
dtItems.Columns.Add("ItemName", typeof(string));
dtItems.Columns.Add("Item_Quantity", typeof(int));
dtItems.Columns.Add("Discount_Percent", typeof(int));
dtItems.Columns.Add("Is_Taxable", typeof(bool));
dtItems.Columns.Add("Item_Price", typeof(float));
dtItems.Columns.Add("Net_Amount", typeof(float));
dtItems.Columns.Add("Item_Unit_Price", typeof(float));
dtItems.Columns.Add("Tax_Percent", typeof(float));
dtItems.Columns.Add("Discount_Price", typeof(float));
dtItems.Columns.Add("Extended_Price", typeof(float));
//ADD SCHEMEOFFER ID
dtItems.Columns.Add("SchemeID", typeof(int));
dtItems.Columns.Add("IsSerial", typeof(bool));
dtItemForDB = new DataTable();
dtItemForDB.Columns.Add("BarCode", typeof(string));
dtItemForDB.Columns.Add("Item_ID", typeof(int));
dtItemForDB.Columns.Add("Item_Quantity", typeof(int));
dtItemForDB.Columns.Add("Discount_Percent", typeof(int));
dtItemForDB.Columns.Add("Is_Taxable", typeof(bool));
dtItemForDB.Columns.Add("Item_Price", typeof(float));
dtItemForDB.Columns.Add("Net_Amount", typeof(float));
dtItemForDB.Columns.Add("Item_Unit_Price", typeof(float));
dtItemForDB.Columns.Add("Tax_Percent", typeof(float));
dtItemForDB.Columns.Add("Discount_Price", typeof(float));
dtItemForDB.Columns.Add("Extended_Price", typeof(float));
//ADD SCHEMEOFFER ID
dtItems.Columns.Add("SchemeID", typeof(int));
}
catch (Exception ex)
{
}
}
void GetAllBarcodeDetails()
{
try
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (TxtBarcode.Text != string.Empty)
{
decimal Price = 0;
Price = ERPManagement.GetInstance.GetPrice(TxtBarcode.Text.Trim());
Price = Math.Round(Price, 2);
//TxtInvoiceNumber.Text = Price.ToString();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tax = 0;
var TaxList = (from col in ERPManagement.GetInstance.GetAllTaxsetUpDetails()
where col.Active == true
select new
{
TaxSetUpId = col.Tax_Setup_Id,
TaxTitle = col.Tax_Title,
Percentage = col.Float,
Effective_Date = col.Effective_Date,
active = col.Active
}).ToList();
if (TaxList.ToList().Count == 0)
{
tax = 1;
}
for (int i = 0; i < TaxList.ToList().Count; i++)
{
//if (TaxList[i].active == true)
//{
tax += (decimal)TaxList[i].Percentage;
//}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dtBarcode = new DataTable();
dtBarcode = ERPManagement.GetInstance.GetAllBarcodeDetailsApproveByBarcode(TxtBarcode.Text.Trim());
if (dtBarcode.Rows.Count > 0)
{
Item_ID = int.Parse(dtBarcode.Rows[0]["Item_ID"].ToString());
//TxtItemName.Text = dtBarcode.Rows[0]["item_name"].ToString();
ItemName = dtBarcode.Rows[0]["item_name"].ToString();
if (EditQuantity == true)
{
EditQuantity = false;
}
//check entry counttextbox
else if (iscountqty == true)
{
Quantity = txtCountNo.Text;
iscountqty = false;
}
//check when edit in a row in datagridview and item in count textbox
else if (isEdit == true)
{
Quantity = txtCountNo.Text;
}
else
{
Quantity = "1";
//set sqleqt here
Saleqty = 1;
}
//TxtUnitPrice.Text = Price.ToString();
Unitprice = Price.ToString();
// TxtPrice.Text = (float.Parse(TxtQuantity.Text) * float.Parse(TxtUnitPrice.Text)).ToString();
if (TaxList.ToList().Count > 0)
{
chktaxable = "true";
}
else
{
chktaxable = "false";
}
ItemPrice = (float.Parse(Quantity) * float.Parse(Unitprice)).ToString("F");
Taxpercentage = tax.ToString();
Extendedprice = (Convert.ToDecimal(ItemPrice) + (Convert.ToDecimal(ItemPrice) * tax) / 100).ToString();
Discountprice = "0";
DiscountPercentage = "0";
Netprice = Extendedprice.ToString();
//***********************************Scheme & Offer********************************
//var dis = from disc in ERPManagement.GetInstance.GetAllScheemAndOffer()
// where disc.Barcode1 == TxtBarcode.Text
// select disc;
//if (dis.ToList().Count() > 0)
//{
// IsScheme = true;
// //Disqty = int.Parse(dis.ToList()[0].Quantity1.ToString());
// Byeqty = int.Parse(dis.ToList()[0].Quantity1.ToString());
// Getqty = int.Parse(dis.ToList()[0].Quantity2.ToString());
// FlagScheme = 1;
// SchemeID = int.Parse(dis.ToList()[0].Scheme_ID.ToString());
// Schemebarcode = dis.ToList()[0].Barcode2.ToString();
// // TxtBarcode.Text = dis.ToList()[0].Barcode2.ToString();
//}
//else
//{
// IsScheme = false;
//}
//***********************************end Scheme & Offer********************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (_EditGrid == true)
{
EditGrid();
_EditGrid = false;
}
else
{
AddToGrid();
chktaxable = "true";
}
GridViewItems.DataSource = AutoNumberedTable(dtItems);
//clear first row selected
if (GridViewItems.Rows.Count > 0)
{
GridViewItems.Rows[0].Selected = false;
}
//format currency cell
GridViewItems.Columns["Item_Price"].DefaultCellStyle.Format = "F";
GridViewItems.Columns["Net_Amount"].DefaultCellStyle.Format = "F";
////****************add scheme grid here********************////
//if (IsScheme == true)
//{
// AddSchemeToGrid();
// //ChkTaxable.Checked = true;
// chktaxable = "true";
// GridViewItems.DataSource = AutoNumberedTable(dtItems);
//}
////****************end here********************////
CalculateFooterData();
//SetGrid();
//call image for serial
GetIsserialImage();
//visible false item column
BlockItemColumn();
//price column visible false
ResetItemData();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//button enable
//btnF11Total.Enabled = true;
}
else
{
MessageBox.Show("No item found !", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
TxtBarcode.Text = "";
} //AddToGrid();
}
}
catch (Exception ex)
{
}
}
void AddToGrid()
{
if (TxtBarcode.Text != "")
{
bool valid = true;
int i;
for (i = 0; i < dtItems.Rows.Count; i++)
{
//******************************************************************************************
////for scheme
// if (dtItems.Rows[i][0].ToString().Trim() == TxtBarcode.Text.Trim() && dtItems.Rows[i][10].ToString()=="0")
//***************************************************************************
if (dtItems.Rows[i][0].ToString().Trim() == TxtBarcode.Text.Trim())
{
valid = false;
break;
}
}
if (valid)
{
DataRow row = dtItems.NewRow();
DataRow row2 = dtItemForDB.NewRow();
if (TxtBarcode.Text != "")
{
row[0] = TxtBarcode.Text;
row2[0] = TxtBarcode.Text;
}
if (ItemName != "")
{
row[1] = ItemName;
row2[1] = Item_ID;
}
if (Quantity != "")
{
row[2] = int.Parse(Quantity);
row2[2] = int.Parse(Quantity);
}
if (DiscountPercentage != "")
{
row[3] = float.Parse(DiscountPercentage);
row2[3] = float.Parse(DiscountPercentage);
}
if (chktaxable == "true")
{
row[4] = true;
row2[4] = true;
}
else
{
row[4] = false;
row2[4] = false;
}
if (ItemPrice != "")
{
row[5] = float.Parse(ItemPrice).ToString("F");
row2[5] = float.Parse(ItemPrice).ToString("F");
}
if (Extendedprice != "")
{
row[6] = float.Parse(Extendedprice).ToString("F");
row2[6] = float.Parse(Extendedprice).ToString("F");
}
if (Unitprice != "")
{
row[7] = float.Parse(Unitprice).ToString("F");
row2[7] = float.Parse(Unitprice).ToString("F");
}
if (Taxpercentage != "")
{
row[8] = float.Parse(Taxpercentage).ToString();
row2[8] = float.Parse(Taxpercentage).ToString();
}
if (Discountprice != "")
{
row[9] = float.Parse(Discountprice).ToString("F");
row2[9] = float.Parse(Discountprice).ToString("F");
}
if (Extendedprice != "")
{
row[10] = float.Parse(Extendedprice).ToString("F"); //Test for which control
row2[10] = float.Parse(Extendedprice).ToString("F"); //Test for which control
}
//assign schemeid
if (Saleqty >= Byeqty)
{
row[11] = SchemeID;
}
else
{
row[11] = 0;
}
row[12] = Isserial;
//check stock when add 1 quantity
List<POS_FranchiseItemPurchase> objPO = new List<POS_FranchiseItemPurchase>();
objPO = ERPManagement.GetInstance.GetQCApproveStockQuantity();
objPO = objPO.Where(lst => lst.Barcode == TxtBarcode.Text).ToList();
if (objPO.Count > 0)
{
int stockqty = objPO.ToList()[0].StockQuantity;
if (int.Parse(Quantity) > stockqty)
{
MessageBox.Show("Stock not available!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
else
{
MessageBox.Show("Stock not available!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
dtItems.Rows.Add(row);
dtItemForDB.Rows.Add(row2);
}
else
{
//Add with existing if Baecode ia already entered
if (dtItems.Rows[i][7].ToString() != "")
{
int qt = 0;
//check is row edit or not?if edit quantity column set 0
if (isEdit == true)
{
qt = 0;
// isEdit = false;
}
else
{
qt = int.Parse(dtItems.Rows[i][2].ToString());
}
qt += int.Parse(Quantity);
Saleqty = qt;
//check stock
List<POS_FranchiseItemPurchase> objPO = new List<POS_FranchiseItemPurchase>();
objPO = ERPManagement.GetInstance.GetQCApproveStockQuantity();
objPO = objPO.Where(lst => lst.Barcode == TxtBarcode.Text).ToList();
if (objPO.Count > 0)
{
int stockqty = objPO.ToList()[0].StockQuantity;
if (Saleqty > stockqty)
{
MessageBox.Show("Stock not available!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
else
{
MessageBox.Show("Stock not available!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
//CHECK QUANTITY IS SCHEME OR ORIGINAL
if (dtItems.Rows[i][11].ToString().Trim() == "0")
{
dtItems.Rows[i][2] = qt;
dtItemForDB.Rows[i][2] = qt;
}
else if (Convert.ToInt32(dtItems.Rows[i][11].ToString()) > 0)
{
dtItems.Rows[i][2] = int.Parse(Quantity);
dtItemForDB.Rows[i][2] = int.Parse(Quantity);
}
//dtItemForDB.Rows[i][2] = qt;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
float qtprice = float.Parse(dtItems.Rows[i][5].ToString());
if (isEdit == true)
{
//qtprice = float.Parse(ItemPrice);
}
else
{
//qtprice += float.Parse(ItemPrice);
}
dtItems.Rows[i][5] = qtprice.ToString("F");
dtItemForDB.Rows[i][5] = qtprice.ToString("F");
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
float qtextnprice = float.Parse(dtItems.Rows[i][6].ToString());
if (isEdit == true)
{
qtextnprice = float.Parse(Extendedprice);
}
else
{
qtextnprice += float.Parse(Extendedprice);
}
dtItems.Rows[i][6] = qtextnprice;
dtItemForDB.Rows[i][6] = qtextnprice;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
float qtdisprice = float.Parse(dtItems.Rows[i][9].ToString());
if (isEdit == true)
{
qtdisprice += float.Parse(Discountprice);
}
else
{
qtdisprice += float.Parse(Discountprice);
}
dtItems.Rows[i][9] = qtdisprice.ToString("F");
dtItemForDB.Rows[i][9] = qtdisprice.ToString("F");
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
float qtnetprice = float.Parse(dtItems.Rows[i][10].ToString());
if (isEdit == true)
{
qtnetprice = float.Parse(Netprice);
}
else
{
qtnetprice += float.Parse(Netprice);
}
dtItems.Rows[i][10] = qtnetprice.ToString("F");
dtItemForDB.Rows[i][10] = qtnetprice.ToString("F");
}
}
}
else
{
}
}
void AddSchemeToGrid()
{
bool schemevalid = true;
if (IsScheme == true)
{
if (Saleqty >= Byeqty)
{
if (FlagScheme == 1)
{
//if Byeqty=getqty
if (Byeqty - Getqty == 0)
{
Quantity = Saleqty.ToString();
Unitprice = "0";
ItemPrice = "0";
Taxpercentage = "0";
Extendedprice = "0";
Discountprice = "0";
Netprice = "0";
chktaxable = "false";
}
//if Byeqty<getqty
if (Byeqty < Getqty)
{
int mod = Byeqty % 2;
int n = Saleqty / Byeqty;
int qty = Byeqty + (n - 1) * Byeqty;
int actualqty = qty + n;
Quantity = actualqty.ToString();
Unitprice = "0";
ItemPrice = "0";
Taxpercentage = "0";
Extendedprice = "0";
Discountprice = "0";
Netprice = "0";
chktaxable = "false";
}
//if Byeqty>getqty
if (Byeqty > Getqty)
{
int mod = Byeqty % Getqty;
//if (mod == 0)
//{
// TxtQuantity.Text = (int.Parse(TxtQuantity.Text) * Saleqty / Disqty).ToString();
//TxtQuantity.Text = (Saleqty / Byeqty).ToString();
int n = Saleqty / Byeqty;
int qty = Byeqty + (n - 1) * Byeqty;
int actualqty = qty - n;
Quantity = actualqty.ToString();
Unitprice = "0";
ItemPrice = "0";
Taxpercentage = "0";
Extendedprice = "0";
Discountprice = "0";
Netprice = "0";
chktaxable = "false";
}
}
int i;
for (i = 0; i < dtItems.Rows.Count; i++)
{
if (dtItems.Rows[i][0].ToString().Trim() == Schemebarcode && dtItems.Rows[i][11].ToString() != "0")
{
schemevalid = false;
break;
}
}
if (schemevalid)
{
DataRow row = dtItems.NewRow();
DataRow row2 = dtItemForDB.NewRow();
if (TxtBarcode.Text != "")
{
row[0] = Schemebarcode;
row2[0] = Schemebarcode;
}
//if (TxtItemName.Text != "")
if (ItemName != "")
{
row[1] = ItemName;
row2[1] = Item_ID;
}
//if (TxtQuantity.Text != "")
if (Quantity != "")
{
row[2] = int.Parse(Quantity);
row2[2] = int.Parse(Quantity);
}
// if (TxtUnitPrice.Text != "")
if (Unitprice != "")
{
row[3] = float.Parse(Unitprice);
row2[3] = float.Parse(Unitprice);
}
//if (TxtPrice.Text != "")
if (ItemPrice != "")
{
row[4] = float.Parse(ItemPrice);
row2[4] = float.Parse(ItemPrice);
}
// if (ChkTaxable.Checked)
if (chktaxable == "true")
{
row[5] = true;
row[6] = float.Parse(Taxpercentage);
row2[5] = true;
row2[6] = float.Parse(Taxpercentage);
}
else
{
row[5] = false;
row[6] = 0;
row2[5] = false;
row2[6] = 0;
}
//if (TxtExtendedPrice.Text != "")
if (Extendedprice != "")
{
row[7] = float.Parse(Extendedprice).ToString("f");
row2[7] = float.Parse(Extendedprice).ToString("f");
}
// if (TxtDiscountPrice.Text != "")
if (Discountprice != "")
{
row[8] = float.Parse(Discountprice).ToString("f");
row2[8] = float.Parse(Discountprice).ToString("f");
}
// if (TxtExtendedPrice.Text != "")
if (Extendedprice != "")
{
row[9] = float.Parse(Extendedprice).ToString("f"); //Test for which control
row2[9] = float.Parse(Extendedprice).ToString("f"); //Test for which control
}
//assign schemeid
row[10] = SchemeID;
dtItems.Rows.Add(row);
dtItemForDB.Rows.Add(row2);
}
else
{
//Add with existing if Baecode ia already entered
if (dtItems.Rows[i][3].ToString() != "")
{
int qt = int.Parse(dtItems.Rows[i][2].ToString());
//qt += int.Parse(TxtQuantity.Text);
qt += int.Parse(Quantity);
Saleqty = qt;
//CHECK QUANTITY IS SCHEME OR ORIGINAL
if (dtItems.Rows[i][10].ToString().Trim() == "0")
{
dtItems.Rows[i][2] = qt;
dtItemForDB.Rows[i][2] = qt;
}
else if (Convert.ToInt32(dtItems.Rows[i][10].ToString()) > 0)
{
//dtItems.Rows[i][2] = int.Parse(TxtQuantity.Text);
//dtItemForDB.Rows[i][2] = int.Parse(TxtQuantity.Text);
dtItems.Rows[i][2] = int.Parse(Quantity);
dtItemForDB.Rows[i][2] = int.Parse(Quantity);
}
//dtItemForDB.Rows[i][2] = qt;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
qt = int.Parse(dtItems.Rows[i][4].ToString());
//qt += int.Parse(TxtPrice.Text);
qt += int.Parse(ItemPrice);
dtItems.Rows[i][4] = qt;
dtItemForDB.Rows[i][4] = qt;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
float qt1 = float.Parse(dtItems.Rows[i][7].ToString());
//qt1 += float.Parse(TxtExtendedPrice.Text);
qt1 += float.Parse(Extendedprice);
dtItems.Rows[i][7] = qt1;
dtItemForDB.Rows[i][7] = qt1;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
qt1 = float.Parse(dtItems.Rows[i][8].ToString());
//qt1 += float.Parse(TxtDiscountPrice.Text);
qt1 += float.Parse(Discountprice);
dtItems.Rows[i][8] = qt1;
dtItemForDB.Rows[i][8] = qt;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
qt1 = float.Parse(dtItems.Rows[i][9].ToString());
//qt1 += float.Parse(TxtNet.Text);
qt1 += float.Parse(Netprice);
dtItems.Rows[i][9] = qt1;
dtItemForDB.Rows[i][9] = qt1;
}
}
}//salebyeqty
}//isscheme
}
//visible false item grid column
void BlockItemColumn()
{
try
{
GridViewItems.Columns["Item_Unit_Price"].Visible = false;
GridViewItems.Columns["Tax_Percent"].Visible = false;
GridViewItems.Columns["Discount_Price"].Visible = false;
GridViewItems.Columns["Extended_Price"].Visible = false;
GridViewItems.Columns["SchemeID"].Visible = false;
GridViewItems.Columns["IsSerial"].Visible = false;
}
catch (Exception) { }
}
//disable form control
void DisableControl()
{
tabDisplay.Enabled = false;
btnF1Item.Enabled = false;
btnF2Customer.Enabled = false;
btnF3Transaction.Enabled = false;
btnF4Tasks.Enabled = false;
btnF5Tools.Enabled = false;
btnF6Return.Enabled = false;
btnF11Total.Enabled = false;
btnTransactionHistory.Enabled = false;
btnConvertSTO.Enabled = false;
btnOrdersbottom.Enabled = false;
btnPurchaseHistory.Enabled = false;
btnClearHistory.Enabled = false;
btnCustomerDetails.Enabled = false;
GridViewItems.Enabled = false;
TxtBarcode.Enabled = false;
txtCountNo.Enabled = false;
pbPlus.Enabled = false;
pbMinus.Enabled = false;
}
//disable form control
void EnableControl()
{
tabDisplay.Enabled = true;
btnF1Item.Enabled = true;
btnF2Customer.Enabled = true;
btnF3Transaction.Enabled = true;
btnF4Tasks.Enabled = true;
btnF5Tools.Enabled = true;
btnF6Return.Enabled = true;
btnF11Total.Enabled = true;
btnTransactionHistory.Enabled = true;
btnConvertSTO.Enabled = true;
btnOrdersbottom.Enabled = true;
btnPurchaseHistory.Enabled = true;
btnClearHistory.Enabled = true;
btnCustomerDetails.Enabled = true;
GridViewItems.Enabled = true;
TxtBarcode.Enabled = true;
// txtCountNo.Enabled = true;
pbPlus.Enabled = true;
pbMinus.Enabled = true;
}
void EditGrid()
{
if (dtItems.Rows.Count > 0)
{
//---------------------------
dtItems.Rows[index][0] = TxtBarcode.Text;
dtItems.Rows[index][1] = ItemName;
dtItems.Rows[index][2] = int.Parse(Quantity);
dtItems.Rows[index][3] = float.Parse(Unitprice);
dtItems.Rows[index][4] = float.Parse(ItemPrice);
//dtItems.Rows[index][5] = TxtRatePerGram.Text;
dtItems.Rows[index][6] = float.Parse(Taxpercentage);
dtItems.Rows[index][7] = float.Parse(Extendedprice);
dtItems.Rows[index][8] = float.Parse(Discountprice);
dtItems.Rows[index][9] = float.Parse(Extendedprice);
//--------------------------
dtItemForDB.Rows[index][0] = TxtBarcode.Text;
dtItemForDB.Rows[index][1] = Item_ID;
dtItemForDB.Rows[index][2] = int.Parse(Quantity);
dtItemForDB.Rows[index][3] = float.Parse(Unitprice);
dtItemForDB.Rows[index][4] = float.Parse(ItemPrice);
//dtItemForDB.Rows[index][5] = TxtRatePerGram.Text;
dtItemForDB.Rows[index][6] = float.Parse(Taxpercentage);
dtItemForDB.Rows[index][7] = float.Parse(Extendedprice);
dtItemForDB.Rows[index][8] = float.Parse(Discountprice);
dtItemForDB.Rows[index][9] = float.Parse(Extendedprice);
}
else
{
AddToGrid();
}
}
void FillData()
{
GridViewItems.DataSource = dtItems;
ResetItemData();
CalculateFooterData();
//SetGrid();
}
void ResetItemData()
{
TxtBarcode.Text = "";
txtCountNo.Text = "";
ItemName = "";
Quantity = "";
Unitprice = "";
ItemPrice = "";
chktaxable = "false";
Taxpercentage = "";
Extendedprice = "";
Discountprice = "";
Netprice = "";
FlagScheme = 0;
SchemeID = 0;
//stockprogressBar.Value = 0;
GridViewItems.Rows[0].Selected = false;
}
void CalculateFooterData()
{
ResetVariables();
for (int i = 0; i < dtItems.Rows.Count; i++)
{
TotalItems += int.Parse(dtItems.Rows[i]["Item_Quantity"].ToString());
//if (dtItems.Rows[i]["Item_Price"].ToString() != "")
//{
// TotalTaxableAmount += Convert.ToDecimal(dtItems.Rows[i]["Item_Price"].ToString());
//}
if (dtItems.Rows[i]["Item_Price"].ToString() != "" && dtItems.Rows[i]["Item_Unit_Price"].ToString() != "")
{
float TotItemprice = (float.Parse(dtItems.Rows[i]["Item_Quantity"].ToString()) * float.Parse(dtItems.Rows[i]["Item_Unit_Price"].ToString()));
TotalTaxableAmount += Convert.ToDecimal(TotItemprice.ToString());
}
if (dtItems.Rows[i]["Extended_Price"].ToString() != "")
{
TotalNetAmount += Convert.ToDecimal(dtItems.Rows[i]["Extended_Price"].ToString());
}
if (dtItems.Rows[i]["Discount_Price"].ToString() != "")
{
TotalDiscountAmount += Convert.ToDecimal(dtItems.Rows[i]["Discount_Price"].ToString());
}
TotalAmount = (TotalNetAmount - TotalDiscountAmount);
TotalTaxAmount = (TotalNetAmount - TotalTaxableAmount);
TotalAdjustAmount = 0;
}
TxtTotalNoOfItems = TotalItems.ToString();
TxtTotalAmount = TotalTaxableAmount.ToString("F"); //Doubt
TxtTotalTaxAmount = TotalTaxAmount.ToString("F");
TxtTotalDiscountAmount = TotalDiscountAmount.ToString("F");
TxtTotalAdjustAmount = TotalAdjustAmount.ToString("F");
TxtNetAmount = TotalNetAmount.ToString(); //Doubt
//total net amount with shiping amount
TotalNetwithship = TotalNetAmount + TotalShippingCharge;
lblGrandTotal.Text = TotalNetwithship.ToString("F");
}
void ResetVariables()
{
TotalItems = 0;
TotalAmount = 0; TotalDiscountAmount = 0; TotalTaxableAmount = 0; TotalTaxAmount = 0; TotalAdjustAmount = 0; TotalNetAmount = 0;
}
//discount
public void ApplyDiscountOnGrid()
{
int _operation = frmDiscount.StaticoperationValue;
decimal _discount = frmDiscount.StaticdiscountValue;
decimal _discountpercentage = frmDiscount.StaticDiscountPercentage;
if (_operation == 2) //% in unit price
{
float price = float.Parse(dtItems.Rows[index][5].ToString());//unitprice
_discount = Convert.ToDecimal(dtItems.Rows[index][7].ToString()) - frmDiscount.StaticdiscountValue;
//dtItems.Rows[index][7] = _discount.ToString();
// dtItems.Rows[index][5] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][2].ToString()) * Convert.ToDecimal(dtItems.Rows[index][7].ToString())), 2).ToString();
dtItems.Rows[index][5] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][2].ToString()) * Convert.ToDecimal(_discount.ToString())), 2).ToString();
dtItems.Rows[index][6] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][5].ToString()) + (Convert.ToDecimal(dtItems.Rows[index][5].ToString()) * tax) / 100), 2).ToString();
dtItems.Rows[index][9] = Math.Round((frmDiscount.StaticdiscountValue * Convert.ToDecimal(dtItems.Rows[index][2].ToString())), 2).ToString();
dtItems.Rows[index][10] = dtItems.Rows[index][6].ToString();
dtItems.Rows[index][3] = _discountpercentage.ToString();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// dtItemForDB.Rows[index][7] = _discount.ToString();
dtItemForDB.Rows[index][5] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][2].ToString()) * Convert.ToDecimal(dtItems.Rows[index][3].ToString())), 2).ToString();
dtItemForDB.Rows[index][6] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][5].ToString()) + (Convert.ToDecimal(dtItems.Rows[index][5].ToString()) * tax) / 100), 2).ToString();
dtItemForDB.Rows[index][9] = Math.Round((frmDiscount.StaticdiscountValue * Convert.ToDecimal(dtItems.Rows[index][2].ToString())), 2).ToString();
dtItemForDB.Rows[index][10] = dtItems.Rows[index][6].ToString();
dtItems.Rows[index][3] = _discountpercentage.ToString();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
}
else if (_operation == 1) //% in extended price
{
dtItems.Rows[index][9] = Math.Round(frmDiscount.StaticdiscountValue, 2).ToString();
dtItems.Rows[index][10] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][6]) - frmDiscount.StaticdiscountValue), 2).ToString();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
dtItemForDB.Rows[index][9] = Math.Round(frmDiscount.StaticdiscountValue, 2).ToString();
dtItemForDB.Rows[index][10] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][6]) - frmDiscount.StaticdiscountValue), 2).ToString();
dtItems.Rows[index][3] = _discountpercentage.ToString();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
}
else if (_operation == 3) // Amount in extended price
{
dtItems.Rows[index][9] = Math.Round(frmDiscount.StaticdiscountValue, 2).ToString();
dtItems.Rows[index][10] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][6]) - frmDiscount.StaticdiscountValue), 2).ToString();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
dtItemForDB.Rows[index][9] = Math.Round(frmDiscount.StaticdiscountValue, 2).ToString();
dtItemForDB.Rows[index][10] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][6]) - frmDiscount.StaticdiscountValue), 2).ToString();
dtItems.Rows[index][3] = _discountpercentage.ToString();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
}
else if (_operation == 4)
{
float price = float.Parse(dtItems.Rows[index][5].ToString());
//
_discount = Convert.ToDecimal(dtItems.Rows[index][5]) - frmDiscount.StaticdiscountValue;
// dtItems.Rows[index][7] = Math.Round(_discount, 2).ToString();
dtItems.Rows[index][5] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][2]) * Convert.ToDecimal(dtItems.Rows[index][3])), 2).ToString();
dtItems.Rows[index][6] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][5]) + (Convert.ToDecimal(dtItems.Rows[index][5]) * tax) / 100), 2).ToString();
dtItems.Rows[index][9] = Math.Round((frmDiscount.StaticdiscountValue * Convert.ToDecimal(dtItems.Rows[index][2])), 2).ToString();
dtItems.Rows[index][10] = dtItems.Rows[index][6];
dtItems.Rows[index][3] = _discountpercentage.ToString();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// dtItemForDB.Rows[index][7] = Math.Round(_discount, 2).ToString();
dtItemForDB.Rows[index][5] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][2]) * Convert.ToDecimal(dtItems.Rows[index][3])), 2).ToString();
dtItemForDB.Rows[index][6] = Math.Round((Convert.ToDecimal(dtItems.Rows[index][5]) + (Convert.ToDecimal(dtItems.Rows[index][5]) * tax) / 100), 2).ToString();
dtItemForDB.Rows[index][9] = Math.Round((frmDiscount.StaticdiscountValue * Convert.ToDecimal(dtItems.Rows[index][2])), 2).ToString();
dtItemForDB.Rows[index][10] = dtItems.Rows[index][6];
dtItems.Rows[index][3] = _discountpercentage.ToString();
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
}
GridViewItems.DataSource = AutoNumberedTable(dtItems);
}
//barcode event
private void btnFind_Click(object sender, EventArgs e)
{
GetProductSearch();
}
private void btnCustFind_Click(object sender, EventArgs e)
{
GetCustomerSearch();
}
private void TxtBarcode_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyValue == 13)
{
GetAllBarcodeDetails();
}
}
private void TxtBarcode_TextChanged(object sender, EventArgs e)
{
//------change image at the time of scann------
changeScanImage(TxtBarcode.Text);
if (_EditGrid == true)
{
}
else if (isEdit == true)
{
}
else if (isItemGridClick == true) { }
else if (TxtBarcode.Text.Length == 14)
{
//get focus in datagridview row
GetDatagridFocus(TxtBarcode.Text);
BarcodeMarker(TxtBarcode.Text);
GetAllBarcodeDetails();
}
if (TxtBarcode.Text.Length == 12)
{
GetCustomerbyCard(TxtBarcode.Text);
}
}
//textbox enter event for virtual keyboard
private void TxtBarcode_Enter(object sender, EventArgs e)
{
j = 1;
if (TxtBarcode.Text == string.Empty)
{
UC_virtual_keyboard.UserControl1.s = "";
changeScanImage(TxtBarcode.Text);
}
else
{
UC_virtual_keyboard.UserControl1.s = TxtBarcode.Text;
}
}
//-------get focus to search customer ------------------------
void GetDatagridFocus(string barcode)
{
for (int i = 0; i < dgvProdSearch.Rows.Count; i++)
{
if (dgvProdSearch.Rows[i].Cells["Barcode"].Value.ToString() == barcode)
{
int rowindex = dgvProdSearch.Rows[i].Cells["Barcode"].RowIndex;
//dgvProdSearch.CurrentCell = dgvProdSearch.Rows[rowindex].Cells["ItemName"];
dgvProdSearch.Rows[rowindex].Selected = true;
}
}
}
public Image NewImage(Image image, int width, int height)
{
Image resizedImage = new Bitmap(width, height);
using (Graphics graphics = Graphics.FromImage(resizedImage))
{
graphics.Clear(Color.White);
graphics.DrawImage(image, new Rectangle(0, 0, 25, 15), new Rectangle(0, 0, 25, 15), GraphicsUnit.Pixel);
}
return resizedImage;
}
private void GetIsserialImage()
{
Image img = Resources._key_board;
for (int i = 0; i < GridViewItems.Rows.Count; i++)
{
//if (GridViewItems.Rows[i].Cells["Column1"].Value.ToString() == barcode)
//{
// int rowindex = GridViewItems.Rows[i].Cells["Column1"].RowIndex;
if (GridViewItems.Rows[i].Cells["Isserial"].Value.ToString() == "True")
{
GridViewItems.Rows[i].Cells["srlimg"].Value = NewImage(img, 15, 15);
}
else
{
GridViewItems.Rows[i].Cells["srlimg"].Value = NewImage(img, 1, 1);
}
//}
//else
//{
//}
}
}
private void txtCountNo_KeyDown()
{
//iscountqty = true;
//GetAllBarcodeDetails();
//TxtBarcode.Text = "";
////focus current grid row
//if (isEdit == true)
//{
// GridViewItems.Rows[rowindex].Selected = true;
// isEdit = false;
//}
}
private void GridViewItems_RowEnter(object sender, DataGridViewCellEventArgs e)
{
GridViewItems.Rows[e.RowIndex].Selected = true;
}
frmDiscount ob = null;
private void GridViewItems_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
isItemGridClick = true;
//TxtBarcode.Text = GridViewItems.Rows[e.RowIndex].Cells["ItemBarcode"].Value.ToString();
txtCountNo.Text = GridViewItems.Rows[e.RowIndex].Cells["Item_Quantity"].Value.ToString();
//assign for popup serial page
QtyForSerialno = int.Parse(GridViewItems.Rows[e.RowIndex].Cells["Item_Quantity"].Value.ToString());
BarcodeForSerialno = GridViewItems.Rows[e.RowIndex].Cells["ItemBarcode"].Value.ToString();
isItemGridClick = false;
try
{
if (GridViewItems.CurrentCell == GridViewItems.Rows[e.RowIndex].Cells["Discount_Price"])
{
//EditGrid = true;
ob = new frmDiscount("");
try
{
TempSale t = listTempSale.Single(a => a.RowNo == e.RowIndex);
if (t != null)
ob = new frmDiscount(t.Percentage + ":" + t.Type);
}
catch { }
index = GridViewItems.CurrentRow.Index;
if (dtItems.Rows[index]["Item_Unit_Price"].ToString() != "")//change 27-02-2013
{
ob.UnitPrice = decimal.Parse(dtItems.Rows[index]["Item_Unit_Price"].ToString());
}
if (dtItems.Rows[index]["Extended_Price"].ToString() != "")
{
ob.ExtendedPrice = Convert.ToDecimal(dtItems.Rows[index]["Extended_Price"]);
}
ob.StartPosition = FormStartPosition.Manual;
ob.Location = tabDisplay.Location; //Cursor.Position;
ob.Location = new Point(ob.Location.X + this.Location.X + 5, this.Location.Y + ob.Location.Y + 25);
ob.ShowDialog();
CalculateDiscount(index);
ApplyDiscountOnGrid();
CalculateFooterData();
}
//open srial popup
try
{
if (GridViewItems.CurrentCell == GridViewItems.Rows[e.RowIndex].Cells["srlimg"])
{
frmPoupSerialNo obj = new frmPoupSerialNo();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = new Point(Cursor.Position.X, Cursor.Position.Y);
obj.ShowDialog();
}
}
catch { }
//check stock progressbar
/*
List<POS_FranchiseItemPurchase> objPO = new List<POS_FranchiseItemPurchase>();
objPO = ERPManagement.GetInstance.GetQCApproveStockQuantity();
int stockqty = 0;
objPO = objPO.Where(lst => lst.Barcode == TxtBarcode.Text).ToList();
if (objPO.Count > 0)
{
stockqty = objPO.ToList()[0].StockQuantity;
//set value here
stockprogressBar.Minimum = 0;
stockprogressBar.Maximum = 100;
stockprogressBar.Value = stockqty;
}
else
{
//set value here
stockprogressBar.Minimum = 0;
stockprogressBar.Maximum = 100;
stockprogressBar.Value = stockqty;
}*/
// BarcodeMarker(TxtBarcode.Text);
BarcodeMarker(BarcodeForSerialno);
}
catch { }
}
}
void CalculateDiscount(int rowno)
{
List<TempSale> preTemp = (from f in listTempSale
where f.RowNo != rowno
select f).ToList();
listTempSale.Clear();
TempSale obj = new TempSale();
obj.Value = frmDiscount.StaticdiscountValue.ToString();
obj.Percentage = frmDiscount.StaticDiscountPercentage.ToString();
obj.RowNo = index;
obj.Type = frmDiscount.Type;
foreach (TempSale item in preTemp) listTempSale.Add(item);
listTempSale.Add(obj);
}
List<TempSale> listTempSale = new List<TempSale>();
public class TempSale
{
public int RowNo { get; set; }
public string Value { get; set; }
public string Percentage { get; set; }
public string Type { get; set; }
}
#endregion
#region RightsideGridviewEvent
private void dgvProdSearch_DoubleClick(object sender, EventArgs e)
{
try
{
string barcode = dgvProdSearch.CurrentRow.Cells["Barcode"].Value.ToString();
Isserial = bool.Parse(dgvProdSearch.CurrentRow.Cells["Isserial"].Value.ToString());
//check row click or not
_rowclickGrid = true;
TxtBarcode.Text = dgvProdSearch.CurrentRow.Cells["Barcode"].Value.ToString();
//change normal color
txtCountNo.BackColor = System.Drawing.Color.White;
}
catch { }
}
private void dgvCustSearch_DoubleClick(object sender, EventArgs e)
{
try
{
dgvCustSearch.CurrentRow.Selected = true;
customeridshipping = int.Parse(dgvCustSearch.CurrentRow.Cells["customerid"].Value.ToString());
//GetCustomerInformation();
// GetCustomerDetailInfo(customeridshipping);
Thread thcustomer = new Thread(new ThreadStart(GetCustomerInformation));
thcustomer.IsBackground = true;
thcustomer.Start();
}
catch { }
}
private void dgvCustSearch_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
if (dgvCustSearch.Columns[e.ColumnIndex].Name.ToString() == "Edit")
{
try
{
customeridshipping = int.Parse(dgvCustSearch.Rows[e.RowIndex].Cells["customerid"].Value.ToString());
EditCustomerDetails(customeridshipping);
}
catch
{ }
GetCustomer();
}
//try
//{
// dgvCustSearch.Rows[e.RowIndex].Selected = true;
// customeridshipping = int.Parse(dgvCustSearch.Rows[e.RowIndex].Cells["customerid"].Value.ToString());
// //GetCustomerDetailInfo(customeridshipping);
// //GetCustomerInformation(customeridshipping);
// //lblcu
// lblmrp.Visible = true;
// lblbrand.Visible = true;
// lblcategory.Visible = true;
//}
//catch { }
}
}
private void dgvProdSearch_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
try
{
dgvProdSearch.Rows[e.RowIndex].Selected = true;
Barcode = dgvProdSearch.Rows[e.RowIndex].Cells["Barcode"].Value.ToString();
Itemid = int.Parse(dgvProdSearch.Rows[e.RowIndex].Cells["ItemId"].Value.ToString());
GetItemDetailInfo(Barcode);
if (GridViewItems.Rows.Count > 0)
{
GridViewItems.Rows[0].Selected = false;
}
//change normal color
txtCountNo.BackColor = System.Drawing.Color.White;
stockprogressBar.Value = 0;
//call variation details here
GetVariationProduct(Itemid);
////if (!loading)
////{
//// //if (TxtBarcode.Text.Trim() == dgvProdSearch.Rows[e.RowIndex].Cells[1].Value.ToString()) IsBarcode = true;
//// //else IsBarcode = false;
//// //TxtBarcode.Text = dgvProdSearch.Rows[e.RowIndex].Cells[1].Value.ToString();
//// //if (IsBarcode)
//// // GetAllBarcodeDetails();
//// //IsBarcode = true;
////}
}
catch
{ }
}
}
private void dgvProdSearch_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
TxtBarcode.Text = dgvProdSearch.CurrentRow.Cells[1].Value.ToString();
}
else
{
}
}
private void dgvProdSearch_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
TxtBarcode.Text = dgvProdSearch.CurrentRow.Cells[1].Value.ToString();
}
else
{
}
}
private void dgvCustSearch_KeyUp(object sender, KeyEventArgs e)
{
try
{
customeridshipping = int.Parse(dgvCustSearch.CurrentRow.Cells["customerid"].Value.ToString());
GetCustomerInformation();
}
catch { }
}
private void dgvCustSearch_KeyDown(object sender, KeyEventArgs e)
{
try
{
customeridshipping = int.Parse(dgvCustSearch.CurrentRow.Cells["customerid"].Value.ToString());
GetCustomerInformation();
}
catch { }
}
private void txtCustomerSearch_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
GetCustomerBySearch();
}
}
private void txtSearch_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
GetProductSearch();
}
}
private void txtSearch_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
if (combosearch.SelectedIndex == 0)
{
if (char.IsDigit(e.KeyChar) == false && (Keys)e.KeyChar != Keys.Back)
{
e.Handled = true;
return;
}
}
if (combosearch.SelectedIndex == 1)
{
if (char.IsDigit(e.KeyChar) == true && char.IsLetter(e.KeyChar) == false && char.IsControl(e.KeyChar) == false && e.KeyChar != '.' && e.KeyChar != ' ')
{
e.Handled = true;
return;
}
}
}
catch (Exception ex)
{
}
}
private void txtCustomerSearch_KeyPress(object sender, KeyPressEventArgs e)
{
if (cmbCustomer.Text == "By Name")
{
txtCustomerSearch.MaxLength = 50;
try
{
if (char.IsDigit(e.KeyChar) == true && char.IsLetter(e.KeyChar) == false && char.IsControl(e.KeyChar) == false && e.KeyChar != '.' && e.KeyChar != ' ')
{
e.Handled = true;
return;
}
}
catch (Exception ex)
{
}
}
if (cmbCustomer.Text == "By Phone No")
{
txtCustomerSearch.MaxLength = 14;
try
{
if (char.IsDigit(e.KeyChar) == false && (Keys)e.KeyChar != Keys.Back)
{
e.Handled = true;
return;
}
}
catch (Exception ex)
{
}
}
if (cmbCustomer.Text == "By Card No")
{
txtCustomerSearch.MaxLength = 20;
try
{
if (char.IsDigit(e.KeyChar) == false && (Keys)e.KeyChar != Keys.Back)
{
e.Handled = true;
return;
}
}
catch (Exception ex)
{
}
}
}
#endregion
#endregion
#region PagecontrolEvent
private void btnClose_Click(object sender, EventArgs e)
{
FormExit();
}
private void btnLock_Click(object sender, EventArgs e)
{
frmLockScreen fmlock = new frmLockScreen();
fmlock.ShowDialog();
}
private void btnHelp_Click(object sender, EventArgs e)
{
}
private void btnMail_Click(object sender, EventArgs e)
{
}
private void btnGroupUser_Click(object sender, EventArgs e)
{
}
private void btnChat_Click(object sender, EventArgs e)
{
}
private void btnFn_Click(object sender, EventArgs e)
{
}
private void btnKeyboard_Click(object sender, EventArgs e)
{
if (i == 0)
{
i = 1;
userControl11.Visible = true;
}
else
{
i = 0;
userControl11.Visible = false;
}
}
private void btnF1Item_Click(object sender, EventArgs e)
{
Point p = btnF1Item.Location;
p = new Point(p.X + this.Location.X, this.Location.Y + p.Y - 164);
cmItems.Show(this, this.PointToClient(p));
}
private void tsmNewItem_Click(object sender, EventArgs e)
{
}
private void tsVEItem_Click(object sender, EventArgs e)
{
}
private void tsSearchItem_Click(object sender, EventArgs e)
{
//frmSearchItem obj = new frmSearchItem();
//obj.ShowDialog();
tabDisplay.SelectedIndex = 1;
combosearch.Text = "Search";
combosearch.Enabled = true;
txtSearch.Enabled = true;
txtSearch.Focus();
}
private void tsItemNo_Click(object sender, EventArgs e)
{
tabDisplay.SelectedIndex = 1;
// combosearch.SelectedIndex = 1;
combosearch.Text = "Item";
combosearch.Enabled = true;
txtSearch.Enabled = true;
txtSearch.Focus();
}
private void tsDescription_Click(object sender, EventArgs e)
{
tabDisplay.SelectedIndex = 1;
//combosearch.SelectedIndex = 0;
combosearch.Text = "Barcode";
combosearch.Enabled = true;
txtSearch.Enabled = true;
txtSearch.Focus();
}
private void tsSubstitutes_Click(object sender, EventArgs e)
{
}
private void tsRInventory_Click(object sender, EventArgs e)
{
}
private void btnF2Customer_Click(object sender, EventArgs e)
{
Point p = btnF2Customer.Location;
p = new Point(p.X + this.Location.X, this.Location.Y + p.Y - 292);
cmCustomer.Show(this, this.PointToClient(p));
}
private void tsmNewCustomer_Click(object sender, EventArgs e)
{
AddNewCustomer();
GetCustomer();
}
private void tsmVECustomerInfo_Click(object sender, EventArgs e)
{
//frmSearchCustomer obj = new frmSearchCustomer();
// obj.ShowDialog();
if (Cust_ID > 0)
{
EditCustomerDetails(Cust_ID);
GetCustomer();
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
private void tsmSearch_Click(object sender, EventArgs e)
{
//frmSearchCustomer obj = new frmSearchCustomer("search");
//obj.Location = new Point(this.Width + this.Location.X - 333, 132);
//obj.ShowDialog();
//if (obj.CloseFor == "add") AddNewCustomer();
//else
//{
// if (obj.customerId != "") EditCustomerAllInformation(obj.customerId);
//}
tabDisplay.SelectedIndex = 2;
cmbCustomer.SelectedItem = "Select";
dgvCustSearch.DataSource = null;
txtCustomerSearch.Focus();
txtCustomerSearch.Text = "";
}
private void tsmCustomerNo_Click(object sender, EventArgs e)
{
//frmSearchCustomer obj = new frmSearchCustomer("no");
//obj.Location = new Point(this.Width + this.Location.X - 333, 132);
//obj.ShowDialog();
//if (obj.CloseFor == "add") AddNewCustomer();
//else
//{
// if (obj.customerId != "") EditCustomerAllInformation(obj.customerId);
//}
tabDisplay.SelectedIndex = 2;
cmbCustomer.SelectedItem = "By Card No";
dgvCustSearch.DataSource = null;
txtCustomerSearch.Focus();
txtCustomerSearch.Text = "";
}
private void tsmByCName_Click(object sender, EventArgs e)
{
//frmSearchCustomer obj = new frmSearchCustomer("name");
//obj.Location = new Point(this.Width + this.Location.X - 333, 132);
//obj.ShowDialog();
//if (obj.CloseFor == "add") AddNewCustomer();
//else
//{
// if (obj.customerId != "") EditCustomerAllInformation(obj.customerId);
//}
tabDisplay.SelectedIndex = 2;
cmbCustomer.SelectedItem = "By Name";
dgvCustSearch.DataSource = null;
txtCustomerSearch.Focus();
txtCustomerSearch.Text = "";
}
private void tsmCphoneNo_Click(object sender, EventArgs e)
{
//frmSearchCustomer obj = new frmSearchCustomer("phone");
//obj.Location = new Point(this.Width + this.Location.X - 333, 132);
//obj.ShowDialog();
//if (obj.CloseFor == "add") AddNewCustomer();
//else
//{
// if (obj.customerId != "") EditCustomerAllInformation(obj.customerId);
//}
tabDisplay.SelectedIndex = 2;
cmbCustomer.SelectedItem = "By Phone No";
dgvCustSearch.DataSource = null;
txtCustomerSearch.Focus();
txtCustomerSearch.Text = "";
}
private void tsmShippingAddress_Click(object sender, EventArgs e)
{
EditCustomerDetails();
}
private void tsmCClear_Click(object sender, EventArgs e)
{
ClearCustomer();
}
private void tsmMakePayment_Click(object sender, EventArgs e)
{
//frmPayments obj = new frmPayments();
//obj.ShowDialog();
}
private void btnF3Transaction_Click(object sender, EventArgs e)
{
Point p = btnF3Transaction.Location;
p = new Point(p.X + this.Location.X, this.Location.Y + p.Y - 250);
cmTransactionMenu.Show(this, this.PointToClient(p));
}
private void tsmEditTransction_Click(object sender, EventArgs e)
{
}
private void tsmEditLineItem_Click(object sender, EventArgs e)
{
EditGridLineItem();
}
private void tsmRemoveLineI_Click(object sender, EventArgs e)
{
RemoveGridLineItem();
}
private void tsmHold_Click_1(object sender, EventArgs e)
{
if (GridViewItems.Rows.Count > 0)
{
HoldTransaction();
}
else
{
MessageBox.Show("No Item for sale!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 0;
}
//if (dgvCustSearch.SelectedRows.Count > 0)
//{
// SaveData();
// MessageBox.Show("Data Hold Successfully", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
// //call auto invoiceno
// GetAutoInvoiceNo();
// GetTotalSale();
// GetOnHoldSale();
// GetProduct();
// //ResetForm
// ResetForm();
// //clear control
// TxtBarcode.Text = "";
// txtCountNo.Text = "";
//}
//else
//{
// MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// tabDisplay.SelectedIndex = 1;
//}
}
private void tsmRecallTrans_Click(object sender, EventArgs e)
{
Point p = GridViewItems.Location;
p = new Point(GridViewItems.Location.X + this.Location.X + 7, p.Y + 126);
frmViewSale obj = new frmViewSale("0");
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
obj.Location = new Point(p.X, p.Y);
obj.ShowDialog();
SaleId = obj.saleid;
//set saleid to maxsaleid for complee transaction bcoz maxsaleid pass to paymentsell page
maxsaleid = SaleId.ToString();
if (SaleId != 0)
{
GetSaleData();
GetSaleDetails();
GetSaleCustomer();
}
//btnF11Total.Enabled = true;
}
private void tsmCancelTrans_Click(object sender, EventArgs e)
{
try
{
btnmode = "CANCEL";
if ((GridViewItems.Rows.Count > 0) && isInvoice == false)
{
CancelTransaction();
}
else
{
MessageBox.Show("No Item for cancel!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 1;
}
btnmode = "";
}
catch { }
}
private void tsmNoSale_Click(object sender, EventArgs e)
{
}
private void btnF4Tasks_Click(object sender, EventArgs e)
{
Point p = btnF4Tasks.Location;
p = new Point(p.X + this.Location.X, this.Location.Y + p.Y - 260);
cmTaskMenuOptions.Show(this, this.PointToClient(p));
}
private void tsmOpenClose_Click(object sender, EventArgs e)
{
}
private void tsmDropPayout_Click(object sender, EventArgs e)
{
}
private void tsmFindReceipts_Click(object sender, EventArgs e)
{
frmReprintlastrcpt obj = new frmReprintlastrcpt();
obj.Location = Cursor.Position;
//obj.Location = new Point(obj.Location.X, obj.Location.Y - 432);
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
}
private void tsmReprintLR_Click(object sender, EventArgs e)
{
frmReprintlastrcpt obj = new frmReprintlastrcpt();
obj.Location = Cursor.Position;
//obj.Location = new Point(obj.Location.X, obj.Location.Y - 432);
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
}
private void tsmPrinterOff_Click(object sender, EventArgs e)
{
}
private void tsmVoid_Click(object sender, EventArgs e)
{
}
private void tsmVoucher_Click(object sender, EventArgs e)
{
}
private void tsmSwitchUserExit_Click(object sender, EventArgs e)
{
FormExit();
}
private void btnF5Tools_Click(object sender, EventArgs e)
{
Point p = btnF5Tools.Location;
p = new Point(p.X + this.Location.X, this.Location.Y + p.Y - 292);
cmToolsMenuOption.Show(this, this.PointToClient(p));
}
private void tsmCalculator_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("calc.exe");
}
private void tsmTimeClock_Click(object sender, EventArgs e)
{
frmTimeClock obj = new frmTimeClock();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
}
private void tsmGraphs_Click(object sender, EventArgs e)
{
}
private void tsmCurrency_Click(object sender, EventArgs e)
{
frmCurrencyConvertor obj = new frmCurrencyConvertor();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
}
private void tsmFind_Click(object sender, EventArgs e)
{
FrmFind obj = new FrmFind();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
int statusvalue = obj.status;
if (statusvalue == 1)
{
FindItem();
}
if (statusvalue == 2)
{
FindCustomer();
}
if (statusvalue == 3)
{
Transaction("O");
}
if (statusvalue == 4)
{
GetQuotationDetails();
}
if (statusvalue == 5)
{
GetHoldItemDetails();
}
if (statusvalue == 6)
{
GetInvoiceDetails();
}
}
private void tsmEPracticeMode_Click(object sender, EventArgs e)
{
}
private void tsmSystem_Click(object sender, EventArgs e)
{
}
private void tsmManagerView_Click(object sender, EventArgs e)
{
}
private void btnF6Return_Click(object sender, EventArgs e)
{
Point p = btnF6Return.Location;
p = new Point(p.X + this.Location.X, this.Location.Y + p.Y - 100);
cmReturnMenu.Show(this, this.PointToClient(p));
}
private void tsmByReciept_Click(object sender, EventArgs e)
{
}
private void tsmRmCustomer_Click(object sender, EventArgs e)
{
}
private void tsmEReturnMode_Click(object sender, EventArgs e)
{
}
private bool CheckSerialno()
{
// string grditembarcode,serial="";
for (int i = 0; i < GridViewItems.Rows.Count; i++)
{
if (GridViewItems.Rows[i].Cells["Isserial"].Value.ToString() == "True")
{
BarcodeForSerialno = GridViewItems.Rows[i].Cells["ItemBarcode"].Value.ToString();
QtyForSerialno = int.Parse(GridViewItems.Rows[i].Cells["Item_Quantity"].Value.ToString());
//check
bool contains = frmPoupSerialNo.dtSerialNo.AsEnumerable()
.Any(row => BarcodeForSerialno == row.Field<String>("Barcode"));
if (contains == false)
{
frmPoupSerialNo obj = new frmPoupSerialNo();
obj.StartPosition = FormStartPosition.Manual;
//obj.Location = new Point(Cursor.Position.X, Cursor.Position.Y);
obj.Location = GridViewItems.PointToScreen(GridViewItems.GetCellDisplayRectangle(4, i, false).Location);
//GridViewItems.Rows[i].Cells["Isserial"]
obj.ShowDialog();
return false;
}
}
}
return true;
}
private void btnF11Total_Click(object sender, EventArgs e)
{
if (GridViewItems.Rows.Count > 0)
{
// if ((dgvCustSearch.SelectedRows.Count > 0) || Cust_ID > 0)
if (Cust_ID > 0)
{
//check serial no entry or not
if (purpose.ToLower() == "s" || purpose.ToLower() == "ss")
{
if (CheckSerialno() == false)
{
return;
}
}
//------------------
if (SaleId > 0)
{
UpdateData();
}
else
{
SaveData();
}
//SaveData();
if (purpose.ToLower() == "s" || purpose.ToLower() == "ss")
{
frmPaymentSell obj = new frmPaymentSell(this);
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
// obj.Location = new Point(obj.Location.X + this.Location.X + 100, 130);
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
if (obj.PayStatus == "P")
{
ResetForm();
//call auto invoiceno
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
//GetCustomer();
tabDisplay.SelectedIndex = 0;
}
else if (obj.PayStatus == "C")
{
}
}
else
{
// MessageBox.Show("Data Saved Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (purpose == "O")
{
MessageBox.Show("Order Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (purpose == "Q")
{
MessageBox.Show("Quotation Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (purpose == "C")
{
MessageBox.Show("Cancel Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (purpose == "F")
{
return;
}
ResetForm();
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
GetCustomer();
tabDisplay.SelectedIndex = 0;
}
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
else
{
MessageBox.Show("No Item for sale!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 1;
}
}
private void btnOrders_Click(object sender, EventArgs e)
{
Transaction("O");
}
private void btnInvoices_Click(object sender, EventArgs e)
{
GetInvoiceDetails();
}
private void btnNewSales_Click(object sender, EventArgs e)
{
EnableControl();
CurrentDate();
btnF11Total.BackgroundImage = Resources.n_total;
if ((GridViewItems.Rows.Count > 0) && isInvoice == false)
{
ConfirmpopFunctionality();
}
else
{
ResetForm();
lblHeader1.Text = "";
lblHeader1.Text = "Sale Invoices No." + AutoinvoiceNo;
popupimgpurpose = "S";
purpose = "S";
chkstockpurpose = "S";
//reset invoice button click
isInvoice = false;
tabDisplay.SelectedIndex = 1;
}
}
private void btnNewQuotes_Click(object sender, EventArgs e)
{
EnableControl();
CurrentDate();
btnF11Total.BackgroundImage = Resources.saveF11;
if ((GridViewItems.Rows.Count > 0) && isInvoice == false)
{
ConfirmpopFunctionality();
}
else
{
ResetForm();
lblHeader1.Text = "";
lblHeader1.Text = "Quote No." + AutoinvoiceNo;
popupimgpurpose = "Q";
purpose = "Q";
chkstockpurpose = "Q";
//reset invoice button click
isInvoice = false;
tabDisplay.SelectedIndex = 1;
}
}
private void btnNewOrder_Click(object sender, EventArgs e)
{
EnableControl();
CurrentDate();
btnF11Total.BackgroundImage = Resources.saveF11;
if ((GridViewItems.Rows.Count > 0) && isInvoice == false)
{
ConfirmpopFunctionality();
}
else
{
ResetForm();
lblHeader1.Text = "";
popupimgpurpose = "O";
purpose = "O";
chkstockpurpose = "O";
lblHeader1.Text = "Order No." + AutoinvoiceNo;
//reset invoice button click
isInvoice = false;
tabDisplay.SelectedIndex = 1;
}
}
private void pbUpSale_Click(object sender, EventArgs e)
{
frmForOrderQuoteSales objFOQS = new frmForOrderQuoteSales(this);
objFOQS.StartPosition = FormStartPosition.Manual;
// obj.Location = Cursor.Position;
objFOQS.Location = new Point(btnTransactionHistory.Location.X + this.Location.X, btnTransactionHistory.Location.Y + this.Location.Y);
objFOQS.ShowDialog();
}
#endregion
private void pbPlus_Click(object sender, EventArgs e)
{
if (GridViewItems.Rows.Count > 0)
{
if (GridViewItems.SelectedRows.Count > 0)
{
GetNuremicpad();
}
else
{
MessageBox.Show("Select one Item!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
private bool CheckStock()
{
if (purpose == "C")
{
return true;
}
else
{
for (int i = 0; i < dtItems.Rows.Count; i++)
{
string barcode = dtItems.Rows[i]["BarCode"].ToString();
int Itemqty = int.Parse(dtItems.Rows[i]["Item_Quantity"].ToString());
string ItemName = dtItems.Rows[i]["ItemName"].ToString();
List<POS_FranchiseItemPurchase> objPO = new List<POS_FranchiseItemPurchase>();
objPO = ERPManagement.GetInstance.GetQCApproveStockQuantity();
objPO = objPO.Where(lst => lst.Barcode == barcode).ToList();
if (objPO.Count > 0)
{
int stockqty = objPO.ToList()[0].StockQuantity;
if (Itemqty > stockqty)
{
msgstock += Environment.NewLine + ItemName;
foreach (DataGridViewRow dgvr in GridViewItems.Rows)
{
if (dgvr.Cells["ItemBarcode"].Value.ToString() == barcode)
{
dgvr.DefaultCellStyle.BackColor = Color.Thistle;
}
}
// MessageBox.Show("Stock not available!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
if (msgstock.Length > 0)
{
return false;
}
else
{
//reset purpose default value after check stock
purpose = chkstockpurpose;
return true;
}
}
}
private void SaveData()
{
//create default datatable if not in popupserial no
SerialDatatable();
if (CheckStock() == true)
{
try
{
POS_PointOfSale obj = new POS_PointOfSale();
ResetVariables();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for (int i = 0; i < dtItems.Rows.Count; i++)
{
TotalItems += int.Parse(dtItems.Rows[i]["Item_Quantity"].ToString());
TotalTaxableAmount += Convert.ToDecimal(dtItems.Rows[i]["Item_Price"].ToString());
TotalNetAmount += Convert.ToDecimal(dtItems.Rows[i]["Extended_Price"].ToString());
TotalDiscountAmount += Convert.ToDecimal(dtItems.Rows[i]["Discount_Price"].ToString());
TotalAmount += (TotalNetAmount - TotalDiscountAmount);
TotalTaxAmount += (TotalNetAmount - TotalTaxableAmount);
TotalAdjustAmount = 0;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
obj.Sale_Employee_ID = userid; //Will be update after login
obj.Customer_ID = Cust_ID;
obj.Sale_Invoice_Date = DateTime.ParseExact(lblcurrentdate.Text, "M/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
//if (ChkIsAgainstAdvance.Checked)
//{
// obj.Is_Against_Advance = true;
// //obj.Advance_Invoice_No = TxtIsAgainstAdvance.Text;
// obj.Advance_Invoice_No = cmbAdvanced.Text;
//}
//else
//{
// obj.Is_Against_Advance = false;
//}
obj.Is_Against_Advance = false;
obj.Total_No_Of_Items = TotalItems;//
obj.Total_Amount = TotalAmount;//
obj.Total_Discount_Amount = TotalDiscountAmount;//
obj.Total_Taxable_Amount = TotalTaxableAmount;//
obj.Total_Tax_Amount = TotalTaxAmount;//
obj.Total_Adjust_Amount = TotalAdjustAmount;//
obj.Total_Net_Amount = TotalNetAmount;//
obj.DataTableItemSaleDetails = dtItemForDB;
obj.DMLOperation = 1;
obj.DataTableItemSaleSerial = dtserial;// frmPoupSerialNo.dtSerialNo;
obj.Payment_Amount = Decimal.Parse(lblGrandTotal.Text);
obj.FunctionalStatus = purpose;
obj.TranctionStatus = 1;//commit in fisrt time not cancel
obj.PaymentStatus = 0;//paystatus false in firsttime
string ReturnVal = ERPManagement.GetInstance.InsertSales(obj);
string[] Val = ReturnVal.Split('@');
TxtInvoiceNumber = Val[0];
TxtNet = Val[1];
maxsaleid = Val[1];
SaleId = int.Parse(Val[1]);
EditInvoiceNumber = Val[0];
// MessageBox.Show("Data Saved Successfully with Invoice No: " + TxtInvoiceNumber, "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
catch { }
}
else
{
//set defalut purpose to assign variable
chkstockpurpose = purpose;
//set purpose false for not enter to payment or order or qutation
purpose = "F";
MessageBox.Show("Required stock not available for marked item!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
msgstock = "";
}
}
private void UpdateData()
{
//create default datatable if not in popupserial no
SerialDatatable();
if (CheckStock() == true)
{
try
{
POS_PointOfSale obj = new POS_PointOfSale();
ResetVariables();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for (int i = 0; i < dtItems.Rows.Count; i++)
{
TotalItems += int.Parse(dtItems.Rows[i]["Item_Quantity"].ToString());
TotalTaxableAmount += Convert.ToDecimal(dtItems.Rows[i]["Item_Price"].ToString());
TotalNetAmount += Convert.ToDecimal(dtItems.Rows[i]["Extended_Price"].ToString());
TotalDiscountAmount += Convert.ToDecimal(dtItems.Rows[i]["Discount_Price"].ToString());
TotalAmount += (TotalNetAmount - TotalDiscountAmount);
TotalTaxAmount += (TotalNetAmount - TotalTaxableAmount);
TotalAdjustAmount = 0;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
obj.Sale_Employee_ID = userid; //Will be update after login
obj.Customer_ID = Cust_ID;
obj.Sale_Invoice_Date = DateTime.Parse(lblcurrentdate.Text);
//if (ChkIsAgainstAdvance.Checked)
//{
// obj.Is_Against_Advance = true;
// //obj.Advance_Invoice_No = TxtIsAgainstAdvance.Text;
// obj.Advance_Invoice_No = cmbAdvanced.Text;
//}
//else
//{
// obj.Is_Against_Advance = false;
//}
obj.Sale_ID = SaleId;
obj.Sale_Invoice_No = EditInvoiceNumber.ToString();
obj.Is_Against_Advance = false;
obj.Total_No_Of_Items = TotalItems;//
obj.Total_Amount = TotalAmount;//
obj.Total_Discount_Amount = TotalDiscountAmount;//
obj.Total_Taxable_Amount = TotalTaxableAmount;//
obj.Total_Tax_Amount = TotalTaxAmount;//
obj.Total_Adjust_Amount = TotalAdjustAmount;//
obj.Total_Net_Amount = TotalNetAmount;//
obj.DataTableItemSaleDetails = dtItemForDB;
obj.DataTableItemSaleSerial = dtserial;// frmPoupSerialNo.dtSerialNo;
obj.DMLOperation = 2;
obj.Payment_Amount = Decimal.Parse(lblGrandTotal.Text);
obj.FunctionalStatus = purpose;
obj.TranctionStatus = 1;//commit in fisrt time not cancel
obj.PaymentStatus = 0;//paystatus false in firsttime
string ReturnVal = ERPManagement.GetInstance.InsertSales(obj);
//string[] Val = ReturnVal.Split('@');
//TxtInvoiceNumber = Val[0];
//TxtNet = Val[1];
//maxsaleid = Val[1];
// MessageBox.Show("Data Saved Successfully with Invoice No: " + TxtInvoiceNumber, "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
catch { }
}
else
{
//set defalut purpose to assign variable
chkstockpurpose = purpose;
//set purpose false for not enter to payment or order or qutation
purpose = "F";
MessageBox.Show("Required stock not available for marked item!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
msgstock = "";
}
}
#region Method for FIND Page
public void FindItem()
{
tabDisplay.SelectedIndex = 1;
combosearch.Text = "Search";
combosearch.Enabled = true;
txtSearch.Enabled = true;
txtSearch.Focus();
}
public void FindCustomer()
{
tabDisplay.SelectedIndex = 2;
cmbCustomer.Text = "Search";
cmbCustomer.Enabled = true;
txtCustomerSearch.Enabled = true;
txtCustomerSearch.Focus();
}
public void GetHoldItemDetails()
{
FrmFind obj1 = new FrmFind();
obj1.Close();
Point p = GridViewItems.Location;
p = new Point(GridViewItems.Location.X + this.Location.X + 7, p.Y + 126);
frmViewSale obj = new frmViewSale("0");
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
obj.Location = new Point(p.X, p.Y);
obj.ShowDialog();
SaleId = obj.saleid;
//set saleid to maxsaleid for complee transaction bcoz maxsaleid pass to paymentsell page
maxsaleid = SaleId.ToString();
if (SaleId != 0)
{
GetSaleData();
GetSaleDetails();
GetSaleCustomer();
}
}
public void GetQuotationDetails()
{
try
{
FrmFind obj1 = new FrmFind();
obj1.Close();
EnableControl();
ResetForm();
Point p = GridViewItems.Location;
p = new Point(GridViewItems.Location.X + this.Location.X + 7, p.Y + 126);
frmViewSale obj = new frmViewSale("Q");
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
obj.Location = new Point(p.X, p.Y);
obj.ShowDialog();
SaleId = obj.saleid;
//set saleid to maxsaleid for complee transaction bcoz maxsaleid pass to paymentsell page
maxsaleid = SaleId.ToString();
if (SaleId != 0)
{
GetSaleData();
GetSaleDetails();
GetSaleCustomer();
//false gridview line focus
GridViewItems.Rows[0].Selected = false;
stockprogressBar.Value = 0;
}
else
{
ResetForm();
GetAutoInvoiceNo();
}
}
catch
{
}
}
#endregion
#region EditRecord
private void GetSaleData()
{
DataTable dtsale = new DataTable();
dtsale = ERPManagement.GetInstance.GetSale(SaleId);
if (dtsale.Rows.Count > 0)
{
string functionalstatus = dtsale.Rows[0]["Functional_Status"].ToString();
EditInvoiceNumber = dtsale.Rows[0]["Sale_Invoice_No"].ToString();
if (functionalstatus == "S")
{
purpose = "S";
chkstockpurpose = "S";
lblHeader1.Text = "Sale Invoices No." + dtsale.Rows[0]["Sale_Invoice_No"].ToString();
}
if (functionalstatus == "O")
{
purpose = "O";
chkstockpurpose = "O";
lblHeader1.Text = "Order No." + dtsale.Rows[0]["Sale_Invoice_No"].ToString();
}
if (functionalstatus == "Q")
{
purpose = "Q";
chkstockpurpose = "Q";
lblHeader1.Text = "Quote No." + dtsale.Rows[0]["Sale_Invoice_No"].ToString();
}
// lblDate.Text = dtsale.Rows[0]["Invoice_Date"].ToString();
lblcurrentdate.Text = dtsale.Rows[0]["Invoice_Date"].ToString();
DateTime editdate = DateTime.Parse(lblcurrentdate.Text);
lblHeader3.Text = string.Format("{0:f}", editdate);
// lblHeader3.Text = string.Format("{0:dd/MM/yyyy}",editdate);
}
}
private void GetSaleDetails()
{
dtItems.Rows.Clear();
dtItemForDB.Rows.Clear();
DataTable dtsale = new DataTable();
dtsale = ERPManagement.GetInstance.GetSaleDetails(SaleId);
if (dtsale.Rows.Count > 0)
{
for (int i = 0; i < dtsale.Rows.Count; i++)
{
DataRow row = dtItems.NewRow();
DataRow row2 = dtItemForDB.NewRow();
if (dtsale.Rows[i]["Barcode"].ToString() != "")
{
row[0] = dtsale.Rows[i]["Barcode"].ToString();
row2[0] = dtsale.Rows[i]["Barcode"].ToString();
}
if (dtsale.Rows[i]["Item_Name"].ToString() != "")
{
row[1] = dtsale.Rows[i]["Item_Name"].ToString();
row2[1] = dtsale.Rows[i]["Item_ID"].ToString();
}
if (dtsale.Rows[i]["Item_Quantity"].ToString() != "")
{
row[2] = int.Parse(dtsale.Rows[i]["Item_Quantity"].ToString());
row2[2] = int.Parse(dtsale.Rows[i]["Item_Quantity"].ToString());
}
if (dtsale.Rows[i]["Discount_Percent"].ToString() != "")
{
row[3] = float.Parse(dtsale.Rows[i]["Discount_Percent"].ToString());
row2[3] = float.Parse(dtsale.Rows[i]["Discount_Percent"].ToString());
}
if (dtsale.Rows[i]["Is_Taxable"].ToString() == "True")
{
row[4] = true;
row[8] = float.Parse(dtsale.Rows[i]["Tax_Percent"].ToString());
row2[4] = true;
row2[8] = float.Parse(dtsale.Rows[i]["Tax_Percent"].ToString());
}
else
{
row[4] = false;
row[8] = i;
row2[4] = false;
row2[8] = i;
}
if (dtsale.Rows[i]["Item_Price"].ToString() != "")
{
row[5] = float.Parse(dtsale.Rows[i]["Item_Price"].ToString());
row2[5] = float.Parse(dtsale.Rows[i]["Item_Price"].ToString());
}
if (dtsale.Rows[i]["Extended_Price"].ToString() != "")
{
row[6] = float.Parse(dtsale.Rows[i]["Extended_Price"].ToString()).ToString("f");
row2[6] = float.Parse(dtsale.Rows[i]["Extended_Price"].ToString()).ToString("f");
}
if (dtsale.Rows[i]["Item_Unit_Price"].ToString() != "")
{
row[7] = float.Parse(dtsale.Rows[i]["Item_Unit_Price"].ToString());
row2[7] = float.Parse(dtsale.Rows[i]["Item_Unit_Price"].ToString());
}
if (dtsale.Rows[i]["Discount_Price"].ToString() != "")
{
row[9] = float.Parse(dtsale.Rows[i]["Discount_Price"].ToString()).ToString("f");
row2[9] = float.Parse(dtsale.Rows[i]["Discount_Price"].ToString()).ToString("f");
}
if (dtsale.Rows[i]["Extended_Price"].ToString() != "")
{
row[10] = float.Parse(dtsale.Rows[i]["Extended_Price"].ToString()).ToString("f");
row2[10] = float.Parse(dtsale.Rows[i]["Extended_Price"].ToString()).ToString("f");
}
if (dtsale.Rows[i]["Needs_Serial"].ToString() != "")
{
row[12] = bool.Parse(dtsale.Rows[i]["Needs_Serial"].ToString());
}
row[11] = 0;
dtItems.Rows.Add(row);
dtItemForDB.Rows.Add(row2);
GridViewItems.DataSource = AutoNumberedTable(dtItems);
CalculateFooterData();
//call image for serial
GetIsserialImage();
BlockItemColumn();
GridViewItems.Rows[0].Selected = false;
}
}
else
{
dtItemForDB.Clear();
dtItems.Rows.Clear();
GridViewItems.DataSource = AutoNumberedTable(dtItems);
}
}
private void GetSaleCustomer()
{
DataTable dtsale = new DataTable();
dtsale = ERPManagement.GetInstance.GetSaleCustomer(SaleId);
if (dtsale.Rows.Count > 0)
{
Cust_ID = int.Parse(dtsale.Rows[0]["Customer_ID"].ToString());
if (dtsale.Rows[0]["Img_Photo"].ToString() != "")
{
byte[] bt = (byte[])dtsale.Rows[0]["Img_Photo"];
MemoryStream ms = new MemoryStream(bt);
pbCustomerImage.Image = Image.FromStream(ms);
}
else
{
pbCustomerImage.Image = POS.Properties.Resources._user_icon;
}
lblCustomerName.Text = dtsale.Rows[0]["Customer_Name"].ToString();
//lblCustlevel.Text = dtsale.Rows[0]["Loyalty_Card_No"].ToString();
lblCustIdNo.Text = dtsale.Rows[0]["Loyalty_Card_No"].ToString();
//lblCustAddress.Text = dtsale.Rows[0]["Address"].ToString();
lblLastVisit.Text = "Last Visit : " + dtsale.Rows[0]["Last_Visit_Date"].ToString();
lblTotalVisits.Text = "Total Visit : " + dtsale.Rows[0]["Total_Visit"].ToString();
lblTotalSales.Text = "Total Sale : " + dtsale.Rows[0]["Total_Sale"].ToString();
lblPhone.Text = "Phone : " + dtsale.Rows[0]["Mobile_No"].ToString();
}
}
#endregion
private void btnTasks_Click(object sender, EventArgs e)
{
}
private void btnF1Item_MouseLeave()
{
try
{
if (pbLastAccess != null)
{
switch (pbLastAccess.Name)
{
case "btnF1Item": cmItems.Close(); break;
case "btnF2Customer": cmCustomer.Close(); break;
case "btnF3Transaction": cmTransactionMenu.Close(); break;
case "btnF4Tasks": cmTaskMenuOptions.Close(); break;
case "btnF5Tools": cmToolsMenuOption.Close(); break;
case "btnF6Return": cmReturnMenu.Close(); break;
}
}
}
catch { }
}
#region Customer Operation
//private void linkPurchaseHistory_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
//{
// //frmViewSale obj = new frmViewSale("C");
// //obj.ShowDialog();
// Point p = GridViewItems.Location;
// p = new Point(GridViewItems.Location.X + this.Location.X, p.Y + 120);
// frmViewSale obj = new frmViewSale("C");
// obj.StartPosition = FormStartPosition.Manual;
// obj.Location = btnF11Total.Location; //Cursor.Position;
// obj.Location = new Point(p.X, p.Y);
// obj.ShowDialog();
// SaleId = frmViewSale.saleid;
// //set saleid to maxsaleid for complee transaction bcoz maxsaleid pass to paymentsell page
// maxsaleid = SaleId.ToString();
// if (SaleId != 0)
// {
// GetSaleData();
// GetSaleDetails();
// GetSaleCustomer();
// }
//}
private void linkClearCustomer_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (MessageBox.Show("Do you want to delete ?", "kenCloud", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int ModifiedBy = 10;
ERPManagement.GetInstance.DeleteCustomer(Cust_ID, ModifiedBy);
MessageBox.Show("Data Delete Successfully", "kenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
GetCustomer();
Cust_ID = 0;
}
}
private void linkCustomerDetails_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
EditCustomerDetails(Cust_ID);
}
private void EditCustomerDetails(int Cust_ID)
{
frmCustomer customer = new frmCustomer();
customer.StartPosition = FormStartPosition.Manual;
customer.Location = new Point(this.Width + this.Location.X - 333, 7);
Control[] ID = customer.Controls.Find("HdnField", true);
//int Customer_ID = Cust_ID;
//List<POS_Customer> Customers = new List<POS_Customer>();
//Customers = ERPManagement.GetInstance.SelectCustomers();
//var CustomerDet = from cust in Customers
// where cust.Customer_ID == Customer_ID
// select cust;
//if (CustomerDet.Count() > 0)
//{
// ID[0].Text = CustomerDet.ToList()[0].Customer_ID.ToString();
//}
ID[0].Text = Cust_ID.ToString();
customer.ShowDialog();
}
#endregion Customer Operation
private void messageToolStripMenuItem_Click(object sender, EventArgs e)
{
d_Message obj = new d_Message();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
}
#region CODE FOR CUSTOMER SEARCH
// =====================CODE FOR CUSTOMER SEARCH BY NAME,CARNO,PHONE NO.=================
public void CustomerButtonDisable()
{
btnPurchaseHistory.Enabled = false;
btnClearHistory.Enabled = false;
btnCustomerDetails.Enabled = false;
btnAddShipping.Enabled = false;
btnSelectAddress.Enabled = false;
btnClearAddress.Enabled = false;
}
public void CustomerButtonEnable()
{
btnPurchaseHistory.Enabled = true;
btnClearHistory.Enabled = true;
btnCustomerDetails.Enabled = true;
btnAddShipping.Enabled = true;
btnSelectAddress.Enabled = true;
btnClearAddress.Enabled = true;
}
private void pbCustomer_Click(object sender, EventArgs e)
{
if (txtCustomerSearch.Text == "")
{
//MessageBox.Show("Please enter in search field !", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
GetCustomer();
}
else
{
GetCustomerBySearch();
}
}
private void linkClearCustomer_LinkClicked(object sender, EventArgs e)
{
ClearCustomer();
}
private void linkCustomerDetails_LinkClicked(object sender, EventArgs e)
{
EditCustomerDetails();
}
private void linkPurchaseHistory_LinkClicked(object sender, EventArgs e)
{
frmViewSale obj = new frmViewSale("C");
// if ((Cust_ID > 0) || (dgvCustSearch.SelectedRows.Count > 0))
if (Cust_ID > 0)
{
Point p = GridViewItems.Location;
p = new Point(GridViewItems.Location.X + this.Location.X + 7, p.Y + 126);
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
obj.Location = new Point(p.X, p.Y);
obj.ShowDialog();
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
SaleId = obj.saleid;
//set saleid to maxsaleid for complee transaction bcoz maxsaleid pass to paymentsell page
maxsaleid = SaleId.ToString();
if (SaleId != 0)
{
GetSaleData();
GetSaleDetails();
GetSaleCustomer();
//DisableControl();
}
else
{
EnableControl();
}
}
private void btnNewCustomer_Click(object sender, EventArgs e)
{
//Point p = tabDisplay.Location;
//p = new Point(p.X + this.Location.X + 5, this.Location.Y + p.Y + 25);
//frmPopUpCustomer customer = new frmPopUpCustomer();
//customer.StartPosition = FormStartPosition.Manual;
//customer.Location = new Point(p.X, p.Y);
//customer.ShowDialog();
//customer.Close();
frmCustomer obj = new frmCustomer();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = new Point(this.Width + this.Location.X - 333, 7);
obj.ShowDialog();
obj.Close();
GetCustomer();
}
private void btnDeleteCustomer_Click(object sender, EventArgs e)
{
if (dgvCustSearch.Rows.Count > 0)
{
// if (dgvCustSearch.SelectedRows.Count > 0)
if (Cust_ID > 0)
{
DialogResult dr = MessageBox.Show("Are you sure want to delete selected Customer.", "KenCloud", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr.ToString() == "OK")
{
foreach (DataGridViewRow row in dgvCustSearch.Rows)
{
if (row.Selected == true)
{
// row is selected
dgvCustSearch.Columns["customerid"].Visible = false;
customerid = int.Parse(row.Cells["customerid"].Value.ToString());
ERPManagement.GetInstance.DeleteCustomer(customerid, 1);
GetCustomer();
}
else { }
}
}
}
else
{
MessageBox.Show("Please select a Customer for Delete!", "KenCloud", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
}
}
}
private void btnConvertSTO_Click(object sender, EventArgs e)
{
if (GridViewItems.Rows.Count > 0)
{
if (purpose.ToLower() != "s" && purpose.ToLower() != "ss")
{
Point p = btnConvertSTO.Location;
if (purpose.ToLower() == "q" || purpose.ToLower() == "qs")
{
tsmOrder.Visible = true;
p = new Point(p.X + this.Location.X, this.Location.Y + p.Y - 50);
}
else
{
tsmOrder.Visible = false;
p = new Point(p.X + this.Location.X, this.Location.Y + p.Y - 28);
}
cmConvert.Show(this, this.PointToClient(p));
}
}
}
private void tsmSale_Click(object sender, EventArgs e)
{
try
{
purpose = "S";
chkstockpurpose = "S";
if (GridViewItems.Rows.Count > 0)
{
//if ((Cust_ID > 0) || (dgvCustSearch.SelectedRows.Count > 0))
if (Cust_ID > 0)
{
//check serial no entry or not
if (purpose.ToLower() == "s" || purpose.ToLower() == "ss")
{
if (CheckSerialno() == false)
{
purpose = "O";
return;
}
}
//------------------
if (SaleId > 0)
{
UpdateData();
}
else
{
SaveData();
}
//SaveData();
if (purpose.ToLower() == "s" || purpose.ToLower() == "ss")
{
frmPaymentSell obj = new frmPaymentSell(this);
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
// obj.Location = new Point(obj.Location.X + this.Location.X + 100, 130);
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
if (obj.PayStatus == "P")
{
ResetForm();
//call auto invoiceno
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
//GetCustomer();
tabDisplay.TabIndex = 0;
}
else if (obj.PayStatus == "C")
{
}
}
else if (purpose == "F")
{
}
else
{
ResetForm();
}
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
else
{
MessageBox.Show("No Item for sale!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 1;
}
}
catch (Exception ex)
{ }
}
private void tsmOrder_Click(object sender, EventArgs e)
{
try
{
if (GridViewItems.Rows.Count > 0)
{
//if ((Cust_ID > 0) || (dgvCustSearch.SelectedRows.Count > 0))
if (Cust_ID > 0)
{
purpose = "O";
if (SaleId > 0)
{
UpdateData();
}
else
{
SaveData();
}
MessageBox.Show("Data Order Successfully ", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Information);
//SaveData();
if (purpose.ToLower() == "s" || purpose.ToLower() == "ss")
{
frmPaymentSell obj = new frmPaymentSell(this);
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
// obj.Location = new Point(obj.Location.X + this.Location.X + 100, 130);
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
if (obj.PayStatus == "P")
{
ResetForm();
//call auto invoiceno
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
//GetCustomer();
tabDisplay.TabIndex = 0;
}
else if (obj.PayStatus == "C")
{
}
}
else if (purpose == "F")
{
}
else
{
ResetForm();
GetAutoInvoiceNo();
GetTotalSale();
GetOnHoldSale();
GetProduct();
tabDisplay.TabIndex = 0;
}
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
else
{
MessageBox.Show("No Item for sale!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 1;
}
}
catch (Exception ex)
{ }
}
private void tsmDelete_Click(object sender, EventArgs e)
{
RemoveGridLineItem();
}
private void tsmEdit_Click(object sender, EventArgs e)
{
EditGridLineItem();
}
private void dgvCustSearch_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.RowIndex >= 0)
{
if (dgvCustSearch.Columns[e.ColumnIndex].Name.ToString() == "custimg")
{
try
{
customerid = int.Parse(dgvCustSearch.Rows[e.RowIndex].Cells["customerid"].Value.ToString());
List<POS_PointOfSale> Customers = new List<POS_PointOfSale>();
Customers = ERPManagement.GetInstance.GetCustomerSearch();
var Customer = from Cust in Customers
where Cust.Customer_ID == customerid
select Cust;
if (Customer.Count() > 0)
{
DataGridViewCell cell = this.dgvCustSearch.Rows[e.RowIndex].Cells[e.ColumnIndex];
cell.ToolTipText = Customer.ToList()[0].CustDetails;
}
}
catch
{ }
}
}
}
private void cmCustomer_Opening(object sender, CancelEventArgs e)
{
}
private void TxtBarcode_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
if (char.IsDigit(e.KeyChar) == false && (Keys)e.KeyChar != Keys.Back)
{
e.Handled = true;
//MessageBox.Show("Special characters are not allowed.", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
TxtBarcode.Focus();
return;
}
}
catch (Exception ex)
{
}
}
private void combosearch_SelectedIndexChanged(object sender, EventArgs e)
{
if (combosearch.SelectedIndex == 0)
{
txtSearch.Enabled = true;
txtSearch.Text = "";
}
else if (combosearch.SelectedIndex == 1)
{
txtSearch.Enabled = true;
txtSearch.Text = "";
}
else
{
txtSearch.Enabled = true;
}
}
private void cmbCustomer_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbCustomer.SelectedIndex == 0)
{
txtCustomerSearch.Enabled = true;
txtCustomerSearch.Text = "";
txtCustomerSearch.Focus();
}
else if (cmbCustomer.SelectedIndex == 1)
{
txtCustomerSearch.Enabled = true;
txtCustomerSearch.Text = "";
txtCustomerSearch.Focus();
}
else if (cmbCustomer.SelectedIndex == 2)
{
txtCustomerSearch.Enabled = true;
txtCustomerSearch.Text = "";
txtCustomerSearch.Focus();
}
else
{
txtCustomerSearch.Enabled = true;
txtCustomerSearch.Focus();
}
}
private void btnAddShipping_Click(object sender, EventArgs e)
{
if (dgvCustSearch.Rows.Count > 0)
{
if (Cust_ID > 0 || lblCustomerName.Text.Trim() != "N/A")
{
if (LblAddress1.Text.Trim() != "Address1 : N/A")
{
frmShippingDetails obj = new frmShippingDetails();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
GetCustomerInformation();
// frmShippingDetails objship = new frmShippingDetails();
//if click back button for cancel
if (frmShippingDetails.status == "SC")
{
popupimgpurpose = "S";
}
else
{
//initialize status for popup
popupimgpurpose = "SS";//for ship image popup
TotalShippingCharge = frmShippingDetails.totalshipamount;
decimal shipchag = TotalNetAmount + TotalShippingCharge;
TxtNetAmount = shipchag.ToString("F");
lblGrandTotal.Text = shipchag.ToString("F");
}
}
else
{
DialogResult dr = MessageBox.Show("Please enter Customer Shipping Address Details!", "KenCloud", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
if (dr.ToString() == "OK")
{
EditCustomerDetails(Cust_ID);
frmCustomer obj = new frmCustomer();
obj.Txtaddress1.Focus();
}
}
GetCustomerInformation();
}
else
{
MessageBox.Show("Please select a Customer for Shipping!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
}
private void btnSelectAddress_Click(object sender, EventArgs e)
{
if (Cust_ID > 0 || lblCustomerName.Text.Trim() != "N/A")
{
EditCustomerDetails(Cust_ID);
GetCustomer();
GetCustomerInformation();
}
else
{
MessageBox.Show("Please select a Customer !", "KenCloud", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
}
}
private void pnlShippingDetails_Click(object sender, EventArgs e)
{
if (Cust_ID > 0 || lblCustomerName.Text.Trim() != "N/A")
{
Point p = pnlShippingDetails.Location;
p = new Point(p.X + this.Location.X + 0, this.Location.Y + p.Y + 0);
frmShippingDetailsexpand ship = new frmShippingDetailsexpand();
ship.StartPosition = FormStartPosition.Manual;
ship.Location = new Point(p.X, p.Y);
ship.ShowDialog();
GetCustomerInformation();
//if click back button for cancel
if (frmShippingDetails.status == "SC")
{
popupimgpurpose = "S";
TotalShippingCharge = frmShippingDetails.totalshipamount;
decimal shipchag = TotalNetAmount + TotalShippingCharge;
TxtNetAmount = shipchag.ToString("F");
lblGrandTotal.Text = shipchag.ToString("F");
}
else
{
//initialize status for popup
popupimgpurpose = "SS";//for ship image popup
TotalShippingCharge = frmShippingDetails.totalshipamount;
decimal shipchag = TotalNetAmount + TotalShippingCharge;
TxtNetAmount = shipchag.ToString("F");
lblGrandTotal.Text = shipchag.ToString("F");
}
}
else
{
MessageBox.Show("Please select a Customer for Shipping!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
private void btnTillCount_Click(object sender, EventArgs e)
{
frmTillCount obj = new frmTillCount();
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
obj.Location = new Point(this.Width + this.Location.X - 333, this.Location.Y + 126);
obj.ShowDialog();
}
public void clearShippdetails()
{
LblAddress1.Text = "Address1 : N/A";
LblAddress2.Text = "Address2 : N/A";
LblCity.Text = "City : N/A";
LblState.Text = "State : N/A";
LblCountry.Text = "Country : N/A";
LblZip.Text = "Pin : N/A";
LblShipPhn.Text = "Phone : N/A";
LblShipMail.Text = "E-Mail : N/A";
lblShippingCharge.Text = "Shipping Charge :N/A";
//GetCustomer();
}
private void btnClearAddress_Click(object sender, EventArgs e)
{
if (Cust_ID > 0 || lblCustomerName.Text.Trim() != "N/A")
{
if (LblAddress1.Text.Trim() != "Address1 : N/A")
{
DialogResult dr = MessageBox.Show("Are you sure to delete selected Customer Shipping Details.", "KenCloud", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr.ToString() == "OK")
{
ERPManagement.GetInstance.ClearShippingAddress(Cust_ID, 1);
LblAddress1.Text = "Address1 : N/A";
LblAddress2.Text = "Address2 : N/A";
LblCity.Text = "City : N/A";
LblState.Text = "State : N/A";
LblCountry.Text = "Country : N/A";
LblZip.Text = "Pin : N/A";
LblShipPhn.Text = "Phone : N/A";
LblShipMail.Text = "E-Mail : N/A";
lblShippingCharge.Text = "Shipping Charge :N/A";
//GetCustomer();
}
}
else
{
MessageBox.Show("No records for Delete !", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
//tabDisplay.SelectedIndex = 2;
}
}
else
{
MessageBox.Show("Select one customer!", "KenCloud", MessageBoxButtons.OK, MessageBoxIcon.Warning);
tabDisplay.SelectedIndex = 2;
}
}
private void BarcodeMarker(string barcode)
{
try
{
int availlevel = 0;
int maxlevel = 0;
int reqlevel = 0;
if (TxtBarcode.Text.Trim() != "")
{
List<POS_PointOfSale> listPOS = ERPManagement.GetInstance.GetBarcodeLevel(barcode);
if (listPOS.Count > 0)
{
availlevel = Convert.ToInt16(Convert.ToString(listPOS.ToArray()[0].Available_Stock));
maxlevel = Convert.ToInt16(Convert.ToString(listPOS.ToArray()[0].Maximum_Stock) == "" ? "0" : Convert.ToString(listPOS.ToArray()[0].Maximum_Stock));
reqlevel = Convert.ToInt16(Convert.ToString(listPOS.ToArray()[0].Minimum_Stock));
}
decimal percentage = 0;
if (maxlevel > 0)
{
percentage = ((decimal)reqlevel * 100) / (decimal)maxlevel;
}
else
{
maxlevel = availlevel;
}
int needwidth = (int)((percentage * stockprogressBar.Width) / 100);
pnlmark.Location = new Point(locationX + needwidth, locationY);
stockprogressBar.Maximum = maxlevel;
stockprogressBar.Minimum = 0;
if (availlevel >= maxlevel)
{
stockprogressBar.Value = maxlevel;
}
else
{
stockprogressBar.Value = availlevel;
}
pnlmark.Visible = true;
}
else
{
pnlmark.Visible = false;
}
}
catch (Exception)
{
}
}
private void quoteToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
EnableControl();
ResetForm();
Point p = GridViewItems.Location;
p = new Point(GridViewItems.Location.X + this.Location.X + 7, p.Y + 126);
frmViewSale obj = new frmViewSale("Q");
obj.StartPosition = FormStartPosition.Manual;
obj.Location = btnF11Total.Location; //Cursor.Position;
obj.Location = new Point(p.X, p.Y);
obj.ShowDialog();
SaleId = obj.saleid;
//set saleid to maxsaleid for complee transaction bcoz maxsaleid pass to paymentsell page
maxsaleid = SaleId.ToString();
if (SaleId != 0)
{
GetSaleData();
GetSaleDetails();
GetSaleCustomer();
//false gridview line focus
GridViewItems.Rows[0].Selected = false;
stockprogressBar.Value = 0;
}
else
{
ResetForm();
GetAutoInvoiceNo();
}
}
catch
{
}
}
private void btnOrdersbottom_Click(object sender, EventArgs e)
{
Transaction("O");
}
private void tabDisplay_Click(object sender, EventArgs e)
{
if (tabDisplay.SelectedTab.Text == "Products")
{
if (z == 1)
{
GetProduct();
//assign default value
z = 0;
}
//else
//{
// i = 0;
//}
}
}
private void dgvProdSearch_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
//===========================================================
#endregion
}
public class POSCustomer
{
public int Customer_ID
{
set;
get;
}
public string Customer_Name
{
set;
get;
}
public string CustomerPhone
{
set;
get;
}
public Image Imagevalue
{
get;
set;
}
}
}
No comments:
Post a Comment