Beispiel #1
0
        public List<InvoiceDetailBO> GetInvoiceDetailByInvoiceID(int invoiceID)
        {
            DBEgine objDbAccess = new DBEgine();
            var list = new List<InvoiceDetailBO>();
            try
            {
                SqlParameter[] parms = new SqlParameter[1];

                SqlParameter parmItemID = new SqlParameter();
                parmItemID.Value = invoiceID;
                parmItemID.SqlDbType = SqlDbType.Int;
                parmItemID.Direction = ParameterDirection.Input;
                parmItemID.ParameterName = "@InvoiceID";
                parms[0] = parmItemID;

                objDbAccess.DBOpen();

                SqlDataReader dr = objDbAccess.ExecuteReader("Sales.GetInvoiceDetailByInvoiceID", parms);

                while (dr.Read())
                {
                    var invoiceDetailBO = new InvoiceDetailBO();

                    invoiceDetailBO.InvoiceDetailId = int.Parse(dr["InvoiceDetailID"].ToString());
                    invoiceDetailBO.InvoiceId = int.Parse(dr["InvoiceID"].ToString());
                    invoiceDetailBO.ItemId = int.Parse(dr["ItemID"].ToString());
                    invoiceDetailBO.Quantity = decimal.Parse(dr["Qty"].ToString());
                    invoiceDetailBO.SubTotal = decimal.Parse(dr["SubTotal"].ToString());
                    invoiceDetailBO.ItemSerial = dr["SubItemSerial"].ToString();
                    invoiceDetailBO.ItemDescription = dr["SubItemDescription"].ToString();

                    list.Add(invoiceDetailBO);

                }
                return list;

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objDbAccess.DBClose();
            }
        }
Beispiel #2
0
        private bool SaveInvoiceDetail(DBEgine objDbAccess, InvoiceDetailBO invoiceDetail)
        {
            bool result = false;
            try
            {
                SqlParameter[] parms = new SqlParameter[4];

                SqlParameter parmInvoiceId = new SqlParameter();
                parmInvoiceId.Value = invoiceDetail.InvoiceId;
                parmInvoiceId.SqlDbType = SqlDbType.Int;
                parmInvoiceId.Direction = ParameterDirection.Input;
                parmInvoiceId.ParameterName = "@InvoiceID";
                parms[0] = parmInvoiceId;

                SqlParameter parmItemId = new SqlParameter();
                parmItemId.Value = invoiceDetail.ItemId;
                parmItemId.SqlDbType = SqlDbType.Int;
                parmItemId.Direction = ParameterDirection.Input;
                parmItemId.ParameterName = "@ItemID";
                parms[1] = parmItemId;

                SqlParameter parmQuantity = new SqlParameter();
                parmQuantity.Value = invoiceDetail.Quantity;
                parmQuantity.SqlDbType = SqlDbType.Decimal;
                parmQuantity.Direction = ParameterDirection.Input;
                parmQuantity.ParameterName = "@Qty";
                parms[2] = parmQuantity;

                SqlParameter parmCSubTotal = new SqlParameter();
                parmCSubTotal.Value = invoiceDetail.SubTotal;
                parmCSubTotal.SqlDbType = SqlDbType.Decimal;
                parmCSubTotal.Direction = ParameterDirection.Input;
                parmCSubTotal.ParameterName = "@SubTotal";
                parms[3] = parmCSubTotal;

                if (objDbAccess.ExecNonQueryStoredProc("Sales.SaveInvoiceDetail", parms) > 0)
                {
                    result = true;
                }
                return result;

            }
            catch
            {
                throw ;
            }
        }
Beispiel #3
0
        private void AddItem()
        {
            try
            {
                var invoiceDetailBO = new InvoiceDetailBO();

                var subItem = new SubItemDAL().GetSubItemByItemSerial(textBoxSubItemNo.Text.Trim());
                SubItemID = subItem.SubItemID;
                decimal unitPrice = subItem.SubItemUnitPrice;
                SubItemDescription = subItem.SubItemDescription;

                invoiceDetailBO.InvoiceDetailId = -1;
                invoiceDetailBO.InvoiceId = InvoiceID;
                invoiceDetailBO.ItemId = SubItemID;
                invoiceDetailBO.Quantity = numericUpDownQty.Value;
                //invoiceDetailBO.SubTotal = numericUpDownQty.Value * decimal.Parse(textBoxUnitPrice.Text);
                invoiceDetailBO.SubTotal = numericUpDownQty.Value * unitPrice;
                invoiceDetailBO.ItemSerial = textBoxSubItemNo.Text.Trim();
                invoiceDetailBO.ItemDescription = SubItemDescription;

                var foundObject =new InvoiceDetailBO();
                if (InvoiceDetailBOList != null)
                    foundObject = InvoiceDetailBOList.Find(s => s.ItemId == SubItemID);

                if (foundObject !=null )
                {
                    //MessageBoxClass.ShowMessage(CommonMethods.GetError("SAL_010"), false);
                    InvoiceDetailBOList.Find(s => s.ItemId == SubItemID).Quantity = foundObject.Quantity + invoiceDetailBO.Quantity;
                    InvoiceDetailBOList.Find(s => s.ItemId == SubItemID).SubTotal = foundObject.SubTotal + invoiceDetailBO.SubTotal;

                }
                else
                {
                    InvoiceDetailBOList.Add(invoiceDetailBO);
                }
                BindDataToGridView();
                ClearInvoiceDetail();

            }
            catch
            {
                MessageBoxClass.ShowMessage(CommonMethods.GetError("U_007"), true);
            }
        }