Ejemplo n.º 1
0
        private void dgvDetailList_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            Decimal qty = Decimal.Zero, uamt = Decimal.Zero, amt = Decimal.Zero;

            try
            {
                qty  = Convert.ToDecimal(dgvDetailList.Rows[e.RowIndex].Cells[5].Value.ToString()); // Qty
                uamt = Convert.ToDecimal(dgvDetailList.Rows[e.RowIndex].Cells[7].Value.ToString()); // Unit Amount

                amt = (decimal)qty * uamt;
            }
            catch { }

            dgvDetailList.Rows[e.RowIndex].Cells[8].Value = amt; // Amount

            if (qty > 0)
            {
                dgvDetailList.Rows[e.RowIndex].Cells[5].Style.Font = new Font(dgvDetailList.DefaultCellStyle.Font, FontStyle.Bold);
                dgvDetailList.Rows[e.RowIndex].Cells[6].Style.Font = new Font(dgvDetailList.DefaultCellStyle.Font, FontStyle.Bold);
            }

            if (uamt > 0)
            {
                dgvDetailList.Rows[e.RowIndex].Cells[7].Style.Font = new Font(dgvDetailList.DefaultCellStyle.Font, FontStyle.Bold);
                dgvDetailList.Rows[e.RowIndex].Cells[8].Style.Font = new Font(dgvDetailList.DefaultCellStyle.Font, FontStyle.Bold);
            }

            if (DAL.Common.Utility.IsGUID(dgvDetailList.Rows[e.RowIndex].Cells[0].Value.ToString()))
            {
                Guid productId = new Guid(dgvDetailList.Rows[e.RowIndex].Cells[0].Value.ToString());

                DetailData detail = ResultList.Find(d => d.ProductId == productId);

                if (detail == null)
                {
                    detail            = new DetailData();
                    detail.ProductId  = productId;
                    detail.Qty        = qty;
                    detail.UnitAmount = uamt;
                }
                else
                {
                    ResultList.Remove(detail);

                    detail.Qty        = qty;
                    detail.UnitAmount = uamt;
                }

                ResultList.Add(detail);
            }

            CalcSubTotalQty();
        }
Ejemplo n.º 2
0
        public List <DetailData> SetDetailData(string STKCODE)
        {
            List <DetailData> resultList = new List <DetailData>();

            foreach (DataGridViewRow row in dgvDetailList.Rows)
            {
                if (row.Cells[3].Value.ToString().Trim() == STKCODE)
                {
                    decimal qty  = Convert.ToDecimal(row.Cells[8].Value.ToString()); // Qty
                    decimal uamt = Convert.ToDecimal(row.Cells[9].Value.ToString()); // Unit Amount

                    if (DAL.Common.Utility.IsGUID(row.Cells[12].Value.ToString()))
                    {
                        Guid productId = new Guid(row.Cells[12].Value.ToString());

                        DetailData detail = resultList.Find(d => d.ProductId == productId);

                        if (detail == null)
                        {
                            detail            = new DetailData();
                            detail.ProductId  = productId;
                            detail.Qty        = qty;
                            detail.UnitAmount = uamt;
                        }
                        else
                        {
                            resultList.Remove(detail);

                            detail.Qty        = qty;
                            detail.UnitAmount = uamt;
                        }

                        resultList.Add(detail);
                    }
                }
            }

            return(resultList);
        }